Reputation: 6043
Migrating from eclipse to Android Studio. Here is AS's build dir structure
Question 1. Where does gradle put all the compiled .class
files? Is it the projectRoot/build/intermediates/classes
directory?
The purpose of this question is a Java class is generated at build time (eg: CustomBuildInfo.java
) and needs to added to the complied dir so that other src files can use it and packaged correctly within APK.
Note:Previously in Eclipse this generated file use to reside inside projectRoot/gen/<package>
directory.
Question 2. Whats the correct location for custom generated Java files? Is it build/generated/r/<buildType>/<package>
? (this is where R.java resides)
Note But this custom generated Java file CustomBuildInfo.java
belongs to common source i.e., used by all build types and all flavors
Any help will be appreciated.
Upvotes: 7
Views: 9913
Reputation: 1692
Intermediate classes can sometimes be stored at "../build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" for the debug build classes and at "../build/intermediates/javac/relese/compileReleaseJavaWithJavac/classes" for the release build classes. And sometimes they can be stored at "../build/debug" for debug classes and at "../build/release" for release build classes.
I'm not sure what causes them to be in one place or the other. If you look at the ".impl" file (which contains xml) for the module your interested in you will find an entry like this:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
or an enty like this:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
That's what determines where the intermediate classes will be stored for the module. Why it's sometimes in the 'build/intermediate/classes' directory and sometimes in the 'build/intermediate/java' directory has me baffled. I've look for various reasons such as 1.) is it affected by the manisfest, 2.) manifest merging 3.) jdk version 4.) module type (application, android library, java library), 5.) use of instance run. In all my attempts to see what causes it to choice one or the other, I've not been able to determine how that decision is made. If someone knows what factor determines the directory scheme choice , please add the reason.
If you're like me and have a reason want to get access to the intermediate java classes produced, the easiest work around is to see which directory exist. You'll have one or the other, but not both!
Upvotes: 2
Reputation: 6043
To answer my own question when using GRADLE build system
Java Byte Code location (post-compilation) <projectroot>/build/intermediates/classes/<build-type>/....
assets
<projectroot>/build/intermediates/assets/<build-type>/....
res
<projectroot>/build/intermediates/res/merged/<build-type>/....
JNI libs (configurable)
<projectroot>/build/intermediates/jniLibs/<build-type>/....
Manifests
<projectroot>/build/intermediates/manifests/full/<build-type>/....
Java class generated from AIDL
<projectroot>/build/generated/source/aidl/<build-type>/....
R.java
<projectroot>/build/generated/source/r/<build-type>/....
BuildConfig.java
<projectroot>/build/generated/source/buildConfig/<build-type>/....
Test reports HTML
<projectroot>/build/reports/tests/<build-type>/index.html
APK output files
<projectroot>/build/outputs/apk/...
Lint Results
<projectroot>/build/outputs/...
Manifest Merger Report (if using multi-module build)
<projectroot>/build/outputs/logs/...
Test Results
<projectroot>/build/test-results/...
Upvotes: 16