Unable to build project with gradle 4.1: "unknown element * found" - android

After updating to Gradle 4.1 I'm unable to build my project (all works fine with previous releases).
Basically it doesn't recognize AndroidManifest tags anymore and gives me errors in the generated manifest in /build/intermediates/manifests/full/debug.
Here's the build log:
/home/paolorotolo/dev/exp/***/build/intermediates/manifests/full/debug/AndroidManifest.xml
Error:(30) unknown element <action> found
Error:(32) unknown element <category> found
Error:(33) unknown element <category> found
Error:/home/paolorotolo/dev/exp/core/***/build/intermediates/manifests/full/debug/AndroidManifest.xml:30 unknown element <action> found
Error:/home/paolorotolo/dev/exp/core/***/build/intermediates/manifests/full/debug/AndroidManifest.xml:33 unknown element <category> found
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 ':***:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 6s

The issue has been fixed in new gradle release (gradle-4.1-rc-2).
To solve add in your gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-2-all.zip

For now using gradle 4.1, or even 4.2 on your gradle wrapper will break builds that have dependencies
I solved this issue by taking back my gradle classpath depency back to gradle 2.3.3
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'

You should check your AndroidManifest.xml,make sure every element like 'action' or 'category' is in right position.

I have got the similar issue recently, The way I solved is by invalidating the cache. You can do that in android studio-> File-> Invalidate cache/ Restart.
After that it stop showing me those ActivityFeed error.

Related

After update of Android Studio 3.6 & Gradle to 3.5.0 unable to run project

Everything was working smoothly but after update of Android Stdio 3.6 & Gradle to 3.5.0, Project is not building,
Getting bellow errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
C:\Users\Amin\.gradle\caches\transforms-2\files-2.1\c1ea7b9f1e5ec36cfafa4328570d20ad\constraintlayout-2.0.0-beta2\res\values\values.xml:321:5-600: AAPT: error: duplicate value for resource 'attr/pivotX' with config ''.
C:\Users\Amin\.gradle\caches\transforms-2\files-2.1\c1ea7b9f1e5ec36cfafa4328570d20ad\constraintlayout-2.0.0-beta2\res\values\values.xml:321:5-600: AAPT: error: resource previously defined here.
C:\Users\Amin\.gradle\caches\transforms-2\files-2.1\c1ea7b9f1e5ec36cfafa4328570d20ad\constraintlayout-2.0.0-beta2\res\values\values.xml:321:5-600: AAPT: error: duplicate value for resource 'attr/pivotY' with config ''.
Here is gradle.properties
org.gradle.jvmargs=-Xmx4608m
android.enableJetifier=true
android.useAndroidX=true
Finally..
I have solved the problem..
I observed error was in constraintlayout as per logcat and observed the constraintlayout version which was alpha
I downgrade the version to implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
and the issue got fixed.
Try changing in gradle.properties
org.gradle.jvmargs=-Xmx4096m
Anyone that tried to do so with com.android.tools.build:gradle:3.5.2 and Gradle Version 5.4.1 the fix is the same - make sure you are working with
androidx.constraintlayout:constraintlayout:1.1.3
when using 3.5.0 and up without androidx.constraintlayout:constraintlayout:1.1.3 - the UI will be blank (inflate exception) for any view that is extending ConstraintLayout.

Android Studio 3.0 failed mergeDebugResources - error: file not found

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.

duplicate attribute AAPT2 link failed in feature Module in Instant app

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

Andorid Studio: ExecutionException : (integer) -1 is less than minimum integer 0

I updated to Android Studio 3 Canary build 2, which bumped up my build tools like so:
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
Now when I try to build I get this issue:
Error:.../values.xml:3490 (integer) -1 is less than minimum integer 0
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 ':app:processStagingResources'.
Failed to execute aapt
So I took a look at line 3490 of the file referenced above and got this:
<item name="android:numColumns">auto_fit</item>
Because it references I GridView style, I went to the docs and found that AUTO_FIT has a value of -1
I'm not sure why I'm getting this issue but I've tried cleaning/building, restarting and I still get that issue. Any idea what to try?
You can disable AAPT2 by putting this in your gradle.properties file:
android.enableAapt2=false
Try upgrading your build tools to 26.0.2 or newer, it was a bug in AAPT2, it should be fixed now.
If you're still using an alpha or a beta of AndroidStudio try upgrading to Android Studio 3.0.

Error:Execution failed for task ':app:mergeDebugResources'. > Error: java.io.FileNotFoundException:

Error: java.io.FileNotFoundException: \app\build\intermediates\res\merged\debug\drawable-mdpi-v4\abc_ic_star_black_48dp.png (The requested operation cannot be performed on a file with a user-mapped section open)
trying to build project but file name changes all the time, error remain same
Just open this(app\build\intermediates\res\merged\debug\drawable-mdpi-v4\abc_ic_star_black_48dp.png) file directory and delete it.
Clean and Re-build your project.
Hope this will help you.
The Android Gradle plugin version 2.2.2 has an issue.
To resolve this issue you need to change your gradle plugin version in project setting:
classpath 'com.android.tools.build:gradle:2.1.3'
Just delete build folder in app then clean & rebuild project that works fine.

Categories

Resources