Android Studio Tips and Tricks
ãAndroid Developersã®Android Studioã«é¢ããtipséã翻訳ãã¾ããã翻訳ã®ééãçãããããããªãã®ã§ã詳細ã«ã¤ãã¦ã¯å
è¨äºãåç
§ãã¦ä¸ãããééããããã°ãç¥ããä¸ããã
å
è¨äº:Android Studio Tips and Tricks
Android Studio Tips and Tricks
ãããIntelliJ IDEAã®ã¤ã³ã¿ãã§ã¼ã¹ã«ä¸æ
£ããªå ´åãAndroid Studioã®ä¸è¬çãªã¿ã¹ã¯ã®å®è¡æ¹æ³ãä¸æè°ã«æãããããã¾ããããã®ãã¼ã¸ã§ã¯éçºã«å½¹ç«ã¤tipsãæä¾ãã¾ãã
ãIntelliJ IDEAã®ã¤ã³ã¿ãã§ã¼ã¹ã®å®å
¨ãªããã¥ã¡ã³ãã¯(Android Studioã¯IntelliJ IDEAããã¼ã¹ã«ä½ããã¦ãã¾ã)ãIntelliJ IDEA documentationãåç
§ãã¦ä¸ããã
Projectã®æ§æ
å³.1 Gradleã®ããã¸ã§ã¯ãæ§æ
ãAndroid Studioã§æ°ããããã¸ã§ã¯ããä½ãæ(ãããã¯Eclipseã§ã®ããã¸ã§ã¯ãã移è¡ããæ)ãããã¸ã§ã¯ãã®æ§æããã¤ãã¨éãã¨ããäºã«æ°ãã¤ãã§ããããå³.1ãè¦ã¦ä¸ããããªã½ã¼ã¹ãAndroidManifest.xmlãªã©ããã¸ã§ã¯ãã®ãã¡ã¤ã«ã®æ®ã©ã"src"ãã£ã¬ã¯ããªã®ä¸ã«ããã¾ãã
ãæ°ããããã¸ã§ã¯ãã®æ§æã¯Gradleãã¼ã¹ã®ãã«ãã·ã¹ãã ã¸ã®åãæ¿ãã«ãããã®ã§ãããã®æ§æã¯ãã«ãããã»ã¹ããããã¬ãã·ãã«ã«ããè¤æ°ã®ç¨®é¡ã®ãã«ããå¯è½ã«ãã¾ã(â»ã¾ã å
¨ã¦ã®æ©è½ã¯å®è£
ããã¦ãã¾ãã)ã大ä½æå¾
éãã«åä½ããã¨æãã¾ãããä¸é¨ã®ãã¡ã¤ã«ã¯ç§»åããããã¦ãã¾ããã»ã¨ãã©ã®é¨åã«ã¤ãã¦ã¯ã"src"ãã£ã¬ã¯ããªå
ã®ãã¡ã¤ã«ã ããå¤æ´ããäºã«ãªãã¾ããGradleã®ããã¸ã§ã¯ãæ§é ã®è©³ç´°ã«ã¤ãã¦ã¯ãGradle Plugin User Guideãåç
§ãã¦ä¸ããã
åºæ¬çãªãªãã¬ã¼ã·ã§ã³
ã以ä¸ã®ãããã¯ã¯Android Studioã®åºæ¬çãªéçºã¿ã¹ã¯ã«ã¤ãã¦è§£èª¬ãã¦ãã¾ãã
ä»®æ³ããã¤ã¹ã®ä½æ
ãAndroid Virtual Device Managerã®å ¨ã¦ã®æ©è½ã«Android Studioããç´æ¥ã¢ã¯ã»ã¹åºæ¥ã¾ãããã¼ã«ãã¼å ã®Android Virtual Device Managerãã¯ãªãã¯ãã¦èµ·åããäºãåºæ¥ã¾ããæ°ããä»®æ³ããã¤ã¹ã®ä½æãèµ·åãªã©ãè¡ãäºãåºæ¥ã¾ãã
Installing SDK updates
ãSDK Managerã«ãã¢ã¯ã»ã¹åºæ¥ã¾ããAndroid toolsãplatformsãã©ã¤ãã©ãªãªã©ããã¦ã³ãã¼ãåºæ¥ã¾ãããã¼ã«ãã¼ã®SDK Managerããèµ·åããäºãåºæ¥ã¾ãã
æ°ãããã¡ã¤ã«ã®ä½æ
ãããã¸ã§ã¯ãå
ã®ãã£ã¬ã¯ããªãé¸æããCTRL+N(Macã®å ´åã¯CMD + N)ã§ç´ æ©ãæ°ããã³ã¼ãããªã½ã¼ã¹ãã¡ã¤ã«ã追å ããäºãåºæ¥ã¾ããé¸æãããã£ã¬ã¯ããªã®ç¨®é¡ã«å¿ãã¦é©åãªãã¡ã¤ã«ãé¸æããäºãåºæ¥ã¾ãã
ãä¾ãã°ã"layout"ãã£ã¬ã¯ããªãé¸æãã¦CTRL + NããããAndroid resource fileããé¸æããã¨ãã¤ã¢ãã°ãéãããã¡ã¤ã«å(èªåã§suffixã«.xmlãä»ãã¾ã)ãå
¥åããããRootã¨ãªãViewãè¨å®ãããããäºãåºæ¥ã¾ããä½æãããã¡ã¤ã«ãéãã¨ã¨ãã£ã¿ãlayout design editorã«èªåçã«åãæ¿ããã¾ãã
ã¬ã¤ã¢ã¦ãã®ä½æ
ãAndroid Studioã¯é«åº¦ãªã¬ã¤ã¢ã¦ãã¨ãã£ã¿ãæä¾ãã¾ããXMLãã¨ãã£ãããã¦ããéã¬ã¤ã¢ã¦ãã®ãã¬ãã¥ã¼ã表示ããããã¦ã£ã¸ã§ããããã©ãã°&ããããã§é
ç½®ããäºãåºæ¥ã¾ããããã¹ãã§ã¬ã¤ã¢ã¦ãXMLãç·¨éãã¦ããéãã¦ã£ã³ãã¦ã®å³å´ã®Previewãã¤ã³ãéãã¦ããã¤ã¹ä¸ã§ã®ã¬ã¤ã¢ã¦ãããã¬ãã¥ã¼ããäºãåºæ¥ã¾ããPreviewãã¤ã³ã®ä¸é¨ã§ãã¬ãã¥ã¼ã®ãªãã·ã§ã³ãå¤æ´ããäºãåºæ¥ã¾ãããªãã·ã§ã³ã«ã¯ããã¤ã¹ã®ç¨®é¡ããã¼ãããã©ãããã©ã¼ã ã®ãã¼ã¸ã§ã³ãªã©ãããã¾ããè¤æ°ã®ããã¤ã¹ã®ã¬ã¤ã¢ã¦ããåæã«ãã¬ãã¥ã¼ããã«ã¯ãããã¤ã¹é¸æã®ãªãã·ã§ã³ã§ãPreview All Screen Sizesããé¸æãã¦ä¸ããã
ãã¬ã¤ã¢ã¦ãã¨ãã£ã¿ã®ä¸é¨ã®ãDesignãã¿ããé¸æããã¨ã°ã©ãã£ã«ã«ã«ã¬ã¤ã¢ã¦ããç·¨éåºæ¥ãã¨ãã£ã¿ã«ã¹ã¤ãããã¾ããDesignãã¥ã¼ã§ã¯ã¦ã£ã³ãã¦ã®å·¦å´ã«ãããã¬ããããã¦ã£ã¸ã§ããããã©ãã°&ããããããäºãåºæ¥ã¾ããã¦ã£ã³ãã¦ã®å³å´ã®ãDesignerããã¤ã³ãã¯ãªãã¯ãã¦éãã¨ãã¬ã¤ã¢ã¦ãã®é層ããã¬ã¤ã¢ã¦ãå
ã®Viewã®ããããã£ã®ãªã¹ãã表示ããã¾ãã
Debugging
ãAndroid Studioã§ã¢ããªã±ã¼ã·ã§ã³ããã«ããããå®è¡ãã¦ããæãã¦ã£ã³ãã¦ä¸é¨ã®ãAndroidããã¤ã³ããDDMSãã¤ã³ãéãã¦logcatã表示ããäºãåºæ¥ã¾ãã
ãAndroid Device Monitorã§ã¢ããªã±ã¼ã·ã§ã³ããããã°ãããå ´åããã¼ã«ãã¼ããèµ·åããäºãåºæ¥ã¾ããAndroid Device Monitorã¯ããã¤ã¹ã®åä½ãå¶å¾¡ãã¢ããªã±ã¼ã·ã§ã³ã®ãããã¡ã¤ã«ãªã©ãè¡ãDDMSã®æ©è½ãå
¨ã¦å«ã¿ãã¢ããªã±ã¼ã·ã§ã³ã®ã¬ã¤ã¢ã¦ããæé©åããã®ãå©ããHierarchy Viewerãªã©ãå«ã¾ãã¦ãã¾ãã
Keyboard Commands
ã以ä¸ã®ãã¼ãã«ã¯åºæ¬çãªå¦çã®ã·ã§ã¼ãã«ããã§ãã
Note: ããMac OS Xã使ã£ã¦ãããªããAndroid Studioã®[Preference]-[Keymap]ã§ãMac OS X 10.5+ãã«è¨å®ãã¦ä¸ããã
(訳注:Macã§ã¯ã¨ããã©ããCTRLã®æãCMDã«ããªãã¨ãããªãã£ããããã®ã§é©å®èª¿æ´ãã¦ä¸ãã)
Table 1. Programming key commands
Action | Android Studio Key Command |
---|---|
ã³ãã³ãã®ã«ãã¯ã¢ãã | CTRL + SHIFT + A |
ã¯ã¤ãã¯ãã£ãã¯ã¹ | ALT + ENTER |
ã³ã¼ãã®ãªãã©ã¼ããã | CTRL + ALT + L (Win) OPTION + CMD + L (Mac) |
é¸æããAPIã®docsã表示ãã | CTRL + Q (Win) F1 (Mac) |
é¸æããã¡ã½ããã®ãã©ã¡ã¼ã¿ã表示 | CTRL + P |
ã¡ã½ããã®çæ | ALT + Insert (Win) CMD + N (Mac) |
ã½ã¼ã¹ã¸ã®ã¸ã£ã³ã | F4 (Win) CMD + down-arrow (Mac) |
è¡ã®åé¤ | CTRL + Y (Win) CMD + Backspace (Mac) |
Search by symbol name | CTRL + ALT + SHIFT + N (Win) OPTION + CMD + O (Mac) |
Table 2. Project and editor key commands
Action | Android Studio Key Command |
---|---|
ãã«ã | CTRL + F9 (Win) CMD + F9 (Mac) |
ãã«ã+å®è¡ | SHIFT + F10 (Win) CTRL + R (Mac) |
Projectãã¤ã³ã®è¡¨ç¤ºåãæ¿ã(表示/é表示) | ALT + 1 (Win) CMD + 1 (Mac) |
ã¿ãã®ç§»å | ALT + left-arrow; ALT + right-arrow (Win) CTRL + left-arrow; CTRL + right-arrow (Mac)(訳注:çè ã®ç°å¢ã§ã¯CMD+ALT+ç¢å°ã§ç§»åã§ãã) |
ãã¼ãããã®å®å ¨ãªã¬ã¤ãã«ã¤ãã¦ã¯IntelliJ IDEA documentationãåç §ãã¦ä¸ããã
æ責ï¼ã«ã¹ã¿ãã¼éçºé¨ãåå·éçºèª² å «æ¨ ä¿åº