Exception:Aapt2 Error: Check Logs for Details

Exception : AAPT2 error: check logs for details

I ran into this very issue today morning and found the solution for it too. This issue is created when you have messed up one of your .xml files. I'll suggest you go through them one by one and look for recent changes made. It might be caused by a silly mistake.

In my case, I accidentally hardcoded a color string as #FFFFF(Bad practice, I know). As you can see it had 5 F instead of 6. It didn't show any warning but was the root of the same issue as encountered by you.

Edit 1: Another thing you can do is to run assembleDebug in your gradle console. It will find the specific line for you.

Edit 2: Adding an image for reference to run assembleDebug.

Sample Image

AAPT2 error: check logs for details after Android Studio upgrade

I ran into this problem a while ago, after updating my Android Studio to the latest version. After searching for a long time, this answer was my savior.

As this answer suggests, the problem might be messed up XML files in your project. You can look for the messed up part by yourself, or run the assembleDebug command in your terminal (like this), which can find the exact line that should be fixed.

AAPT2 error: check logs for details(Build failed)

Okay, so the problem is with the AndroidManifest in your app module:

    <activity android:name=".Main2Activity">
<service
android:name="SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD"
tools:ignore="WrongManifestParent">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

According to the documentation the 'service' element must be nested under 'application' not 'activity'. So change that part of code to:

    <activity android:name=".Main2Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD"
tools:ignore="WrongManifestParent">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>

This will fix the error you are getting from AAPT2. For your project to build successfully you will also need to update your dependencies as described here. If you do both, everything should build correctly. :)



Related Topics



Leave a reply



Submit