NOTICE: Please do not post this "android.enableAapt2=false" as an answer. It is not a solution. It is just ignoring the real error which is not causing any problem on runtime.
Solution was simple, just removed mistakenly placed action tag outside of an intent filter in the manifest file.
Have an application which was building by Android Studio 2.3 fine. After updating Android Studio 3.0 Stable, started to having this error and unable to build my project.
Here my manifest.xml
<application
android:name=".ApplicationClass"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--other unrelated stuff-->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.xxx.xxx" />
</intent-filter>
</receiver>
</application>
Error shows this line:
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
If I comment/remove this action tag line, the project builds fine but it is necessary for GCM
and I cannot remove it.
As you see the logs, The error not occurs at main manifest file, occurs at /build/intermediates/manifests/full/debug/AndroidManifest.xml
Tried cleaning, rebuilding, disabling instant run. Is there any solution?
The Error Logs:
/THE_PROJECT_PATH/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
Error:(99) error: unknown element <action> found.
Error:(99) unknown element <action> 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
Information:BUILD FAILED in 1s
Information:6 errors
Information:0 warnings
Information:See complete output in console
You have a misplaced tag. The new AAPT (AAPT2) now throws an error on this.
From the docs in here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Behavior changes when using AAPT2
To improve incremental resource processing, Android plugin 3.0.0 enables AAPT2 by default. Although AAPT2 should immediately work with older projects, this section describes some behavior changes that you should be aware of.
Element hierarchies in the Android manifest
In previous versions of AAPT, elements nested in incorrect nodes in the Android manifest are either ignored or result in a warning. For example, consider the following sample:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myname.myapplication"> <application ... <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <action android:name="android.intent.action.CUSTOM" /> </activity> </application> </manifest>
Previous versions of AAPT would simply ignore the misplaced tag. However, with AAPT2, you get the following error:
AndroidManifest.xml:15: error: unknown element <action> found.
To resolve the issue, make sure your manifest elements are nested correctly. For more information, read Manifest file structure.