Android Studio 3.0 migration AAPT2 error - android

After migrating my existing project to Android Studio 3.0, it is not compiling. Below are the log details:
Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
Information:BUILD FAILED in 27s
Information:11 errors
Information:0 warnings

Go to your gradle.properties write the below code and Sync your project
android.enableAapt2=false

Is your username in OS cyrillic? If so - you need to change the .gradle resource folder in settings to path which does not contain cyrillic symbols.
In ->Settings-> Build, Execution -> Gradle change Service directory path to "C:/Users/Public/.gradle"

this problem occur when there is something wrong in your XMl file
1:- remove all unnecessary XML files from your code
2:- Reopen and Check XML files
If there is Still Problem
Go to your gradle.properties write the below code
android.enableAapt2=false
and then Go to your build.gradle(app) write the below code and Sync your project
aaptOptions {
cruncherEnabled = false
}
Note android.enableAapt2=false is deprecated, and will be removed by the end of 2018, so this doesn't solve the problem, is just a temporary workaround

Related

Error Execution failed for task ':app:mergeReleaseResources' building APK

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.

Cordova build android:':app:mergeDebugResources'. failing in Jenkins

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

Gradle Build Errors in Android Studio

It's my first time using Android Studio, or developing an Android app in general, so I'm sorry if it's an obvious error.
When I try to build my app I get errors, as seen below.
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :app:compileDebugSources]
H:\Stage_3\CEG3799_Individual_Research_Project\App\CEG3799\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(36) error: unknown element <activity> found.
Error:(36) unknown element <activity> found.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
Failed to execute aapt
> Information:BUILD FAILED in 4s
> Information:6 errors
> Information:0 warnings
> Information:See complete output in console
The debug file it is referring to is https://pastebin.com/Yyc1wGDL. The main AndroidManifest.xml file is https://pastebin.com/kj978xd4. If I try and move my <activity> to inside my <application>, I get the following error instead.
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
This is the console / logs that I can find https://pastebin.com/pT1m0GLZ.
The build.gradle is at https://pastebin.com/6r5ys8Fi
Can anyone help advise me how to get this working? Thank you in advance
When you move <activity> inside <application> you'll have two <activity> tags with the same android:name="uk.ac.ncl.b5027438.CEG3799.MainActivity". delete one of these tags
Move the
<activity
android:name="uk.ac.ncl.b5027438.CEG3799.MainActivity"
android:configChanges="screenSize|orientation" />
inside the <application> node

android studio 3.0 | AAPT2 Error: failed to execute apt

when building an app with some videos (mp4) inside raw/ directory i get this error:
raw_frenulectomia.mp4.flat: error: failed to read data meta data.
error: failed parsing overlays.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
Caused by: java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
with previous version, everything compiled allright. any idea ?
thanks
Aapt2 is enabled by default when you use android plugin for gradle 3.0.
This is to
improve incremental resource processing
as stated here.
But if you are facing issues with it, you can switch back to previous version by adding this in gradle.properties
android.enableAapt2=false

Non-specific Error in Android studio 3.0 Beta 2

I can't continue building my app, because I updated Android studio to 3.0 beta 2 and I got this error message:
Error:C:\Users\Luk?\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.1.aar\f61ab9a130e23c5f88348e1bd6936dcf\res\drawable-xhdpi-v4\abc_ic_menu_copy_mtrl_am_alpha.png file not found
Error:C:\Users\Luk?\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.1.aar\f61ab9a130e23c5f88348e1bd6936dcf\res\drawable-hdpi-v4\abc_btn_radio_to_on_mtrl_000.png file not found
Error:C:\Users\Luk?\.gradle\caches\transforms-1\files-1.1\support-compat-26.0.1.aar\62d1a0a0753b75c4dfbf8fbe3e7715ba\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png file not found
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
aapt2 compile --legacy -o C:\AndroidApp\app_name\app\build\intermediates\res\merged\debug C:\Users\my_name.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.1.aar\f61ab9a130e23c5f88348e1bd6936dcf\res\layout\tooltip.xml
Issues:
- ERROR: C:\Users\my_name.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.1.aar\f61ab9a130e23c5f88348e1bd6936dcf\res\layout\tooltip.xml file not found
Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.
If you want to build the project with aapt2 enabled the follow the below link for changes in project and to get to how fix the error.
Reference : here
I was using Android studio 3.0.1 In which I disabled the AAPT2 and it resolved my error.

Categories

Resources