I use Android Studio 3.1.4 and android gradle plugin version 3.1.4.
Previously I set buildToolsVersion "27.0.3" in build.gradle of module and there was no problem in building/running. Today I installed newer version of build tools and change build.gradle to use that: buildToolsVersion "28.0.2"
But when I try to sync project with gradle files or rebuild project it ends with AAPT2 error:
AGPBI: {"kind":"error","text":"error: \u003citem\u003e inner element must either be a resource reference or empty.","sources":[{"file":"<path to module>/src/main/res/values/ids.xml","position":{"startLine":16,"startColumn":4,"startOffset":752,"endColumn":55,"endOffset":803}}],"original":"","tool":"AAPT"}
....
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':<modulee-name>:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
But I do not understand what causes the error. For example addressed line in error is:
<item type="id" name="bookmark">false</item>
What causes this error and how I can solve this problem?
Edit
I added android.enableAapt2=false to the gradle.properties and it seems ignores error, but causes this warning:
The option 'android.enableAapt2' is deprecated and should not be used
anymore. Use 'android.enableAapt2=true' to remove this warning. It
will be removed at the end of 2018..
you cannot assign false (nor any other value but it's name) to an ID resource.
An ID is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine ID resources with other simple resources in the one XML file, under one element. Also, remember that an ID resources does not reference an actual resource item; it is simply a unique ID that you can attach to other resources or use as a unique integer in your application.
with android.enableAapt2=false it might ignore the logical error, but not "fix it".
Related
I had faced following error when I update versions in Gradle:
C:\Users\03142\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\7e646e2ca904450b985ca981ac3ba677\res\values\values.xml
Error:(251, 5) error: duplicate value for resource 'attr/mode' with config ''.
Error:(251, 5) error: resource previously defined here.
How to Resolved it?
You have defined same resources for multiple times. Like you are using any module for your app but you initialled them multiple times in gradle file.
When I add the core-ktx dependency to my app's build.gradle file, my gradle builds fail with the error message AAPT2 error: check logs for details
It furthermore tells that there are two attributes missing in values.xml. This file is located under the .gradle folder inside my user directory.
when I add android.enableAAPT2=false to my project properties, the build fails due to that option being deprecated so I want to avoid that.
The error descriptions of the two resource not found errors are the following:
error: resource android:attr/fontVariationSettings not found.
Message{kind=ERROR, text=error: resource android:attr/fontVariationSettings not found., sources=[C:\Users\Marc.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\b6d4f8d4d33639ae469eaec181e24176\res\values\values.xml], original message=, tool name=Optional.of(AAPT)}
When I add different ktx libraries everything is just fine. It builds properly and I can even import androidx.collections! How can I add the core-ktx library without any errors?
You are using 'AndroidX' which is only available if you set your compileSdkVersion 'android-P' and targetSdkVersion 28. Then in AndroidStudio go to Refactor -> Refactor to AndroidX and everything should work fine now :).
I created an empty project and added appcompat-v7-26.1.0 support. I'm getting many errors like that:
C:\Users\username.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\e0aabf040e64856c88683f1511ddf095\res\layout\tooltip.xml: error: file not found.
which lead to:
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
I can solve it by adding property in gradle.properties file
android.enableAapt2=false
... but this is rather workaround than fixing the cause. If you take a look at this missing file path it seems quite long so I was wondering if the path length may be the problem as posted for other issues here. Unfortunately I don't know how can I changed it as most of the length is inside the gradle directory, so even if I change GRADLE_USER_HOME path (C:\Users\username\.gradle in my case) it's not a big profit.
I also tried to set
android.enableBuildCache=true # false didn't work as well
android.buildCacheDir =c:\\temp\\
but with no luck. I'd appreciate a helping hand or any tip in this case.
Here is what I changed In build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:0.4.3'
}
issure here:
https://issuetracker.google.com/issues/36972228
I had similar issue.
Changing gradle runtime from Gradle 4.4.1 to Gradle 4.1 helped.
(no changes in dependencies, if you use Jenkins make sure that environment variables updated correctly gradle --version)
It looks like the problem is gradle is looking in C:\Users\username.gradle\caches for the cached appcompat libraries. I'm assuming that username.gradle doesn't exist? Or is that a typo?
In any case, I had a similar issue, and specifying the gradle user home directory fixed it. In my case, gradle was looking inside C:\Windows\System32\config\systemprofile, and not finding the cache because it didn't exist.
I set an environment variable for GRADLE_USER_HOME so that gradle would cache things in a set location. See this question for a little more detail.
I am following google codelab for instant app. After I convert the original app to baseFeature and added another feature module which will then act like the application but will be based on the original baseFeature.
As per told in code lab, I changed the buld.gradle files and deleted the application component from the feature Module (Non Base module). When I try to build the project I get the follow error.
Error:(4) duplicate attribute
Error:/home/adventure/Desktop/android-topeka/topekaapk/build/intermediates/manifests/full/debug/AndroidManifest.xml:4 duplicate attribute
Error:java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:Execution failed for task ':topekaapk:processDebugResources'.
> Failed to execute aapt
I got stabbed in my back by lint , YES LINT
Problem : As shown in the image Lint gave an warning for optimizing the import and I removed the xmlns property from manifest.
Solution : Do not delete the xmlns property
In Android Studio I have this error when I update Android SDK Tools to version 25:
I tried to modify SDK version in gradle build to 21 to execute my app but I have this error. Really I don't why this happens.
This is my build.gradle file:
Thanks a lot for your help!
Update your build tools, and the error will be fixed automatically.
I have same issue before seeing this post i solved it by exiting android studio and running it with administrative privilege
I was getting this after adding google maps. It turned out being a missing key reference
Error:(45) resource string/google_maps_key (aka com.your.package:string/google_maps_key) not found.
Error:(45) error: resource string/google_maps_key (aka com.your.package:string/google_maps_key) not found.
android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
In the manifest. Which needed to be added in the build.gradle script as showin in https://developers.google.com/maps/documentation/android-api/map-with-marker. After adding the following to build.gradle
resValue "string", "google_maps_key",
(project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
The aapt error went away.