[Fixed] AAPT2 process unexpectedly exit – Android

by
Ali Hasan
android android-gradle-plugin build.gradle gradle-kotlin-dsl

The Problem:

When attempting to run a project in Android 14, the AAPT2 process exits unexpectedly with an error indicating an unknown chunk type ‘200’. The error occurs in the Arsc.cpp file, line 682.

The Solutions:

Solution 1: Update AGP, Gradle, and Gradle Plugin

Explanation:

The error "AAPT2 process unexpectedly exit" can sometimes occur due to outdated Android Gradle Plugin (AGP), Gradle, or Gradle Plugin. Updating these components can resolve the issue.

Steps:

  1. Update your AGP to the latest version (e.g., 7.4.2 or higher).
  2. Update your Gradle to the latest version (e.g., 7.5 or higher).
  3. Update your Gradle Plugin to the latest version compatible with your AGP and Gradle.

For example, in your gradle-wrapper.properties file, update the distributionUrl to the latest version:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

Then, in your build.gradle file, update the AGP version:

dependencies {
    classpath 'com.android.tools.build:gradle:7.4.2'
}

Finally, clean and rebuild your project.

Note: Make sure to consult the official documentation for the latest recommended versions of AGP, Gradle, and Gradle Plugin.

Solution 2: Reduce the `targetSdkVersion`

The aapt2.exe warning about an "Unknown chunk type" is issued because the build tools are not fully up-to-date with the latest Android version. This is not an error, but a warning, and the build should still finish properly.

To resolve the warning, reduce the targetSdkVersion in your app/build.gradle file by one or two API levels. This should be enough to eliminate the warning.

Q&A

When I try to run My project in Android, I noticed one error like APT process unexpectedly exit. Error output apt exe Warns with Unknown chunk type.

Upgrade AGP dependency from 4.2.0 to 4.2.1 or later. Upgrade Gradle version to 7.3.3 or later. Upgrade Gradle plugins to 4.2.0 or later.

The build tools are always a little bit behind — how much depends on the dev environment you use (Android Studio, Delphi, Cordova, Xamarin etc).

Note that this is not an error but a warning (marked in the message by the W after apt exe). Nothing bad should happen and the build should still finish properly.

Video Explanation:

The following video, titled "Aapt2 process unexpectedly exit- Fixed Error In Android Studio ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Aapt2 process unexpectedly exit- Fixed Error In Android Studio.