compileReleaseJavaWithJavaC failed for react native modules when building a release build - android

Task :react-native-device-info:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.
java.io.FileNotFoundException: /workspace/eos-native/node_modules/react-native-device-info/android/build/intermediates/annotation_processor_list/release/annotationProcessors.json (No such file or directory)
The error makes sense , and the file is not there, but I have no idea why its not there? It is created when I run a debug version of the app and debug versions of my libraries, react-native-device-info, react-orientation-locker etc.. I've cleaned, gradle synched, rebuilt etc. but when trying to assemble or install a release build I get this error within seconds. What is causing the Java

I had the same problem in an android project (without react) when I added a library module.
After searching for a solution for quite some time, I finally deleted the .gradle directory in the project root folder.
This solved the problem for me.

update android gradle plugin to 3.3
update gradle to 4.10.3
fixed the issue for me.

Related

unable to find project exploded aar

We have simple composite gradle build with android project and a library project. We are getting the following error from the build
> Task :kds-android-studio:lintAnalyzeDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kds-android-studio:lintAnalyzeDebug'.
> unable to find project exploded aar for /Users/dean/workspace/tray/monorepo/android/libraries/tray-lib-android-studio :
In the build file, we have this line to pull in the artifact(per composite builds)
implementation 'com.tray.android.lib:tray-lib-android-studio'
In the settings.gradle file, we have this(per composite builds)
includeBuild '../../libraries/tray-lib-android-studio'
I have no idea what an aar file is. Any direction on debugging this further would be great? (I am mostly guessing right now and google doesn't seem to have any results on lintAnalyzeDebug and "unable to find project exploded aar".
I see an aar file fro debug and release in the tray-lib-android-studio project. Where is the main gradle project searching for 'exploded aar' and I wonder if I can just hack a target before the one that fails to explode the library aar in a good location to get this passing?

flutter More than one file was found with OS independent path 'AndroidManifest.xml'

I have a sample flutter project that has multiple lib modules that can build with
./gradlew app:assembleDevRelease
but for some reason when I run
flutter run --release --flavor dev
It is trying to run
./gradlew assembleDevRelease
command that of project level, then I got the error
> Task :track_sdk_plugin:mergeDevReleaseJavaResource FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':track_sdk_plugin:mergeDevReleaseJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'AndroidManifest.xml'
Any idea why this is not working? Can provide the gradle file if needed.
In my case, there were more than two AndroidManifest.xml files in one of the modules due to migrating from the old project.
Please search for the AndroidManifest.xml files under your project directory, if you could find there were more than one in src folder, only keep the one in src/main folder.
I had a similar case with the following error message:
More than one file was found with OS independent path 'lib/x86/libswscale.so'.
The problem was that I accidentally had both the following dependencies in my pubspec.yaml:
ffmpeg_kit_flutter_min_gpl: ^4.5.0
ffmpeg_kit_flutter: ^4.5.0-LTS
The top one of course has everything that the below one has and that caused the issue. The below one was unnecessary.

Gradle plugin 3.5.0: "Failed to transform artifact", "Execution failed for JetifyTransform"

We updated Android Gradle plugin from 3.4.2 to 3.5.0 (and Gradle from 5.1.1 to 5.4.1).
After that, the build started failing in a few submodules. Trying to assemble any build variant yields this (same error on the command line and in Android Studio):
> Failed to transform artifact 'bottom-navigation.aar (project :bottom-navigation)' to match attributes {artifactType=jar}.
> Execution failed for JetifyTransform: <project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar.
> Failed to transform '<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar' using Jetifier.
Reason: Cannot open a library at 'FileMapping(from=<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar, to=<project_root>/bottom-navigation/build/.transforms/9b2af95a5f0e0055110660c22ff05ab5/jetified-bottom-navigation-release.aar)'. (Run with --stacktrace for more details.)
Any ideas how to fix this?
What I've tried
"Invalidate caches" in AS and also clearing all Gradle caches in ~/.gradle/caches as suggested in this answer
All the advice in this somewhat similar question
I checked that the problematic modules use apply plugin:
'com.android.library' (instead of com.android.application)
I tried updating appcompat dependency to androidx.appcompat:appcompat:1.1.0 in affected modules and also removing that dependency
Update
It starts to look like something is wrong in Gradle plugin 3.5.0; builds behave erratically for me locally and on our CI machine.
For example, clean builds are failing: ./gradlew clean assembleBetaRelease fails while ./gradlew assembleBetaRelease works!
Also, sometimes I get AAPT: error: attribute ... not found instead of the above Failed to transform artifact error.
Reverting to Gradle plugin 3.4.2, all these problems disappear.
Edit Oct 2019: Still seeing this weird behaviour with Gradle plugin 3.5.1. Edit Nov 2019 And 3.5.2. Upgrading to Gradle 5.6 didn't help either.
A bit weird, but I got it working again. Apparently just a temporary glitch in Android Gradle plugin related to caching.
This answer helped me:
The simple way to solve this is to switch between your build variants. This refreshes the cached copies and resolves the issue.
I couldn't do that in Android Studio since the project sync was failing, but on the command line I tried another variant (in my case ./gradlew assembleBetaDebug having used ./gradlew assembleBetaRelease earlier). The build passed, and after that it worked for all all other variants too, and Gradle sync in Android Studio started working as well!
Edit: actually this is not completely solved; see updated question.
Update 12/2019: bundle* commands work fine, it's only assemble* that fails—still failing with Android Gradle plugin 3.5.3. Building in Android Studio works fine. Obviously this is not a common issue, and I don't know what exactly in the particular project I'm working on is causing this.
Update 04/2020: now with Android Gradle plugin 3.6.2 (and Gradle 5.6.4) builds work for me locally and I was able to update the project. On CircleCI, the build still occasionally fails with "Failed to transform artifact" but re-running fixes it. Go figure 🤔

"Could not initialize class" error running lint target from gradle

I'm working on an Android project with two projects inside it. When trying to run a build with gradlew (./gradlew build), I see the following error:
Execution failed for task ':example:lint'.
Could not initialize class
com.android.build.gradle.tasks.Lint$LintGradleIssueRegistry
With stacktrace enabled, this is listed as a java.lang.NoClassDefFoundError.
Oddly, the first time I ran this (which downloaded dependencies), the build failed with a different error:
Execution failed for task ':example:lint'.
lombok/ast/Node
The gradle wrapper that Android SDK created for the project is using Gradle 2.8.
Could this be a configuration issue with the project or my dev machine? I'm trying to avoid using the Android SDK lint tool as this complains about the projects using Gradle (and I hear it may miss some parts of these projects).
Turned out this was a configuration issue in our build.gradle. The following line had been added for testing and never removed:
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
As such, the classes needed for linting were missing.
The following discussion pointed us in the right direction, in case it's useful to anyone else:
https://github.com/evant/gradle-retrolambda/issues/96

Execution failed for task ':app:mockableAndroidJar'

I am using local gradle of version 2.4 and IntelliJ IDEA 14.1.3
When I run project from IntelliJ it runs fine but when execute gradle clean build command from command line it gives the flowing exception and build fails.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mockableAndroidJar'.
> java.util.zip.ZipException: invalid entry compressed size (expected 2051 but got 2050 bytes)
This looks like an old ques which is not yet answered yet.
I got into same problem, when my jar files could not be read by Android Studio and it gave me the above mentioned error.
Taking lead from the comment by -Mikhail Boyarsky I changed classpath in build.gradle file to 'com.android.tools.build:gradle:2.2.3'.
Synced project and it started working.
I solved it by changing com.android.tools.build:gradle:2.3.0 version to 2.2.3, then build it with another exception and then I changed the version back to 2.3.0.
Not sure how it works, looks like a gradle bug.

Categories

Resources