Repository navigation
Description
Hello, i'm experiencing the following issue compiling my project using the latest android-maven-plugin 4.2.1. However it happens when com.google.android.gms:play-services:7.5.0 is a transitive dependency, not a direct one.
My relevant dependency chain is as follows:
com.google.android.gms:play-services:7.5.0 (aar) <- myGroupId:coreProject (aar) <- myGroupId:appProject
coreProject depends on play-services, while appProject depends on coreProject. However coreProject builds fine while appProject fails with this error:
[INFO] --- android-maven-plugin:4.2.1:generate-sources (default-generate-sources) @ appProject ---
[INFO] Manifest copied from appProject/AndroidManifest.xml to appProject/target/AndroidManifest.xml
[INFO] Extracting libs
[INFO] Extracting aar play-services...
[INFO] Extracting aar play-services-ads...
[INFO] Extracting aar play-services-analytics...
[INFO] Extracting aar play-services-appindexing...
[INFO] Extracting aar play-services-appinvite...
[INFO] Extracting aar play-services-appstate...
[INFO] Extracting aar play-services-base...
[INFO] Extracting aar support-v4...
[INFO] Extracting aar play-services-cast...
[INFO] Extracting aar mediarouter-v7...
[INFO] Extracting aar appcompat-v7...
[INFO] Extracting aar play-services-drive...
[INFO] Extracting aar play-services-fitness...
[INFO] Extracting aar play-services-games...
[INFO] Extracting aar play-services-gcm...
[INFO] Extracting aar play-services-identity...
[INFO] Extracting aar play-services-location...
[INFO] Extracting aar play-services-maps...
[INFO] Extracting aar play-services-nearby...
[INFO] Extracting aar play-services-panorama...
[INFO] Extracting aar play-services-plus...
[INFO] Extracting aar play-services-safetynet...
[INFO] Extracting aar play-services-wallet...
[INFO] Extracting aar play-services-wearable...
[INFO] Extracting aar coreProject...
[INFO] Generating R file for myGroupId:appProject:apk:3.0.0-SNAPSHOT
[INFO] (skipping file '.gitattributes' due to ANDROID_AAPT_IGNORE pattern '.*')
[INFO] Generating R file for aar : com.google.android.gms.wearable
[INFO] Generating R file for aar : com.google.android.gms.plus
[INFO] Generating R file for aar : com.google.android.gms.location
[INFO] Generating R file for aar : myGroupId
[INFO] Generating R file for aar : com.google.android.gms.games
[INFO] Generating R file for aar : com.google.android.gms.analytics
[INFO] Generating R file for aar : com.google.android.gms.cast
[INFO] Generating R file for aar : com.google.android.gms.wallet
[INFO] Generating R file for aar : com.google.android.gms.appstate
[INFO] Generating R file for aar : com.google.android.gms.safetynet
[INFO] Generating R file for aar : com.google.android.gms.drive
[INFO] Generating R file for aar : com.google.android.gms.appindexing
[INFO] Generating R file for aar : com.google.android.gms.panorama
[INFO] Generating R file for aar : com.google.android.gms.all
[INFO] Generating R file for aar : com.google.android.gms.ads
[INFO] Generating R file for aar : com.google.android.gms.appinvite
[INFO] Generating R file for aar : com.google.android.gms.fitness
[INFO] Generating R file for aar : com.google.android.gms.identity
[INFO] Generating R file for aar : com.google.android.gms.gcm
[INFO] Generating R file for aar : com.google.android.gms.maps
[INFO] Generating R file for aar : com.google.android.gms
[INFO] Generating R file for aar : android.support.v7.mediarouter
[INFO] Generating R file for aar : com.google.android.gms.nearby
[INFO] Generating R file for aar : android.support.v7.appcompat
[INFO] Adding R gen folder to compile classpath: appProject/target/generated-sources/r
[ERROR] Error generating BuildConfig
java.io.FileNotFoundException: appProject/target/unpacked-libs/cgag_play-services_7.5.0/classes.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:154)
at java.util.jar.JarFile.<init>(JarFile.java:118)
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.isBuildConfigPresent(GenerateSourcesMojo.java:1198)
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.skipBuildConfigGeneration(GenerateSourcesMojo.java:1156)
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateBuildConfig(GenerateSourcesMojo.java:1137)
at com.simpligility.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:329)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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)
As the error message suggests, i've verified that no classes.jar is found on appProject/target/unpacked-libs/cgag_play-services_7.5.0/ folder.
I saw that similar issues were addressed on #618 and #626 (when .aar doesn't contain a classes.jar file), however both are closed. By the way, i use this project layout since a year ago. Problems arised when i tried to include play-services:7.5.0 to my core project (which in turn forced me to upgrade from android-maven-plugin 3.9.0-rc.3 to 4.2.1).
Activity
william-ferguson-au commentedon Jun 10, 2015
Hmm looks like an edge case that hasn't been well covered yet.
Can you create a cut down pair of projects that I can spin up and test across.
dessalines commentedon Sep 24, 2015
I too have trouble getting
com.google.android.gms:play-services-cast:7.8.0converted to a maven dependency. I downloaded it in the android SDK manager, and have successfully added others such as the support aars, but can't get play-services or play-services-cast to work.dessalines commentedon Sep 24, 2015
Nevermind I just figured this out. I had to add a second repository:
takarabt commentedon Nov 6, 2015
Hello
We have the same problem and we added a local repository as above but still didn't work.
Any idea?
paolo-rendano commentedon Jan 5, 2016
I've the same problem (in a multimodule maven project), but I discovered that if you don't make a "mvn clean package", but only a "mvn package", it works. Looking at the extended log (-X) it seems that the plugin deleted the unpacked-libs after the modules that use it.
william-ferguson-au commentedon Jan 5, 2016
Can you post a cut down project on Github that clearly shows the failure?
Yrlec commentedon Jun 27, 2016
We have the same issue. Judging from the logs it looks it the error occurs in isBuildConfigPresent. It should be fairly easy to fix it. One just needs to catch FileNotFoundExceptions and return false. Something like this:
private boolean isBuildConfigPresent(Artifact artifact, String packageName) throws MojoExecutionException { try { JarFile jar = new JarFile(getUnpackedAarClassesJar(artifact));JarEntry entry = jar.getJarEntry(packageName.replace('.', '/') + "/BuildConfig.class");
Yrlec commentedon Jun 27, 2016
Sorry about the bad formatting. Markdown didn't like my code snippet for some strange reason.
mosabua commentedon Jun 27, 2016
Can you send this as a PR instead so you end up in the changelog?
mosabua commentedon Jul 15, 2016
Is this fixed with the 4.4.3 release I just cut?
meletis commentedon May 20, 2017
No, the problem still persists with 4.4.3.
mosabua commentedon May 3, 2019
Closing old issues as part of cleanup effort. Feel free to re-open and submit a PR with fix.
meletis commentedon May 8, 2019
The problem still persists with 4.5.0 but we use the following workaround:
It is just that one command with both goals together can't run:
...but the workaround of two commands is not that bad.
mosabua commentedon May 9, 2019
Hm .. that shoud work .. but I cant reproduce. Maybe you can try the above suggested patch (not sure where exactly to apply that) and test it and then send a PR with the fix.