9

I am getting this error:

Task :@react-native-community_async-storage:compileReleaseJavaWithJavac FAILED
/Users/Desktop/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.java:10: error: package javax.annotation does not exist
import javax.annotation.Nullable;                       ^
/Users/Desktop/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.java:20: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.ReadableArray;
like 1`

Why is this happening and how can I fix it?

0

1 Answer 1

10

OP's solution migrated from the question to an answer:

In your android/build.gradle, add the following lines

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
   configurations.all {
       resolutionStrategy {
           force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
       }
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.