Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution failed for task ':alibrary:generateRJava' #61

Open
zuoyun opened this issue Mar 14, 2017 · 9 comments
Open

Execution failed for task ':alibrary:generateRJava' #61

zuoyun opened this issue Mar 14, 2017 · 9 comments

Comments

@zuoyun
Copy link

zuoyun commented Mar 14, 2017

i follow your tips,embedded in library and compile the library in app

image in library

image in app

gradle show this:

Error:FAILURE: Build failed with an exception.

  • Where:
    Script 'H:\android_project\BaseRecyclerViewAdapterHelper-master\alibrary\fat-aar.gradle' line: 218

  • What went wrong:
    Execution failed for task ':alibrary:generateRJava'.

H:\android_project\BaseRecyclerViewAdapterHelper-master\alibrary\build\intermediates\exploded-aar\BaseRecyclerViewAdapterHelper-master\blibrary\unspecified\AndroidManifest.xml (系统找不到指定的路径。)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
@JohnSFR
Copy link

JohnSFR commented Mar 14, 2017

I just ran into the same problem.
I got as far as working out that the string 'unspecified' in your error tty comes from - in blibrary's build file - not having an entry for project.version, so I added project.version = android.defaultConfig.versionName in that library's defaultConfig.
Adding that changes
...ploded-aar\trunk<blibrary>\unspecified\AndroidManifest.xml (The system cannot find the path specified)
to
...ploded-aar\trunk<blibrary>\1.0\AndroidManifest.xml (The system cannot find the path specified)

Update: I'm not sure that exploded-aar folder is ever created, maybe it's moved or something's changed? (Studio version 2.3, Gradle 3.3)

@roremeol
Copy link

roremeol commented Mar 14, 2017

I think that I found a solution for this issue.

I figure out the new default configuration for Android Studio 2.3: (android.enableBuildCache=true). When a change it to false in gradle.properties it stops in line 356:

Error:Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.

java.io.FileNotFoundException: /Users/romulo/Desenvolvimento/develLibs/qLibAds_and/qLibAdsProject/qLibAds/build/intermediates/bundles/release/AndroidManifest.orig.xml (No such file or directory)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Fix
I fix it! Please see issue #62

@JohnSFR
Copy link

JohnSFR commented Mar 16, 2017

Well I'm getting closer.

Setting android.enableBuildCache=false in gradle.properties does make the exploded-aar folder appear.
However, the build process didn't explode the sub-library's aar in question into there. So to progress matters, I manually unzipped the aar into exploded-aar/

I then had to change the path in embedJavaJars() from "$aarPath/jars/classes.jar" to "$aarPath/classes.jar", and skip the call to embedManifests() - as that was crashing, and I don't need to merge the manifests in this case.

With that (still with the manual unzip which I'll have to fix later), it looks like I now have a merged aar file. (Though I still have problems building my app with it....)

@JohnSFR
Copy link

JohnSFR commented Mar 16, 2017

Update:

R$... classes from the sub-library were missing from the output aar.
They are in \build\fat-aar\ as well as in a .jar file in build\intermediates\bundles\release\libs

After manually copying them from build\intermediates\bundles\release\libs<sub-library>.jar into classes.jar within the output aar, I am now able to compile the aar into a separate apk project.

So I now just need to figure out how to replace the two manual steps, i.e.

  • unzip the contents of the sub-library's aar file into build\intermediates\exploded-aar\
  • manually copy contents of build\intermediates\bundles\release\libs<sub-library>.jar into classes.jar in the output aar
  • (I'm not worried that I disabled manifest merging)

@roremeol
Copy link

roremeol commented Mar 16, 2017

It could help you:

#copy file sample
task copyHeaders {
    copy {
        from("${srcLibs}")
        into "../../Classes"
    }
    dependsOn ':app:preBuild'
}
#unzip file sample
task unzip {
    copy {
        def zipFile = file("${binLibs}/lib.aar")
        def outputDir = file("../../libs")

        from zipTree(zipFile)
        into outputDir
    }
    dependsOn ':app:preBuild'
}

@roremeol
Copy link

it seems that it does not work with maven dependencies. @JohnSFR

@roremeol
Copy link

roremeol commented Mar 16, 2017

Update:

I think that this issue is related to #62 .

I do not know why. When "Flavors" is in debug in Android Studio, gradle makes other intermediates build folder ({libary dir}/build/intermediates/bundles/debug) and it seems to use it.

When i change the "Flavors" to release, it uses the correct one ({libary dir}/build/intermediates/bundles/default). And now the fat-aar works.

I figure out this curious issue on Androis's project

@vigidroid
Copy link

vigidroid commented Mar 17, 2017

After android gradle plugin 2.3.0 was released, something about file path has been changed.
That results in the hard-code build script working wrong.

AFAIK, there are 2 points below:

  1. build/intermediates/bundles/debug is changed to build/intermediates/bundles/default in some case.
  2. exploded-aar is moved to build-cache for performance improvement. To restore this, we can disable build-cache.

I have created a new repo to try to support all these.
Even so disable build-cache is also needed. Or you should use the version prior to 2.2.3.

If the build script is really puzzle you, you can try mine.

@zuoyun @JohnSFR @roremeol

@lgengsy
Copy link

lgengsy commented Aug 2, 2017

I have the same question as you 。finally I change gradle to 2.3.1 to 2.2.3 solve it
classpath 'com.android.tools.build:gradle:2.2.3'
I found this way can solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants