android studio 3.0 | AAPT2 Error: failed to execute apt - android

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

Related

How to fix : Execution failed for task ':app:processDebugResources'

I'm currently working with Cordova CLI along with Android cmdline-tools, and I'm getting this error when I run cordova build to generate apk.
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
/home/user/.gradle/caches/transforms-2/files-2.1/1723263284390e5d17b6b8ac539aa999/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT:
error: resource android:attr/lStar not found.
A couple of days ago was working perfectly but I just can't spot the issue.
What's happening ?
I'm still troubleshooting with this.
Any help is hugely appreciated.
the issue is in values.xml file where you have defined android:attr/lStar .
the resource directory is not able to find resource with the same so that the resource can not be found.
You can use this example for further reference.
A failure occurred while executing com.android.build.gradle.internal.tasks

Meteor APK build broken with accounts-google

We can no longer build our APK with accounts-google. Obviously, this is a serious blocking issue.
This build was working fine as recently as two days ago. Now it would seem that Google have once again broken something.
Steps to produce the issue:
$ meteor create broken-gooogle-oauth-test
$ cd broken-gooogle-oauth-test
$ meteor add-platform android
$ meteor add accounts-google
$ meteor build --verbose ~/test-build --server=http://www.example.com
or...
$ meteor run android-device
Either way, you eventually will see a long list of error messages, starting with:
/home/mad/.gradle/caches/transforms-1/files-1.1/core-1.0.0.aar/37baf6a1e42da25347f527a778e640b7/res/values/values.xml:133:5-70: AAPT: error: resource android:attr/fontVariationSettings not found.
/home/mad/.gradle/caches/transforms-1/files-1.1/core-1.0.0.aar/37baf6a1e42da25347f527a778e640b7/res/values/values.xml:133:5-70: AAPT: error: resource android:attr/ttcIndex not found.
/home/mad/androidTest3/.meteor/local/cordova-build/platforms/android/app/build/intermediates/incremental/mergeReleaseResources/merged.dir/values/values.xml:92: error: resource android:attr/fontVariationSettings not found.
/home/mad/androidTest3/.meteor/local/cordova-build/platforms/android/app/build/intermediates/incremental/mergeReleaseResources/merged.dir/values/values.xml:92: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor184.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt
The cause of this is the June 17th update of the google android libs, which make API 28 the required minimum SDK version. API 28 introduces some new XML attributes, such as ttcIndex and fontVariationSettings referenced in your error.
In this case the plugins in question are com.google.android.gms:play-services-auth and com.google.android.gms:play-services-identity
Unfortunately there isn't an easy way of fixing this, apart from hacking the meteor output in .meteor/local. There are two approaches:
force API 28 (obviously you'll need to download the required API files)
change the :+ version requirement in cordova-plugin-googleplus to the latest version that supports API 27 (e.g., before June 17th).
Option 1 is the cleanest if you can manage it, in .meteor/local/cordova-build/platforms/android edit project.properties and set target=android-28
Option 2 is harder, but better if you're not ready to update everything to API 28. You'd need to edit the plugins plugin.xml file or find where those files are referenced in a .gradle file somewhere.

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

Android Studio 3.0 migration AAPT2 error

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

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