Android studio 3.0.1 new project: AAPT2 Execution Exception - android

I created a new project in Android Studio 3.0.1 and during the build process I am getting aapt2 exceptions. Disabling aapt2 is an option but I want to understand why aapt2 is failing to build.
Let me know if any additional details are required
Gradle Console Output:
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 1s
Console output with --info flag:
AAPT warning(1028621614), Job(QueuedJob{
title=Compiling values.xml,
task={from=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml, to=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\res\merged\debug},
future=com.google.common.util.concurrent.SettableFuture#7d83ce1d}): Done
Exception while processing job : QueuedJob{
title=Compiling values.xml,
task={from=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml, to=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\res\merged\debug},
future=com.google.common.util.concurrent.SettableFuture#7d83ce1d} : com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Process (412248382) processed 0 files
Thread(queued-resource-processor_54): Process(412248382), after shutdown queue_size=2
Slave 1566465306 is ready
Process (197581388) processed 0 files
Thread(queued-resource-processor_55): Process(197581388), after shutdown queue_size=2
Process (1933852165) processed 1 files
Thread(queued-resource-processor_53): Process(1933852165), after shutdown queue_size=1
Process (1566465306) processed 0 files
Thread(queued-resource-processor_56): Process(1566465306), after shutdown queue_size=0
Shutdown finished in 9ms
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
:app:mergeDebugResources (Thread[Task worker for ':',5,main]) completed. Took 0.561 secs.
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 --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
7 actionable tasks: 1 executed, 6 up-to-date
Edit:
Full Gradle Output:
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature.
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location 'D:\AndroidSDK\add-ons\addon-google_apis-google-19-1' (Expected 'D:\AndroidSDK\add-ons\addon-google_apis-google-19')
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location 'D:\AndroidSDK\add-ons\addon-google_apis-google-19-1' (Expected 'D:\AndroidSDK\add-ons\addon-google_apis-google-19')
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
values_values.arsc.flat: error: failed to open.
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:prepareLintJar UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformNativeLibsWithStripDebugSymbolForDebug
:app:processDebugJavaRes NO-SOURCE
:app:validateSigningDebug
: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 24s
18 actionable tasks: 11 executed, 7 up-to-date

The simple solution has to do with folder permissions. I discovered the answer after a lot of digging through the stacktrace output and learning more about the Java exception.
Move your Development/Project folder to a location that gives write accesss to android studio/gradle.

Related

Could not resolve all files for configuration error with gradle on Android Studio

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
> Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.
> Could not resolve io.realm:realm-annotations-processor:10.0.1.
Required by:
project :app
> Could not resolve io.realm:realm-annotations-processor:10.0.1.
> Could not get resource 'https://jcenter.bintray.com/io/realm/realm-annotations-processor/10.0.1/realm-annotations-processor-10.0.1.pom'.
> Could not GET 'https://jcenter.bintray.com/io/realm/realm-annotations-processor/10.0.1/realm-annotations-processor-10.0.1.pom'. Received status code 502 from server: Bad Gateway
* 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 4s
2 actionable tasks: 1 executed, 1 up-to-date
Does anyone know how to fix these problems? And below is the image for my build.gradle.
build.gradle project :
build.gradle App :
2 & 3

Cause: newPosition < 0: (-1 < 0) in Android Studio

I am getting errors in android studio, I tried all the possible steps but nothing helped me.
[Android Gradle Plugin Version 4.2.2, Gradle Version:7.2-rc-2 and JDK 15.0.2
Error Log File
Executing tasks: [clean, :app:assembleDebug] in project C:\Users\asrar\Desktop\Smart GIT
Task :clean UP-TO-DATE
Task :app:clean
Task :app:preBuild UP-TO-DATE
Task :app:preDebugBuild UP-TO-DATE
Task :app:compileDebugAidl NO-SOURCE
Task :app:compileDebugRenderscript NO-SOURCE
Task :app:generateDebugBuildConfig
Task :app:javaPreCompileDebug
Task :app:checkDebugAarMetadata
Task :app:generateDebugResValues
Task :app:generateDebugResources
Task :app:processDebugGoogleServices
Task :app:createDebugCompatibleScreenManifests
Task :app:extractDeepLinksDebug
Task :app:mergeDebugResources
Task :app:processDebugMainManifest
Task :app:processDebugManifest
Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
Task :app:mergeDebugShaders
Task :app:compileDebugShaders NO-SOURCE
Task :app:generateDebugAssets UP-TO-DATE
Task :app:mergeDebugAssets
Task :app:compressDebugAssets
Task :app:processDebugJavaRes NO-SOURCE
Task :app:mergeDebugJavaResource FAILED
Task :app:checkDebugDuplicateClasses FAILED
Task :app:processDebugManifestForPackage
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
newPosition < 0: (-1 < 0)
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.
==============================================================================
2: Task failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform work-runtime-2.5.0.aar (androidx.work:work-runtime:2.5.0) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for AarToClassTransform: C:\Users\asrar.gradle\caches\modules-2\files-2.1\androidx.work\work-runtime\2.5.0\b878e75e14ee7e745fe120bc78e8db8995064f4d\work-runtime-2.5.0.aar.
> zip END header not found
Failed to transform concurrent-futures-1.1.0.jar (androidx.concurrent:concurrent-futures:1.1.0) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=7, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for EnumerateClassesTransform: C:\Users\asrar.gradle\caches\transforms-3\a51d8e3d972cee1891837c926b3ae865\transformed\jetified-concurrent-futures-1.1.0.jar.
> zip END header 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2-rc-2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 34s
18 actionable tasks: 17 executed, 1 up-to-date
Stacktrace and info is not a solution, just gives you more information about what went wrong.
Seems really similar to IntelliJ Compilation Error zip END header not found
Which suggests your gradle cache is corrupted. Try clearing it. folder: $HOME/.gradle/caches
Probably there are some corrupted files.
For me invalidating caches and restart worked.
Last option here:
The versions you're using for plugin version and Gradle are not compatible. According to https://developer.android.com/studio/releases/gradle-plugin?
For Gradle Version 7.2 you need at least 7.1 Plugin version

there is always appear to me when i build

Executing tasks: [:app:generateDebugSources]
Configuration on demand is an incubating feature.
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:mainApkListPersistenceDebug UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: G:\ProjectsClone\MessengerClone\app\google-services.json
AGPBI: {"kind":"error","text":"error: not well-formed (invalid token).","sources":[{"file":"G:\\ProjectsClone\\MessengerClone\\app\\src\\main\\res\\layout\\activity_weather.xml","position":{"startLine":53}}],"original":"","tool":"AAPT"}
:app:mergeDebugResources
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.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.builder.internal.aapt.v2.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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 13s
10 actionable tasks: 2 executed, 8 up-to-date
Most probably, the issue here is exactly what the error message says:
"Could not find google-services.json".
If not already done, you need to download this json file from your Firebase console and place it in app folder.
The error is in your file activity_weather.xml. The error is not well formed which means that the XML structure isn't correct, most likely a closing tag missing somewhere.

Can someone give me a better understanding of this error? Error:Execution failed for task ':app:processDebugResources'

Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
I recently updated my version of android studio, when i create an activity now i get this error. Can someone explain this error to me?
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Configuration on demand is an incubating feature.
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\eche\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
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:prepareComAndroidSupportAppcompatV72310Library
:app:prepareComAndroidSupportConstraintConstraintLayout101Library
:app:prepareComAndroidSupportDesign2310Library
:app:prepareComAndroidSupportRecyclerviewV72310Library
:app:prepareComAndroidSupportSupportV42310Library
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
AGPBI: {"kind":"error","text":"No resource identifier found for attribute \u0027srcCompat\u0027 in package \u0027com.drawscape.drawscape\u0027","sources":[{"file":"C:\Users\eche\Documents\Drawscape 2.05\app\src\main\res\layout\activity_adminoptions.xml","position":{"startLine":24}}],"original":"","tool":"AAPT"}
C:\Users\eche\Documents\Drawscape 2.05\app\build\intermediates\res\merged\debug\layout\activity_adminoptions.xml:25: error: No resource identifier found for attribute 'srcCompat' in package 'com.drawscape.drawscape'
FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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.
BUILD FAILED
Total time: 5.875 secs

Gradle Build Error on Android Studio in Ubuntu 12.04 LTS

Well, after too much googling for about two days and trying most of the recommended work arounds suggested on this platform, my problem is not solved yet!!
It goes like this...
I have started android app development recently with Android Studio on Ubuntu 12.04 LTS.
Whenever I open my project, gradle build always finishes with following two errors;-
Executing tasks: [clean, :app:compileDebugJava]
Configuration on demand is an incubating feature.
:app:clean
:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
/home/vivek/AndroidStudioProjects/MyApplication3/app/src/main/res/drawable-mdpi/ic_launcher.png: Error: Cannot run program "/home/vivek/Documents/android-studio/sdk/build-tools/21.0.1/aapt": error=2, No such file or directory
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> /home/vivek/AndroidStudioProjects/MyApplication3/app/src/main/res/drawable-mdpi/ic_launcher.png: Error: Cannot run program "/home/vivek/Documents/android-studio/sdk/build-tools/21.0.1/aapt": error=2, No such file or directory
* 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: 6.776 secs

Categories

Resources