Elton11220
Elton11220

Reputation: 23

A timeout exception thrown by AAPT2 during the packaging of React Native application on Android

My react-native project has a 10mb image that I import through "require" with TypeScript.

When building the Android package, an error occurs with message:

> Task :app:mergeReleaseResources
AAPT2 aapt2-8.2.1-10154469-windows Daemon #1 Failed to shutdown within timeout
java.util.concurrent.TimeoutException: AAPT2 aapt2-8.2.1-10154469-windows Daemon #1: Failed to shut down within 30 seconds. Forcing shutdown

I think this problem is caused by the large size of the picture. Is there any good solution?

There are ways to get rid of the resource file size limit or there are better ways to solve this problem

Upvotes: 0

Views: 363

Answers (1)

Manish
Manish

Reputation: 2868

You can remove this error by increasing AAPT2 shut down timeout as shown below in gradle file android block.

android {
    aaptOptions {
        timeoutInMs 60000 
        // Increase timeout to 60 seconds (default is 30 seconds)
    }
}

Large images for instance take AAPT2 a while to work on your project. Simplify your resources and decrease the quantity of them. Check for possible optimisations through the use of tools such as Lint within the Android Studio. and websites like tinypng to optimise those 10 mb images.


Helpful links :

Upvotes: 1

Related Questions