After trying to build APK once and fixing an error, I got an error executing ./gradlew assembleRelease again: Execution failed for task ':app:mergeReleaseResources' building APK
The problem occured becaused when I tried to build once, it has created drawables dirs on android/app/src/main/res/. Then when I tried on second time, it has shown me this error Execution failed for task ':app:mergeReleaseResources' building APK
I just deleted the drawable-* dirs and it worked.
Hope it helps!
rm -rf android/app/src/main/res/drawable-*
As addition to accepted answer, if there is a "raw" folder in the same directory, also you must delete that.
I just deleted the drawable-* dirs as well raw dir from
android/app/src/main/res/ and it worked.
Exactly problem occurred when I tried to build once, it has created drawable dirs.
I was facing following issue:
Execution failed for task ':app:mergeReleaseResources'.
java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.0-5013011-windows Daemon #0: Unexpected error during compile 'E:\project\ionic\uvparentlan0.4\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
Solution: I delete all drawable directories named "drawable-port-*****"
Now Build again " ionic cordova build --release android "
BUILD SUCCESSFUL in 1m 11s
42 actionable tasks: 40 executed, 2 up-to-date
Built the following apk(s):
Sometimes it's a result of a duplicate file. Reading the error log, it seemed that I had a duplicate file name (two files with the same name). The issue resolved by removing one of the files (from a previous build if I remember it right).
I changed .png to .jpg in drawable and it worked for me.
Related
I'm using react native to develop an android app. When I run the command
./gradlew clean
I get these errors:
> Task :app:clean FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:clean'.
> java.io.IOException: Unable to delete directory '/Users/XXXXXX/APPNAME/android/app/build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
And the directories it points to are all variations on this: android/app/build/intermediates/merged_res_blame_folder/debug/out/*
Some things I've tried:
changing ownership of the files/folders
ending all java processes from Activity Monitor
ending Daemons with ./gradlew --stop
Not sure what I'm doing wrong. For what it's worth I've followed all the steps outlined in https://reactnative.dev/docs/environment-setup.
I managed to solve the issue by manually deleting the /android/app/build folder and rerunning ./gradlew clean. For some reason I could not delete it from the command line so I had to use the file explorer gui.
After trying cleaning up the build cache (doing 'rm -rf $HOME/.gradle/caches/' as suggested in How to clear gradle cache?), Gradle stopped working entirely (no task would work). All of them immediate report the following error:
* Where:
Settings file '/.../android/settings.gradle.kts' line: 1
* What went wrong:
Failed to load compiled script from classpath [/.../.gradle/caches/jars-9/.../classes.jar].
Any ideas?
I found that the whole $HOME/.gradle folder needed to be deleted, otherwise Gradle would not work, looking for a missing jar. So, the solution:
rm -rf $HOME/.gradle
At first install running a program all is normal. And then it's happened since I add a splash screen in there. I've reinstalled the application but nothing was changed. First run normal and the second run is failed again. I try to check my gradle and the file, but no one problem that found in there.
How I can fix this problem?
Execution failed for task ':app:mergeDebugResources'.
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
Failed to transform aapt2-4.1.2-6503028-windows.jar (com.android.tools.build:aapt2:4.1.2-6503028) to match attributes {artifactType=_internal-android-aapt2-binary, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for Aapt2Extractor: C:\Users\ASUS.gradle\caches\modules-2\files-2.1\com.android.tools.build\aapt2\4.1.2-6503028\6d9042942daa27a40e3ff66254cb2a82a7f0b69f\aapt2-4.1.2-6503028-windows.jar.
> Failed to create directory 'C:\Users\ASUS.gradle\caches\transforms-2\files-2.1\0acdb043263d98cb86ad08d6f4b1bd1a\aapt2-4.1.2-6503028-windows'
Cannot isolate the issue but you can try these things if the caches got scrambled or something
try clean build or invalidate caches/restart
If the above didn't work delete the build/caches folder and rerun. From what I can see you can go here C:\Users\ASUS.gradle\caches and delete the caches folder, this will most certainly resolve your issue.
If that also didn't work the ultimate resort would be nuking the caches
Close Android Studio
open terminal and go to project location (cd project location)
./gradlew clean
./gradlew --stop
rm -rf ~/.gradle/caches
./gradlew assembleDebug
Open Android Studio and gradle sync
I hope it works.
I use react-native-smart-splash-screen and install completely (do all task in docs).
and its work in the android emulator.
i install gradle-4-10-2 and in ./android folder in my project run this command $> ./gradlew assembleRelease
but get this erors:
What went wrong:
Execution failed for task ':react-native-smart-splashscreen:verifyReleaseResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
I use the react-native link but also not work
how can fix it and build .apk file
Firstly, ensure Generated Signed APK . If error still exists, try add this line in your project gradle.properties file:
android.enableAapt2=false
I cannot run any project. I created a default project with an acitivity and when i try to run it I get this error.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\androidstudio\sdk\build-tools\android-4.4W\dx.bat --dex --num-threads=4 --output C:\projects\app\build\intermediates\dex\debug C:\projects\app\build\intermediates\classes\debug C:\projects\app\build\intermediates\dependency-cache\debug
Error Code:
1
Output:
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
any dependency it tries to copy to dex/debug im guessing, but fails to do so.
Any ideas?
First of all, you should double check that the path C:\androidstudio\sdk\build-tools\android-4.4W\dx.bat does indeed exist. It could be that your SDK configuration is pointing at an invalid directory (though that's unlikely, given how far you're getting in the compilation/build process).
After that, this looks very similar to a similar error on OSX, so you might try the proposed solution there, which is to run gradlew.bat --stop using the Gradle wrapper script that should be in the root of your project and then try to compile again.