Reputation: 221
I have an Android project with a dependency to a apklib project. In the apklib project a R.java file will be generated and packed into the result apklib file. The Android project unzip it via android plugin and rebuild all code. In consequence of this there are a doublicate R file compilation error cause the plugin try to rebuild the R file of the apklib project resources in the Android project.
What is the problem? Here my snippets from the pom files:
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...<packaging>apk</packaging><build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.0</version>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<genDirectory>${project.basedir}/gen</genDirectory>
<sdk>
<platform>15</platform>
<path>${android.sdk.path}</path>
</sdk>
<undeployBeforeDeploy>false</undeployBeforeDeploy>
<emulator>MyAndroid</emulator>
<device>usb</device>
<dexOptimize>true</dexOptimize>
<mergeManifests>true</mergeManifests>
</configuration>
</plugin>
...
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>4.0.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r12</version>
</dependency>
...
<dependency>
<groupId>my.group.id</groupId>
<artifactId>artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
</dependencies>
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><packaging>apklib</packaging>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.0</version>
<extensions>true</extensions>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<genDirectory>${project.basedir}/gen</genDirectory>
<sdk>
<platform>15</platform>
<path>${android.sdk.path}</path>
</sdk>
</configuration>
</plugin>
...
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>4.0.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r12</version>
</dependency>
...
</dependencies>
The problem is that the in the apklib generated R.java file is copied into the gen folder of the Android project by the aapt tool (V. 19). I work with Windows platform, maven 3.1.1 and the android maven plugin 3.8.0 on both projects.
Upvotes: 1
Views: 96