More Android and Maven issues in 10.0.2
We are observing some strange behavior between Maven and the Android facet. In the project structure for the Android module the assets, libs and res directory all reside in the module root directory. The Android facet looks good initially pointing to the said directories in the module's root. We define gen and src as source folders and exclude the Maven target directory. After running the Maven build from inside Intellij we observed side effects in the Project Structure of the Android module. In a nutshell:
1. target/generated-sources/combined-assets and target/generated-sources/r are added as source folders
2. a number of subdirectories under target are added as exclusions and the original exclusion of the entire target directory is gone.
Number 1 basically causes errors in Intellij about duplicate assets if we try and deploy the app to the emulator. You must manually delete both entries as source folders before deployment works. We can deploy the APK outside Intellij but because the Android facet is pointing at the <MODULE ROOT DIRECTORY>/assets and the project structure includes <MODULE ROOT DIRECTORY>/target/generated-sources/combined-assets as a source folder we get a duplicate asset error on deployment.
A second unrelated issue is Intellij on OS X does not resolve the ANDROID_HOME environment variable that points to the SDK path resulting in build errors. It works fine on Windows. I had to explictly add android.sdk.path as a property in the Maven/Runner settings on OS X.
Grant
Please sign in to leave a comment.
The following Android facet changes fixed our deployment issues for now but I'm pretty sure this is a bug.
1. Set the Assets directory to .../target/generated-sources/combined-assets/assets
2. Had to explicitly set APK path to .../target/demo-apk-1.0-SNAPSHOT.apk
After making those changes to the facet configuration the deployment worked from the IDE.
The environment variable ended up being a Mac issue. I had ANDROID_HOME set in my .bash_profile file. That didn't work. I had to add it to /etc/launchd.conf before it was visible to Intellij.
Grant
Hello, Grant.
1,2. Yes. Currently, this problem exists. It is recommended to build your maven project before importing it to IntelliJ, in this case everything should be imported properly. Please, try this.
I've submited issues about your problems. Please, vote:
http://youtrack.jetbrains.net/issue/IDEA-65689
http://youtrack.jetbrains.net/issue/IDEA-65690
http://youtrack.jetbrains.net/issue/IDEA-65691