When you compile a project sometimes, you may run into "AAPT2 error": Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
.
Search for this error message on google, there are tons of possible resolutions for this, you'll never know what if the root cause of your current issue.
The best practice I find: ./gradlew assembleDebug
.
In my case, the terminal shows exactly the erroneous line:
C:\xxx\AndroidManifest.xml:13: error: attribute 'android:roundIcon' not found.
error: failed processing manifest.
After I remove that line android:roundIcon
, still there are errors, so I run ./gradlew assembleDebug
again.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:13: error: attribute 'android:endX' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:13: error: attribute 'android:endY' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:13: error: attribute 'android:startX' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:13: error: attribute 'android:startY' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:19: error: attribute 'android:offset' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:22: error: attribute 'android:offset' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:7: error: attribute 'android:fillType' not found.
C:\xxx\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:28: error: attribute 'android:fillType' not found.
So again, remove that incorrect res folders.
Problem solved!
The root cause of this issue:
At first the compileSdkVersion
is high (compileSdkVersion >= 26), then I decrease it to 23
, so some new features which are introduced in API level 26 are not available in API level 23.
Anyway, Android Studio is not friendly enough to point out the exact errors.
网友评论