Error Building APK build Error> Task :app:packageRelease FAILED - gradle

I am trying to generate android APK build, and I am getting different errors every time, from different libraries
for example here it says > Task :react-native-fast-image:mergeReleaseResources FAILED
after that I didn't do anything I just re-run ./gradlew clean && ./gradlew assembleRelease and it shows me different error
and I am in the loop since yesterday, any clue what's the problem or maybe solution?

This can be fixed by configuring the max heap size for your project.
Add this to your android/gradle.properties
org.gradle.jvmargs=-Xmx2560m
For more options prefer this.

Related

Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService()

I am new in gradle and when I try to simple check gradle built in tasks, I get Build Failed error.
Can anybody explain what is wrong?
I only run 'gradle tasks' on cmd and get next error:
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService().
> Timeout waiting to lock checksums cache (M:\.gradle\checksums). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 14372
Owner Operation: unknown
Our operation:
Lock file: M:\.gradle\checksums\checksums.lock
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with
--scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 1s
./gradlew --stop as the error happens when gradle didn't close cleanly. Such as in: Cannot lock checksums cache (/Users/.../StudioProjects/android/.gradle/7.4.2/checksums) as it has already been locked by this process.
This was a permissions issue for me.
I tried running a project on my Mac from my mounted Google Drive directory and got this error.
Moving the project to Documents worked.
FWIW, I forgot to stop the server in IntelliJ and once I did the problem went away.
For Flutter users
I faced this problem on Mac OS Monterey (M1 processor)
I solved it in the following way
Browse android/buil.gradle add or update gradle version to 7.1.2
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'. //---this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Update distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to 7.4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
Navigate in the terminal to the android folder and run
cd android
despues
./gradlew --stop
4.Run flutter clean and flutter pub get
flutter clean
flutter pub get
Then run flutter run
flutter run
This work for me:
Close my IDE
Go to my project directory
Search and delete all .lock files
Open the IDE, and try again
Just restart your machine. it's a cache related error

Error when build react native for task ':app:prepareComAndroidSupportSupportV42301Library'

I'm new react-native developer. When i run react native in windows with "react-native run-android", it return error :
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportSupportV42301Library FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:prepareComAndroidSupportSupportV42301Library'.
Could not expand ZIP 'C:\Android\sdk\extras\android\m2repository\com\android\support\support-v4\23.0.1\support-v4-23.0.1.aar'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15 mins 33.768 secs
Can you help me fix this problem? thank!
I had the exact same issue and it turns out it's got to do with the google play-services-analytics version.
and by adding the following code to the build.gradle file I was able to get rid of the error.
compile("com.google.android.gms:play-services-analytics:8.3.0"){
force = true
}
add it at the top of the dependencies curly braces.
so that it looks like this.
dependencies { compile("com.google.android.gms:play-services- analytics:8.3.0"){
force = true
}
//the rest of the dependencies follow
Go t the page below for a better and more detailed explanation
https://github.com/idehub/react-native-google-analytics-bridge/issues/31

TeamCity Android Proguard results in "Your input classes appear to be inconsistent."

When I build my Android project from the command line with
gradlew assembleRelease
It works, but when I run it from my teamcity build agent the build gives a lot of warnings and fails witht he following errors:
[11:40:43][Step 4/10] Warning: there were 75 unresolved references to program class members.
[11:40:43][Step 4/10] Your input classes appear to be inconsistent.
[11:40:43][Step 4/10] You may need to recompile the code.
[11:40:43][Step 4/10] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
[11:40:43][Step 4/10] :proguardRelease FAILED
I've tried modifying my build config to run gradlew from command line instead of using the gradle build runner but it is still broken. There is obviously something different between running the command from TeamCity versus running it manually through command line, but I don't know what that could be. Where to look?
Your problem and solution are right what it says on the tin:
Your input classes appear to be inconsistent.
You may need to recompile the code.
Given you're using Gradle, it's possible one version of gradle doesn't match the other or doesn't behave the same. This is particularly true if e.g. you've upgraded gradle from an older version.
Fix is simple: gradle clean or gradlew clean then try again.

Android studio build error

Tried to create my first project in android studio, using one of the examples im trying to run the application, but gradle gives me this build error (didnt change one line of code - just trying to run the Empty activity):
Gradle: FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':Passivelocation:packageDebug'.
org.bouncycastle.asn1.ASN1Integer.(J)V
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Ive tried adding info and debug while running the command on with the cli but i cant make much of the output it gives me.
Any suggestions?
I faced the same failure and the problem was with my jdk/jre because some time ago I added the Bouncy Castle Crypto APIs functionality by adding the jar to my jdk/jre path.
I tried a gradle build with a "clean" jdk/jre and problem was solved

AndroidStudio Unambiguous Errors

I've been using AndroidStudio and it has a few inconsistencies but it's very good already.
I've been compiling and running my app fine and then suddenly (after doing something innocuous) it's throwing up the below error but i cannot find out the issue. Does anyone have any ideas how to find out the errors?
Compilation completed with 2 errors and 0 warnings in 46 sec
2 errors
0 warnings
Gradle:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':Candle:compileDebug'.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
If nothing has really changed in your project settings, then I'd check the log (Help | Show log in Files/Explorer/Finder) for clues. Most likely, the Gradle daemon died, and a rebuild should fix it.
If that doesn't help, then your only option to find more info is to do a command line build. Go to the root of your project, and do:
./gradlew assemble
The best way I've found to get to the errors is to run gradle compile and/or package from the command line. In the root of your project run:
gradlew compileDebug
AND / OR
gradlew packageDebug
This will give you command line output for your errors
It also sometimes helps to run a gradle clean before running builds:
gradle clean
Hope this helps

Resources