Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: docs/android_studio.md

Issue 2837863002: Android: Remove apk modules for Android Studio (Closed)
Patch Set: Update docs. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gradle/generate_gradle.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, common targets are generated. To add more targets to generate 20 By default, common targets are generated. To add more targets to generate
21 projects for: 21 projects for:
22 22
23 ```shell 23 ```shell
24 build/android/gradle/generate_gradle.py --extra-target //chrome/android:chrome_p ublic_apk 24 build/android/gradle/generate_gradle.py --extra-target //chrome/android:chrome_p ublic_apk
25 ``` 25 ```
26 26
27 For those upgrading from Android Studio 2.2 to 2.3:
28
29 * Use `gn clean` and `gn gen`
30 * Clean up in `//third_party/android_tools` with `git clean -ffd`.
31 * Remove project from android studio and regenerate with `generate_gradle.py`.
32
33 For first-time Android Studio users: 27 For first-time Android Studio users:
34 28
35 * Avoid running the setup wizard. 29 * Avoid running the setup wizard.
36 * The wizard will force you to download unwanted SDK components to 30 * The wizard will force you to download unwanted SDK components to
37 `//third_party/android_tools`. 31 `//third_party/android_tools`.
38 * To skip it, select "Cancel" when it comes up. 32 * To skip it, select "Cancel" when it comes up.
39 33
34 For those upgrading from Android Studio 2.2 to 2.3:
35
36 * Use `gn clean` and `gn gen`
37 * Clean up in `//third_party/android_tools` with `git clean -ffd`.
38 * Remove project from android studio and regenerate with `generate_gradle.py`.
39
40 To import the project: 40 To import the project:
41 41
42 * Use "Import Project", and select the directory containing the generated 42 * Use "Import Project", and select the directory containing the generated
43 project, by default `out/Debug/gradle`. 43 project, by default `out/Debug/gradle`.
44 44
45 You need to re-run `generate_gradle.py` whenever `BUILD.gn` files change. 45 You need to re-run `generate_gradle.py` whenever `BUILD.gn` files change.
46 46
47 * After regenerating, Android Studio should prompt you to "Sync". If it 47 * After regenerating, Android Studio should prompt you to "Sync". If it
48 doesn't, use: 48 doesn't, use:
49 * Button with two arrows on the right side of the top strip. 49 * Button with two arrows on the right side of the top strip.
50 * Help -> Find Action -> "Sync Project with Gradle Files" 50 * Help -> Find Action -> "Sync Project with Gradle Files"
51 * After `gn clean` you may need to restart Android Studio. 51 * After `gn clean` you may need to restart Android Studio.
52 52
53 ## How It Works 53 ## How It Works
54 54
55 Android Studio integration works by generating `build.gradle` files based on GN 55 By default, only a single module is generated. If more than one apk target is
56 targets. Each valid target produces a separate Gradle sub-project. 56 specified, then an `_all` module is generated. Otherwise a single apk module is
57 Instrumentation tests are combined with their `apk_under_test`. 57 generated. Since instrumentation tests are combined with their `apk_under_test`
58 target, they count as one module together.
59
60 To see more detailed structure of gn targets, the `--split-projects` flag can
61 be used. This will generate one module for every gn target in the dependency
62 graph.
58 63
59 ### Excluded Files 64 ### Excluded Files
60 65
61 Gradle supports source directories but not source files. However, files in 66 Gradle supports source directories but not source files. However, files in
62 Chromium are used amongst multiple targets. To accommodate this, the script 67 Chromium are used amongst multiple targets. To accommodate this, the script
63 detects such targets and creates exclude patterns to exclude files not in the 68 detects such targets and creates exclude patterns to exclude files not in the
64 current target. The editor does not respect these exclude patterns, so a `_all` 69 current target. The editor does not respect these exclude patterns, so a `_all`
65 pseudo module is added which includes directories from all targets. This allows 70 pseudo module is added which includes directories from all targets. This allows
66 imports and refactorings to be searched across all targets. 71 imports and refactorings to be searched across all targets.
67 72
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 125
121 The resulting artifacts are not terribly useful. They are missing assets, 126 The resulting artifacts are not terribly useful. They are missing assets,
122 resources, native libraries, etc. 127 resources, native libraries, etc.
123 128
124 * Use a 129 * Use a
125 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html) 130 [gradle daemon](https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html)
126 to speed up builds using the gradlew script: 131 to speed up builds using the gradlew script:
127 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`, 132 * Add the line `org.gradle.daemon=true` to `~/.gradle/gradle.properties`,
128 creating it if necessary. 133 creating it if necessary.
129 134
130 ## Status (as of April 19th, 2017) 135 ## Status (as of April 27th, 2017)
131 136
132 ### What works 137 ### What works
133 138
134 * Android Studio v2.3. 139 * Android Studio v2.3.
135 * Java editing and gradle compile. 140 * Java editing and gradle compile.
136 * Instrumentation tests included as androidTest. 141 * Instrumentation tests included as androidTest.
137 * Symlinks to existing .so files in jniLibs (doesn't generate them). 142 * Symlinks to existing .so files in jniLibs (doesn't generate them).
138 * Editing resource xml files. 143 * Editing resource xml files.
139 * Java debugging (see 144 * Java debugging (see
140 [here](/docs/android_debugging_instructions.md#Android-Studio)). 145 [here](/docs/android_debugging_instructions.md#Android-Studio)).
141 * Import resolution and refactoring across all modules. 146 * Import resolution and refactoring across all modules.
147 * Correct lint and AndroidManifest when only one target is specified.
142 148
143 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues /detail?id=620034)) 149 ### What doesn't work (yet) ([crbug](https://bugs.chromium.org/p/chromium/issues /detail?id=620034))
144 150
145 * Gradle being aware of assets. 151 * Gradle being aware of assets.
146 * Layout editor. 152 * Layout editor.
147 * Add support for native code editing. 153 * Add support for native code editing.
148 * Make the "Make Project" button work correctly. 154 * Make the "Make Project" button work correctly.
OLDNEW
« no previous file with comments | « build/android/gradle/generate_gradle.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698