Hello.
On the advice of Manfred Moser, I'm writing this small PSA in case
anyone runs into the same problem with Intellij that I've had to work
around.
Intellij doesn't seem to be able to cope well with AAR dependencies
when those dependencies are part of the same overall project. The
symptom is a lot of spurious "duplicate class" errors concerning R.java
and BuildConfig.java.
I haven't tracked down the specific cause of the issue. Searches online
led me here:
http://stackoverflow.com/questions/19192699/intellij-idea-12-duplicate-class-r-java-and-buildconfig-java
The suggested fix was to reconfigure the various directories marked as
sources, generated sources, excluded, etc. Unfortunately, those are all
configured correctly.
Currently the safe workaround seems to be to disable Intellij's
internal build logic and instead let Maven do it all. This has the
obvious advantage that if your Maven build is stable (and why wouldn't
it be!) then all developers are building the program exactly the same
way, regardless of whether that build is triggered in an IDE or from
the command line.
In practical terms:
1. Open the "Run" configuration for your application.
2. Select "Do not deploy anything" under the "Package" section.
3. In the "General" tab, remove the existing "Make" command
from the "Before Launch" list at the bottom.
4. Add a "Run Maven goal" command with whatever parameters
you'd normally use to build the app. I recommend adding
parameters such as -Dmaven.javadoc.skip=true to reduce
the build time during everyday development.
5. Add another "Run Maven goal" command to call android:deploy-apk
and deploy the resulting apk to your device.
When running the application from the IDE, maven will build and deploy
the apk. No more duplicate class errors!
M