mahmud83 / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

Multi-project build with apk and apklib fails if both depend on the same native library #424

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an APKLIB project with dependency on native lib
2. Create APK project with dependency of this APKLIB as well as on the same 
native lib
3. Run "mvn clean package"

What is the expected output?
There should be no error messages because of duplicate files inside APK.

What do you see instead?
[INFO] --- android-maven-plugin:3.7.0:apk (default-apk) @ kontrolle ---
[DEBUG] Configuring mojo 
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.7.0:apk 
from plugin realm 
ClassRealm[plugin>com.jayway.maven.plugins.android.generation2:android-maven-plu
gin:3.7.0, parent: sun.misc.Launcher$AppClassLoader@cac268]
[DEBUG] Configuring mojo 
'com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.7.0:apk' 
with basic configurator -->
[DEBUG]   (f) aaptExtraArgs = []
[DEBUG]   (f) androidManifestFile = 
D:\Projekte\mtx\kontrolle\AndroidManifest.xml
[DEBUG]   (f) apkMetaIncludes = []
[DEBUG]   (f) assetsDirectory = D:\Projekte\mtx\kontrolle\assets
[DEBUG]   (f) attachJar = true
[DEBUG]   (f) attachSources = false
[DEBUG]   (f) combinedAssets = 
D:\Projekte\mtx\kontrolle\target\generated-sources\combined-assets\assets
[DEBUG]   (f) combinedRes = 
D:\Projekte\mtx\kontrolle\target\generated-sources\combined-resources\res
[DEBUG]   (f) envAndroidHome = D:\MTx_SDE_Android\sdk
[DEBUG]   (f) extractDuplicates = true
[DEBUG]   (f) extractedDependenciesAssets = 
D:\Projekte\mtx\kontrolle\target\generated-sources\extracted-dependencies\assets
[DEBUG]   (f) extractedDependenciesDirectory = 
D:\Projekte\mtx\kontrolle\target\generated-sources\extracted-dependencies
[DEBUG]   (f) extractedDependenciesJavaResources = 
D:\Projekte\mtx\kontrolle\target\generated-sources\extracted-dependencies\src\ma
in\resources
[DEBUG]   (f) extractedDependenciesJavaSources = 
D:\Projekte\mtx\kontrolle\target\generated-sources\extracted-dependencies\src\ma
in\java
[DEBUG]   (f) extractedDependenciesRes = 
D:\Projekte\mtx\kontrolle\target\generated-sources\extracted-dependencies\res
[DEBUG]   (f) generateApk = true
[DEBUG]   (f) nativeLibrariesDependenciesHardwareArchitectureDefault = armeabi
[DEBUG]   (f) nativeLibrariesDirectory = D:\Projekte\mtx\kontrolle\libs
[DEBUG]   (f) nativeLibrariesOutputDirectory = 
D:\Projekte\mtx\kontrolle\target\libs
[DEBUG]   (f) project = MavenProject: de.db.mtx.client:kontrolle:1.0.0-SNAPSHOT 
@ D:\Projekte\mtx\kontrolle\pom.xml
[DEBUG]   (f) projectRepos = [central-cache 
(http://seujava.noncd.rz.db.de/nexus/content/groups/default, releases), central 
(svn:https://swd.noncd.rz.db.de/svn/mavenpp/dist/maven2, releases), kolt 
(svn:https://swd.noncd.rz.db.de/svn/kolt/dist/maven2, releases), kermit 
(http://kermit.bku.db.de:8081/nexus/content/groups/public/, 
releases+snapshots), kermit-repository 
(http://kermit.bku.db.de:8081/nexus/content/groups/public/, releases+snapshots)]
[DEBUG]   (f) release = false
[DEBUG]   (f) repoSession = 
org.sonatype.aether.util.DefaultRepositorySystemSession@16dc5c9
[DEBUG]   (f) resourceDirectory = D:\Projekte\mtx\kontrolle\res
[DEBUG]   (f) resourceOverlayDirectory = D:\Projekte\mtx\kontrolle\res-overlay
[DEBUG]   (f) platform = 15
[DEBUG]   (f) sdk = com.jayway.maven.plugins.android.configuration.Sdk@18c9fec
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@127a49c
[DEBUG]   (f) signDebug = auto
[DEBUG]   (f) sourceDirectories = []
[DEBUG]   (f) sourceDirectory = D:\Projekte\mtx\kontrolle\src
[DEBUG]   (f) undeployBeforeDeploy = false
[DEBUG]   (f) unpackedApkLibsDirectory = 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs
[DEBUG] -- end configuration --
[INFO] Copying dependency assets files to combined assets directory.
[INFO] Copying dependency assets files to combined assets directory.
[INFO] Copying dependency assets files to combined assets directory.
[INFO] Enabling debug build for apk.
[INFO] D:\MTx_SDE_Android\sdk\build-tools\18.0.1\aapt.exe [package, -f, -M, 
D:\Projekte\mtx\kontrolle\AndroidManifest.xml, -S, 
D:\Projekte\mtx\kontrolle\res, -S, 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_kontrolle-barco
de_apklib_1.0.0-SNAPSHOT/res, -S, 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client.native_flott_ap
klib_1.0.0-SNAPSHOT/res, -S, 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client.native_fernlib_
apklib_1.0.0-SNAPSHOT/res, -S, 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_mtx-eticket_apk
lib_1.0.0-SNAPSHOT/res, -S, 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_baselib_apklib_
1.0.0-SNAPSHOT/res, --auto-add-overlay, -A, 
D:\Projekte\mtx\kontrolle\target\generated-sources\combined-assets\assets, -I, 
D:\MTx_SDE_Android\sdk\platforms\android-15\android.jar, -F, 
D:\Projekte\mtx\kontrolle\target\kontrolle-1.0.0-SNAPSHOT.ap_, --debug-mode]
[DEBUG] nothing matches overlay file ic_launcher.png, for flavor 
,,,,,,,,,,,,ldpi,,,,,,,
[DEBUG] nothing matches overlay file ic_launcher.png, for flavor 
,,,,,,,,,,,,xxhdpi,,,,,,,
[DEBUG] ANDROID-040-000: Executed command: Commandline = cmd.exe /X /C 
"D:\MTx_SDE_Android\sdk\build-tools\18.0.1\aapt.exe package -f -M 
D:\Projekte\mtx\kontrolle\AndroidManifest.xml -S D:\Projekte\mtx\kontrolle\res 
-S 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_kontrolle-barco
de_apklib_1.0.0-SNAPSHOT/res -S 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client.native_flott_ap
klib_1.0.0-SNAPSHOT/res -S 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client.native_fernlib_
apklib_1.0.0-SNAPSHOT/res -S 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_mtx-eticket_apk
lib_1.0.0-SNAPSHOT/res -S 
D:\Projekte\mtx\kontrolle\target\unpack\apklibs/de.db.mtx.client_baselib_apklib_
1.0.0-SNAPSHOT/res --auto-add-overlay -A 
D:\Projekte\mtx\kontrolle\target\generated-sources\combined-assets\assets -I 
D:\MTx_SDE_Android\sdk\platforms\android-15\android.jar -F 
D:\Projekte\mtx\kontrolle\target\kontrolle-1.0.0-SNAPSHOT.ap_ --debug-mode", 
Result = 0
[DEBUG] Including attached artifact: kontrolle-barcode(de.db.mtx.client). 
Artifact is APKLIB.
[DEBUG] Copying existing native libraries from D:\Projekte\mtx\kontrolle\libs
[DEBUG] Including attached artifact: kontrolle-barcode(de.db.mtx.client). 
Artifact is APKLIB.
[DEBUG] Copying existing native libraries from D:\Projekte\mtx\kontrolle\libs
[DEBUG] Including attached artifact: kontrolle-barcode(de.db.mtx.client). 
Artifact is APKLIB.
[DEBUG] Copying existing native libraries from D:\Projekte\mtx\kontrolle\libs
[DEBUG] Including attached artifact: kontrolle-barcode(de.db.mtx.client). 
Artifact is APKLIB.
[DEBUG] Copying existing native libraries from D:\Projekte\mtx\kontrolle\libs
[DEBUG] Building APK with internal APKBuilder
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5:06.337s
[INFO] Finished at: Thu Oct 24 07:40:01 CEST 2013
[INFO] Final Memory: 16M/60M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "corporation-properties" could not be activated 
because it does not exist.
[ERROR] Failed to execute goal 
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.7.0:apk 
(default-apk) on project kontrolle: Duplicate files at the same path inside the 
APK -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.7.0:apk 
(default-apk) on project kontrolle: Duplicate files at the same path inside the 
APK
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Duplicate files at 
the same path inside the APK
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.doAPKWithAPKBuilder(ApkMojo.java:625)
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.createApkFile(ApkMojo.java:351)
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.execute(ApkMojo.java:317)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

What version of maven-android-plugin are you using?
3.7.0

What are the complete output lines of "mvn -version" on your machine?
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 
14:51:28+0100)
Maven home: D:\Programme\apache-maven-3.0.5
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
Java home: C:\SEU\java\base-4.1\jdk1.6.0_27\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

Please provide any additional information below.
Because the native library is referenced by the APK and the APKLIB it will be 
contained in multiple "target/unpack" directories.
All of these folders are passed to the APK build which (correctly) complains 
about duplicate files.
There is already the extractDuplicates switch but it has no effect on native 
libraries. I modified the ApkMojo class in order to do duplicates filtering for 
native libs in the same way it is already done for classes. Please have a look 
at the attached patch and consider merging it.

Original issue reported on code.google.com by camueller28 on 24 Oct 2013 at 6:31

Attachments:

GoogleCodeExporter commented 9 years ago
Test against 3.8.3-SNAPSHOT

If the failure stills occurs then provide a project or link to a project that 
clearly highlights the failure.

Original comment by william....@xandar.com.au on 17 Feb 2014 at 11:16

GoogleCodeExporter commented 9 years ago
I'm also getting the same issue on my Windows system.
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 
19:21:28+0530)
Maven home: c:\maven\v305
Java version: 1.6.0_32, vendor: Sun Microsystems Inc.
Java home: c:\Program Files\Java\jdk1.6.0_32\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

Any updates on the fix ?

Original comment by vigne...@strumsoft.com on 21 Feb 2014 at 2:54

GoogleCodeExporter commented 9 years ago
@vigneshm
Android-Maven-Plugin requires Maven 3.1.1+
Are you getting this error against the 3.8.3-SNAPSHOT?

Original comment by william....@xandar.com.au on 21 Feb 2014 at 10:45

GoogleCodeExporter commented 9 years ago
@William: As mentioned above, I'm using Maven 3.0.5 and Android-Maven-Plugin 
v3.7.0

Original comment by vigne...@strumsoft.com on 22 Feb 2014 at 5:58

GoogleCodeExporter commented 9 years ago
OK .. well no one is planning on patching this back in version 3.7.0 of the 
plugin.
So if you want a fix I suggest you see if it is fixed in 3.8.3-SNAPSHOT

Original comment by william....@xandar.com.au on 22 Feb 2014 at 6:23

GoogleCodeExporter commented 9 years ago
Can you provide a project showing the failure?
That way we at least test whether it still exists?

Original comment by william....@xandar.com.au on 10 Mar 2014 at 11:57

GoogleCodeExporter commented 9 years ago
Setup:
Using 3.9.0-SNAPSHOT w/ patch for PR313+PR314, Maven 3.1.1
Modifying the project from #444 

Test 1:
apklib depends on
    <dependency>
        <groupId>com.badlogicgames.gdx</groupId>
        <artifactId>gdx-bullet-platform</artifactId>
        <version>0.9.9</version>      
        <classifier>natives-armeabi-v7a</classifier>
    </dependency>

    <dependency>
        <groupId>com.badlogicgames.gdx</groupId>
        <artifactId>gdx-bullet-platform</artifactId>
        <version>0.9.9</version>      
        <classifier>natives-armeabi</classifier>
    </dependency>
both of those put a libgdx-bullet.so at / inside the jar
If extractDuplicates=false, it will tell you that the two libgdx-bullet.so 
files conflict with each other.
If extractDuplicates=true, it compiles fine, but does not include either 
libgdx-bullet.so in the resulting apk.

Test 2:
apklib depends on these:
    <dependency>
        <groupId>com.snappydb</groupId>
        <artifactId>snappydb-native</artifactId>
        <version>0.2.0</version>
        <classifier>armeabi-v7a</classifier>
        <type>so</type>
    </dependency>

    <dependency>
        <groupId>com.snappydb</groupId>
        <artifactId>snappydb-native</artifactId>
        <version>0.2.0</version>
        <classifier>armeabi</classifier>
        <type>so</type>
    </dependency>
APK does not contain the native libs. Perhaps because of:
[DEBUG] Not extracting snappydb-native...
[DEBUG] Not extracting snappydb-native...

Test 3:
Sanity check - moved the Test 2 dependencies directly into the apk project. 
That compiled fine and included the native dependencies.

Test 4: 
Sanity check - Test 3 + Test 1 w/ <extractDuplicates>true</extractDuplicates>
Same result as #3. Snappy but not badlogic in APK.

So a couple things are obvious from this.
1. we are not currently handling jars that have native dependencies at the root
2. we are not currently handling external native dependencies of APKLIB
3. If it says there are duplicates, they are probably named the same in the 
same path

Original comment by malac...@gmail.com on 23 Mar 2014 at 5:06

GoogleCodeExporter commented 9 years ago
I have a pull request to handle #2
https://github.com/jayway/maven-android-plugin/pull/319

Still need to figure out the best way of addressing #1

Original comment by malac...@gmail.com on 28 Mar 2014 at 7:41

GoogleCodeExporter commented 9 years ago
We are no longer using the issue tracking system on Google Code. Please refile 
this issue on https://github.com/jayway/maven-android-plugin/issues if you 
still have this problem with the latest release of the Android Maven Plugin

Original comment by mosa...@gmail.com on 19 May 2014 at 4:20