Android Studio 3.0 unknown element <library> found

After I updated Android Studio, one of my projects cannot be built. The error message is:

Error:(20) error: unknown element <library> found.
Error:(20) unknown element <library> 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

My SDK version is 25. I have tried to invalidate cache and add distributionUrl=https://services.gradle.org/distributions/gradle-4.1-rc-2-all.zip, and both of them don't work for me.

Here is my dependencies:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.4.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
testCompile 'junit:junit:4.12'

annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'

compile 'com.microsoft.projectoxford:face:1.3.0'
}

This is the error log after removing DBFlow:

Error:(20) error: unknown element <library> found.
Error:(20) unknown element <library> 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

Add this code in gradle.properties in the root project:

android.enableAapt2=false

Android Studio 3.0 Manifest Error: unknown element <action> found , You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this. From the docs in here:  Android Studio 3.0 Beta 2 - unknown element <action> found in AndroidManifest.xml

In android studio version 3.1.2 the solution

android.enableAapt2=false

is no longer working.

The root cause of this problem is the Manifest MERGE, which happens when you try to include other dependencies in your project.

To inspect the error

  1. Open AndroidManifest.xml

  2. On bottom of the window select Merged Manifest Tab

  3. Browse your manifest file now, and check the portion of manifest being in the slightly red background or lookup for library tag.

  4. Right click and select Go To Declaration. Inspect the file and check which library/depencency it belongs to.

  5. Either remove that library or update it from the repo.

Hope this helps.

Android Studio 3.0 Manifest Error: unknown element found, You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this. From the docs in here:  Home » Android » Android Studio 3.0 Manifest Error: unknown element <action> found Android Studio 3.0 Manifest Error: unknown element <action> found Posted by: admin April 10, 2020 Leave a comment

This is a reported issue on Github. The issue in the projectoxford seems to be fixed already at v.1.0.395

Unknown element <library> found · Issue #6 · Yalantis/StarWars , The tag in the AndroidManifest.xml causes compile error on Android Studio 3.0 with Gradle 3.0.0-beta6. Please remove that line. Home » Android » Android Studio 3.0 Manifest Error: unknown element <action> found Android Studio 3.0 Manifest Error: unknown element <action> found Posted by: admin October 27, 2017 Leave a comment

Try removing the annotation processor that you have added this line annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}" if you have used any other remove that also

As in studio 3.0 onwards they have inbuilt annotation processor

build error, Android Studio 3.0 Manifest Error: unknown element <action> found. NOTICE: Please do not post this "android.enableAapt2=false" as an answer. It is not a  The SDK and Sample should support Android Studio 3.0.1 and Gradle version 4.1 now. Close this issue and feel free to create a new one if you have any concern. huxuan closed this Mar 1, 2018

You need simply to add this to your Android manifest

<library tools:node="removeAll" />

hope it helps :)

Android Studio 3.0.1 unknown element <user-permission> found, After I updated Android Studio, one of my projects cannot be built. The error message is: Error:(20) error: unknown element <library> found. Tools attributes reference. Android Studio supports a variety of XML attributes in the tools namespace that enable design-time features (such as which layout to show in a fragment) or compile-time behaviors (such as which shrinking mode to apply to your XML resources).

<manifest>, It must contain an <application> element and specify package attributes.… This attribute was introduced in API Level 3. It is meaningful only if  Toggle view: Toggles between displaying task execution as a graphical tree and displaying more detailed text output from Gradle—this is the same output you see in the Gradle Console window on Android Studio 3.0 and earlier. If your build variants use product flavors, Gradle also invokes tasks to build those product flavors.

<uses-permission-sdk-23>, If the device is running API level 22 or lower, the app does not have the specified permission. This element is useful when you update an app to  Then Error:(72) unknown element <receiver> found in the merged manifest occurred. We can see the receiver tag is placed wrong although no receiver can be find in my manifest file at all. And it's all good before upgrading Android Plugin. Hope dji resolve it soon!

Comments
  • This is coming from one of your dependencies. Examine the merged manifest (see the Merged Manifest sub-tab when editing your manifest) and see where it is coming from.
  • Why are you adding filetree 2 times?
  • What does this do specifically?
  • as @udit-kapahi points out, this solution is no longer working
  • I found the reason. It comes from the Microsoft dependency. But is there anyway that I can fix it without removing it?
  • I am not sure, I have never worked with that, maybe try reducing your gradle version from 3.0.0 to 2.3.3
  • Where should add this.