Aapt2 error: check logs for details

Exception:

Caused by: com.android.builder . internal.aapt .v2.Aapt2Exception: AAPT2 error: check logs for details
    at com.android.builder . png.AaptProcess $N otifierProcessOutput.handleOutput ( AaptProcess.java:443 )
    at com.android.builder . png.AaptProcess $N otifierProcessOutput.err ( AaptProcess.java:395 )
    at com.android.builder . png.AaptProcess $ ProcessOutputFacade.err ( AaptProcess.java:312 )
    at com.android.utils .GrabProcessOutput$1.run( GrabProcessOutput.java:104 )

All r documents are wrong and red;

Aapt2 explains:

AAPT is the full name of Android asset packaging tool. It is an indispensable tool to build app and even Android system. Its function is to compress and package all resource files into Android APK. We can find it in the Android SDK directory. For example, I can find it in my directory D: SDK, build tools, 28.0.2, and other versions of build tools;

Aapt2 is a new version of AAPT. Starting from Android studio 3.0, it is used as the default resource packaging tool.

terms of settlement:

1. Click toggleview to view the execution output of gradle more clearly;

After clicking, it is shown as follows:

2. The red output information in the figure above has the following information:

AGPBI: {"kind":"error","text":"error: resource drawable/shape_round (aka com.liyuhuyu.liyu:drawable/shape_round) not found.","sources":[{"file":"E:\\Project\\LiYuTwo\\app\\src\\main\\res\\layout\\item_water.xml","position":{"startLine":10}}],"original":"","tool":"AAPT"}

AGPBI: {"kind":"error","text":"error: resource drawable/popupwindow_close (aka com.liyuhuyu.liyu:drawable/popupwindow_close) not found.","sources":[{"file":"E:\\Project\\LiYuTwo\\app\\src\\main\\res\\layout\\popupwindow_pay_select.xml","position":{"startLine":62}}],"original":"","tool":"AAPT"}

3. From the above prompt output information, we can know the following:

1) The file where the error occurred is item_ water.xml ;

2) The reason for the mistake is android:background Property value “@ drawable / shape”_ “Round” not found

4. Open item_ water.xml File, find the error location, as shown in the above output information error; delete or correct it;

Conclusion:

1) In fact, the reason for my error is that the referenced resource file cannot be found;

2) Aapt2 is a tool for packing resource files. If aapt2 reports an error, it is usually a problem with the resource file.

Other solutions:

Many solutions on the Internet say that the project is successful gradle.properties Add a line to“ android.enableAapt2=false “To shut down aapt2


Other knowledge:

Use AAPT to view the app package name and other information

1, use CD in the command line of CMD to switch to the directory where AAPT is located

2. Enter the command “AAPT dump bagging C: / / users / administrator / desktop / find fault 201905171701. APK” to run, OK;

The path of the app is C: users, administrator, desktop, 201905171701.apk

Read More: