0
votes

I am using react-native async-storage community version which is working smoothly with iOS but not with android.

After using react-native run-android I am getting following error

FAILURE: Build failed with an exception.

  • Where: Build file '/Users/blickx/Desktop/dumont-reactnative/Dumont/node_modules/@react-native-community/async-storage/android/build.gradle' line: 36

  • What went wrong: A problem occurred evaluating project ':@react-native-community_async-storage'.

    Plugin with id 'com.android.library' not found.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 5s

at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (/Users/blickx/Desktop/dumont-reactnative/Dumont/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/Users/blickx/Desktop/dumont-reactnative/Dumont/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at /Users/blickx/Desktop/dumont-reactnative/Dumont/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (/Users/blickx/Desktop/dumont-reactnative/Dumont/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:7)
2
which version of RN are you using? and have you linked it manually? - Gaurav Roy
react-native-cli: 2.0.1 react-native: 0.61.1 - vicky keshri
nope. I have linked it using the link command. However, I have manual linking also. both are same. - vicky keshri
one thing , is your app not working? like for me too after react-native run-android it says build failed but i can use my app in my phone after connecting it via wifi. have you tried that? - Gaurav Roy
When I run command react-native run-android it throw the error. It doesn't matter from which network you are connected. - vicky keshri

2 Answers

0
votes

Problem

It seems you have a missing android plugin which is causing the issue for you.

Solution

Instruct Gradle to download Android plugin from Maven Central repository. You do it by pasting the following code at the beginning of the Gradle build file:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
    }
}

Note: Make sure your project is using Gradle 3.

Hope this Helps!

0
votes

In settings.gradle file find this

include ':@react-native-async-storage_async-storage' project(':@react-native-async-storage_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-async-storage/async-storage/android')

copy the ':@react-native-async-storage_async-storage' in the include line and paste the same to implementation project line in build.gradle

Like this ->

dependencies {

......

implementation project(':@react-native-async-storage_async-storage') //<- paste this

..... }