After updating the android studio, gradle version and Cordova (incl. platforms) for hybrid project in windows 10 recently, i got this error in Jenkins.
:app:mergeDebugResourcesC:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.4.0.aar\76d6a769daf730ed767830374ebcd3bd\res\drawable\abc_btn_colored_material.xml: error: file not found.
...
...
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I searched for a solution for this which should be dynamical and can be managed through Jenkins itself since it is not possible to edit individual platform files.
Originally the error was
Execution failed for task ':mergeDebugResources'.
> Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file
which was caused by
Error: File path too long on windows, keep below 240 characters
Workaround for this was to change workspace folder so it is coming to a top level. (eg: C:/Users/[youruser]/yourfolder. Check the link here
Note
I added this question and the answer, for the self reference in future and to assist someone who is working with Jenkins.
The answer is a simple tweak. Go to
Manage Jenkins --> Configure System --> Global Properties
add an Environment variable
name = GRADLE_USER_HOME
value = C:\Users\[youruser]\devGradle
create a folder "devGradle" (or give it any name) if it is not created already.
The Gradle build script will look for this environment variable and then use the specified directory as the Gradle home directory and will build the project
Related
I have created app icons with a website called appicon. It provided icon files for both android(mipmap files) and ios devices(an Assets.xcassets file), which I added to their respective locations being (C:\Users\user\StudioProjects\i_am_rich(name of app)\android\app\src\main\res) for android and (C:\Users\user\StudioProjects\i_am_rich\ios\Runner) for ios.
When I run the program the following error is displayed:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\user\StudioProjects\i_am_rich\build\app\intermediates\packaged_manifests\debug\AndroidManifest.xml:16: AAPT: error: resource mipmap/ic_launcher (aka com.example.i_am_rich:mipmap/ic_launcher) not found.
* 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 36s
Exception: Gradle task assembleDebug failed with exit code 1
I am learning Android Studio as the IDE with flutter, as a beginner, so I don't understand the problem nor what I have to do to fix it.
Help and, possibly, an explanation would be greatly appreciated :)
The website you mentioned does generate correct names and correct order of directories it seems. so most probably this is an issue with where you have put your files or the name of the files.
The 5 directories of icons must be copied to android\app\src\main\res folder.
and make sure in each directory you have a file called ic_launcher
if all is correct, please run flutter clean command and try again.
also by anychance the webisite generating incorrect files, try using this web site AndroidAssetStudio
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{}],"original":"ERROR:: AAPT: D:\android-basics-kotlin-cupcake-app-starter\app\build\intermediates\processed_res\debug\out\resources-debug.ap_: error: The system cannot find the file specified. (2).\nerror: failed to create archive.\n\n ","tool":"AAPT"}
Task :app:mergeDebugNativeLibs
Task :app:mergeExtDexDebug
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
ERROR:: AAPT: D:\android-basics-kotlin-cupcake-app-starter\app\build\intermediates\processed_res\debug\out\resources-debug.ap_: error: The system cannot find the file specified. (2).
error: failed to create archive.
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
27 actionable tasks: 26 executed, 1 up-to-date
Can anyone help me to solve this problem...? please...
This is what happens when aapt fails to create an archive.
First make sure you are using the latest IDE and SDK. aapt for packaging is obsolete, and the earlier aapt2 has many bugs.
If they are up to date, try to check if the following processes on your computer have read/write access to the project directory.
[your android sdk path]\build-tools[your sdk version]\aapt.exe
[your android sdk path]\build-tools[your sdk version]\aapt2.exe
[your android studio path]\bin\studio64.exe
[your android studio path]\bin\fsnotifier64.exe
[your android studio path]\jre\bin\java.exe
[your android studio path]\jre\bin\javaw.exe
If you haven't set permissions manually, they are usually blocked by security software.
I recently ran into this problem and spent a lot of time finally found out that the security software on my workstation was not adding aapt2 and aapt to the allowed list for the project repository.
I would like to run espresso tests on jenkins. I did configuration like here
https://www.perfectomobile.com/solutions/devtunnel/espresso-in-continuous-integration
I got error like below
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-
1.1\design-26.1.0.aar\a1a21cd8aba52bd546711d26a970dfcb\res\drawable-
v21\avd_hide_password.xml: error: file not found.
Error: java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
10 actionable tasks: 9 executed, 1 up-to-date
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
Any sugestions what can be wrong?
This is happening because AAPT2 still has issues with long paths on windows (only supports paths up to 145 characters or so for now, sadly). This file path is around 170, so it's over that limit.
The issue should be fixed soon, in the meantime you can move your cache directory closer to the C: root.
I faced the same issue. The solution proposed here helped.
Simply add enviornmental variable GRADLE_USER_HOME
env GRADLE_USER_HOME= ${WORKSPACE}/gh
Note: Make sure gh is close to the main drive location
Been trying to debug this issue for hours! Tried many solutions online, none seems to be working.
Build properties not found for package Android SDK Platform 25
File /root/.android/repositories.cfg could not be loaded.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
>
Failed to find target with hash string 'android-25' in: /home/hisham/Android/Sdk
* 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: 39.749 secs
Error: /home/hisham/Desktop/Dev-PGDoc/ionic_app/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to find target with hash string 'android-25' in: /home/hisham/Android/Sdk
How do I fix this?
Finally got it fixed! Not sure which one of the following fixed it though.
Change $ANDROID_HOME inside ~/.bashrc from ANDROID_HOME=$HOME/Android/Sdk to ANDROID_HOME=$HOME/Android/Sdk/platform-tools
Deleted version 25's folder inside platform-tools folder in the Sdk and installed version 25 again.
After doing the two above, restarted the system and I am now able to compile and build ionic app to .apk files.
PS : This might be just only in my personal computer, and you might be facing the same issue due to different issue. Hope this helps.
I’m getting error when I'm trying to run on Android Device! I have no idea what is happening!
What can I do to solve it?
FAILURE: Build failed with an exception.
BUILD FAILED
Total time: 7.791 secs
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:373: AAPT: Attribute "theme" already defined with incompatible format.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:359: AAPT: Original attribute defined here.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values-v26\values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:373: error: Attribute "theme" already defined with incompatible format.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:359: Original attribute defined here.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values-v26\values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[ERROR] An error occurred while running cordova run android (exit code 1).
Solved
Solved: Re-create the project and add the features again!
just put this code inside build.gradle on the last part
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
If you update the v4 v7 version to 26.0.0,
you also should change the CompileSdkVersion and BuildToolsVersion
to 26.0.0
Strange cause of this error for me was that I was missing a drawable from a layout. I copied the layout from another project and forgot to copy the drawable before running my project.
Also, check that the activity names in your layouts do not have spaces.
this problem comes from the mismatch project environment and executing platform environment.
try to create a new project and run in the same platform environment.
if its run, copy-paste old project src files.
$ ionic start
$ cd "project_name"
$ ionic cordova platform add android
$ ionic cordova run android
copy-paste old project src files