OLD | NEW |
1 # Android Studio | 1 # Android Studio |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Usage | 5 ## Usage |
6 | 6 |
7 Make sure you have followed | 7 Make sure you have followed |
8 [android build instructions](android_build_instructions.md) already. | 8 [android build instructions](android_build_instructions.md) already. |
9 | 9 |
10 ```shell | 10 ```shell |
11 build/android/gradle/generate_gradle.py | 11 build/android/gradle/generate_gradle.py |
12 ``` | 12 ``` |
13 | 13 |
14 This creates a project at `out/Debug/gradle`. To create elsewhere: | 14 This creates a project at `out/Debug/gradle`. To create elsewhere: |
15 | 15 |
16 ```shell | 16 ```shell |
17 build/android/gradle/generate_gradle.py --output-directory out/My-Out-Dir --proj
ect-dir my-project | 17 build/android/gradle/generate_gradle.py --output-directory out/My-Out-Dir --proj
ect-dir my-project |
18 ``` | 18 ``` |
19 | 19 |
20 By default, only common targets are generated. To customize the list of targets | 20 By default, only common targets are generated. To customize the list of targets |
21 to generate projects for: | 21 to generate projects for: |
22 | 22 |
23 ```shell | 23 ```shell |
24 build/android/gradle/generate_gradle.py --target //some:target_apk --target //so
me/other:target_apk | 24 build/android/gradle/generate_gradle.py --target //chrome/android:chrome_public_
apk --target //android_webview/test:android_webview_apk |
25 ``` | 25 ``` |
26 | 26 |
27 For first-time Android Studio users: | 27 For first-time Android Studio users: |
28 | 28 |
29 * Avoid running the setup wizard. | 29 * Avoid running the setup wizard. |
30 * The wizard will force you to download unwanted SDK components to | 30 * The wizard will force you to download unwanted SDK components to |
31 `//third_party/android_tools`. | 31 `//third_party/android_tools`. |
32 * To skip it, select "Cancel" when it comes up. | 32 * To skip it, select "Cancel" when it comes up. |
33 | 33 |
34 To import the project: | 34 To import the project: |
35 | 35 |
36 * Use "Import Project", and select the directory containing the generated | 36 * Use "Import Project", and select the directory containing the generated |
37 project, by default `out-gn/Debug/gradle`. | 37 project, by default `out/Debug/gradle`. |
38 | 38 |
39 You need to re-run `generate_gradle.py` whenever `BUILD.gn` files change. | 39 You need to re-run `generate_gradle.py` whenever `BUILD.gn` files change. |
40 | 40 |
41 * After regenerating, Android Studio should prompt you to "Sync". If it | 41 * After regenerating, Android Studio should prompt you to "Sync". If it |
42 doesn't, use: | 42 doesn't, use: |
| 43 * Button with two arrows on the right side of the top strip. |
43 * Help -> Find Action -> "Sync Project with Gradle Files" | 44 * Help -> Find Action -> "Sync Project with Gradle Files" |
44 | 45 * After `gn clean` you may need to restart Android Studio. |
45 | 46 |
46 ## How it Works | 47 ## How it Works |
47 | 48 |
48 Android Studio integration works by generating `build.gradle` files based on GN | 49 Android Studio integration works by generating `build.gradle` files based on GN |
49 targets. Each `android_apk` and `android_library` target produces a separate | 50 targets. Each `android_apk` and `android_library` target produces a separate |
50 Gradle sub-project. | 51 Gradle sub-project. |
51 | 52 |
52 ### Excluded files and .srcjars | 53 ### Excluded files and .srcjars |
53 | 54 |
54 Gradle supports source directories but not source files. However, some | 55 Gradle supports source directories but not source files. However, some |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 109 |
109 The resulting artifacts are not terribly useful. They are missing assets, | 110 The resulting artifacts are not terribly useful. They are missing assets, |
110 resources, native libraries, etc. | 111 resources, native libraries, etc. |
111 | 112 |
112 * Use a | 113 * Use a |
113 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html) | 114 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html) |
114 to speed up builds using the gradlew script: | 115 to speed up builds using the gradlew script: |
115 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`, | 116 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`, |
116 creating it if necessary. | 117 creating it if necessary. |
117 | 118 |
118 ## Status (as of Jan 19, 2017) | 119 ## Status (as of Feb 7th, 2017) |
119 | 120 |
120 ### What works | 121 ### What works |
121 | 122 |
122 * Tested with Android Studio v2.2. | 123 * Tested with Android Studio v2.2. |
123 * Java editing and gradle compile works. | 124 * Java editing and gradle compile works. |
124 * Instrumentation tests included as androidTest. | 125 * Instrumentation tests included as androidTest. |
125 * Symlinks to existing .so files in jniLibs (doesn't generate them). | 126 * Symlinks to existing .so files in jniLibs (doesn't generate them). |
| 127 * Editing resource xml files. |
126 | 128 |
127 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues
/detail?id=620034)) | 129 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues
/detail?id=620034)) |
128 | 130 |
129 * Make gradle aware of resources and assets | 131 * Make gradle aware of assets |
| 132 * Layout editor |
130 * Add a mode in which gradle is responsible for generating `R.java` | 133 * Add a mode in which gradle is responsible for generating `R.java` |
131 * Add support for native code editing | 134 * Add support for native code editing |
132 * Make the "Make Project" button work correctly | 135 * Make the "Make Project" button work correctly |
OLD | NEW |