

You need to disable a new gradle option in order to edit native files: File -> Settings -> Experimental -> Gradle and uncheck “Only resolve selected variants”. Accept Android Studio's prompts for these SDK packages. This will require you to install cmake and ndk when prompted. The target must be the full path and name of a valid gn target (no shorthands). Pass in any number of -native-target flags in order to try it out. Native FilesĪ new experimental option is now available to enable editing native C/C++ files with Android Studio. ** TLDR:** Always re-generate project files when generated files change (this includes R.java). It can be slow to build all these generated files, so if -fast is passed then the generator script skips building and extracting them. This is the reason that the _all pseudo module may contain multiple copies of generated files. The generator script builds and extracts them to extracted-srcjars/ subdirectories for each target that contains generated files. This allows imports and refactoring to be across all targets.

The editor does not respect these exclude patterns, so the _all pseudo module is added which includes directories from all targets. To accommodate this, the script detects such targets and creates exclude patterns to exclude files not in the current target. However, files in Chromium are used amongst multiple targets. Gradle supports source directories but not source files. This can be very slow when used with -all by default. This will generate one module for every gn target in the dependency graph. To see more detailed structure of gn targets, the -split-projects flag can be used. If just one apk target is explicitly specified, then a single apk module is generated.

Pass -canary or -beta to avoid the “A newer version of gradle is available” notification.

You need to re-run generate_gradle.py whenever BUILD.gn files change. If you‘re asked to use Studio’s Gradle wrapper: Yes. If you‘re asked to use Studio’s Android SDK: No. See android_test_instructions.md for more information about building and running emulators. Use “Import Project”, and select the directory containing the generated project, e.g.The above commands create a project dir gradle under your output directory. build / android / gradle / generate_gradle. Make sure you have followed android build instructions already.
