5
votes

Hi I'm just starting to learn how to code on android studio.

After running npm run android on my terminal, I've faced some errors which I could not solve.

The error message is as follows :

XXXX-MacBook-Pro:first-app XXXX$ npm run android

[email protected] android /Users/XXXX/Desktop/React Native/first-app react-native run-android

Scanning folders for symlinks in /Users/XXXX/Desktop/React Native/first-app/node_modules (8ms) Starting JS server... Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

What went wrong: Could not resolve all files for configuration ':app:_internal_aapt2_binary'. Could not find com.android.tools.build:aapt2:3.2.0-4818971. Searched in the following locations: file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar Required by: project :app

BUILD FAILED in 3s 11 actionable tasks: 1 executed, 10 up-to-date Could not install the app on the device, read the error above for details.

I hope you guys can help me with it.

2

2 Answers

7
votes

I managed to fix this issue by adding a line google() to ~/my-app/android/build.gradle in the following section:

allprojects {
    respositories{
        google() //right here
    }
}

Just a guess, but I believe it is a regression to do with the new Android Studio 3.2.0 release.

1
votes

This is in react native which in fact i never used, this isn't an answer but i cant comment as my reputation is too low for that(pardon me). Have you installed android build tools? The ':app:_internal_aapt2_binary' is a configuration file that the system needs to compile the application which is a part of build tools. If you are using android studio 3.0, then in gradle , change the dependency from

compile files('xyz')

to

implementation files('xyz')