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 //chrome/android:chrome_public_
apk --target //android_webview/test:android_webview_apk | 24 build/android/gradle/generate_gradle.py --target //some:target_apk --target //so
me/other:target_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/Debug/gradle`. | 37 project, by default `out-gn/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. | |
44 * Help -> Find Action -> "Sync Project with Gradle Files" | 43 * Help -> Find Action -> "Sync Project with Gradle Files" |
45 * After `gn clean` you may need to restart Android Studio. | 44 |
46 | 45 |
47 ## How it Works | 46 ## How it Works |
48 | 47 |
49 Android Studio integration works by generating `build.gradle` files based on GN | 48 Android Studio integration works by generating `build.gradle` files based on GN |
50 targets. Each `android_apk` and `android_library` target produces a separate | 49 targets. Each `android_apk` and `android_library` target produces a separate |
51 Gradle sub-project. | 50 Gradle sub-project. |
52 | 51 |
53 ### Excluded files and .srcjars | 52 ### Excluded files and .srcjars |
54 | 53 |
55 Gradle supports source directories but not source files. However, some | 54 Gradle supports source directories but not source files. However, some |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 108 |
110 The resulting artifacts are not terribly useful. They are missing assets, | 109 The resulting artifacts are not terribly useful. They are missing assets, |
111 resources, native libraries, etc. | 110 resources, native libraries, etc. |
112 | 111 |
113 * Use a | 112 * Use a |
114 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html) | 113 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html) |
115 to speed up builds using the gradlew script: | 114 to speed up builds using the gradlew script: |
116 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`, | 115 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`, |
117 creating it if necessary. | 116 creating it if necessary. |
118 | 117 |
119 ## Status (as of Feb 7th, 2017) | 118 ## Status (as of Jan 19, 2017) |
120 | 119 |
121 ### What works | 120 ### What works |
122 | 121 |
123 * Tested with Android Studio v2.2. | 122 * Tested with Android Studio v2.2. |
124 * Java editing and gradle compile works. | 123 * Java editing and gradle compile works. |
125 * Instrumentation tests included as androidTest. | 124 * Instrumentation tests included as androidTest. |
126 * Symlinks to existing .so files in jniLibs (doesn't generate them). | 125 * Symlinks to existing .so files in jniLibs (doesn't generate them). |
127 * Editing resource xml files. | |
128 | 126 |
129 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues
/detail?id=620034)) | 127 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues
/detail?id=620034)) |
130 | 128 |
131 * Make gradle aware of assets | 129 * Make gradle aware of resources and assets |
132 * Layout editor | |
133 * Add a mode in which gradle is responsible for generating `R.java` | 130 * Add a mode in which gradle is responsible for generating `R.java` |
134 * Add support for native code editing | 131 * Add support for native code editing |
135 * Make the "Make Project" button work correctly | 132 * Make the "Make Project" button work correctly |
OLD | NEW |