Async-storage: RN 0.60.0 error: package com.facebook.react.module.annotations does not exist

Created on 8 Jul 2019  Â·  13Comments  Â·  Source: react-native-async-storage/async-storage

upgrading to react-native 0.60.0 throw this error:


xx/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java:26: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
xx/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java:33: error: cannot find symbol
@ReactModule(name = AsyncStorageModule.NAME)
 ^
  symbol: class ReactModule
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-community_async-storage:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

BUILD FAILED in 24s

    at checkExecSyncError (child_process.js:637:11)
    at execFileSync (child_process.js:655:13)
    at runOnAllDevices (xx/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (xx/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
    at then.result (xx/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  • Async Storage version: 1.5.0
  • React-Native version: 0.60.0
question

Most helpful comment

@AbanoubNassem in my case adding:

maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}

to the allprojects config worked

All 13 comments

Hi @AbanoubNassem

Could you provide a repro steps? Have you cleaned the project/restart Metro?

hello @Krizzu , when I tested it on a fresh app it worked fine, but it errors out in my current app, so am trying to figure out which package is conflicting with , and I will update you once I figure something out

after removing/adding all my current packages and upgrading it to use Androidx , I saw that I have native-navigation package https://github.com/airbnb/native-navigation#readme I have no clue how this package was added! probably typeo when instantiated the project back then.
I didn't have this issue before since I was adding the plugins manually, but since v 0.60 the new CLI introduced the auto-discovery function , hence discovering this old package making the whole app crash.

hope this might help someone , if they faced similar problem

I am having this same problem. Removing the package, and adding it back and the latest version to an existing application that had it prior to the .60 update.

I'm getting this error, react native 0.61.0-rc.0. Any update on this ?

I cannot get to the root of this one. All of the packages that are logged to be missing are in the exact location by which react-native-geolocation is looking. Truly blowing my mind.

Try these steps:

  1. Make sure that react-native is in app/build.gradle dependencies
  2. Run ./gradlew clean in android/ directory
  3. Remove node_modules
  4. Install node modules
  5. Run react-native run-android in your project root

Hey @Krizzu! Thanks so much for responding!

My dependencies include react-native:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"
    implementation "androidx.appcompat:appcompat:1.0.0"
    implementation "com.facebook.android:facebook-android-sdk:4.22.1"
    implementation "com.google.firebase:firebase-ads:17.2.1"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
      transitive = true
    }
    implementation "com.google.firebase:firebase-firestore:19.0.0"
    implementation ('com.google.android.gms:play-services-gcm:10.2.1') {
        force = true;
    }
    implementation (project(':react-native-svg')) {
      exclude group: "com.android.support", module: "appcompat-v7"
    }
    implementation (project(':react-native-fbsdk')) {
      exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
    }

    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

I deleted the node_modules and npm install, then received the same errors.

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBAccessTokenModule.java:33: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBAccessTokenModule.java:38: error: cannot find symbol
@ReactModule(name = FBAccessTokenModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBActivityEventListener.java:27: error: cannot find symbol
import com.facebook.react.bridge.BaseActivityEventListener;
                                ^
  symbol:   class BaseActivityEventListener
  location: package com.facebook.react.bridge
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBActivityEventListener.java:29: error: cannot find symbol
public class FBActivityEventListener extends BaseActivityEventListener {
                                             ^
  symbol: class BaseActivityEventListener
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBAppEventsLoggerModule.java:32: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBAppEventsLoggerModule.java:106: error: cannot find symbol
@ReactModule(name = FBAppEventsLoggerModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBGameRequestDialogModule.java:29: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBGameRequestDialogModule.java:37: error: cannot find symbol
@ReactModule(name = FBGameRequestDialogModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBGraphRequestModule.java:42: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBGraphRequestModule.java:55: error: cannot find symbol
@ReactModule(name = FBGraphRequestModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBLoginManagerModule.java:38: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBLoginManagerModule.java:45: error: cannot find symbol
@ReactModule(name = FBLoginManagerModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBMessageDialogModule.java:29: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBMessageDialogModule.java:36: error: cannot find symbol
@ReactModule(name = FBMessageDialogModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBShareAPIModule.java:30: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBShareAPIModule.java:39: error: cannot find symbol
@ReactModule(name = FBShareAPIModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBShareDialogModule.java:29: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
                                            ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBShareDialogModule.java:33: error: cannot find symbol
@ReactModule(name = FBShareDialogModule.NAME)
 ^
  symbol: class ReactModule
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBAppEventsLoggerModule.java:213: error: cannot find symbol
     @ReactMethod(isBlockingSynchronousMethod = true)
                                                ^
  symbol:   method isBlockingSynchronousMethod()
  location: @interface ReactMethod
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBActivityEventListener.java:32: error: method does not override or implement a method from a supertype
  @Override
  ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBSDKCallbackManagerBaseJavaModule.java:39: error: incompatible types: FBActivityEventListener cannot be converted to ActivityEventListener
        reactContext.addActivityEventListener(mActivityEventListener);
                                              ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBLoginButtonManager.java:41: error: incompatible types: FBActivityEventListener cannot be converted to ActivityEventListener
        reactApplicationContext.addActivityEventListener(mActivityEventListener);
                                                         ^
C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBSDKPackage.java:31: error: FBSDKPackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class FBSDKPackage implements ReactPackage {
       ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Monroe\tourney\mobile\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\Utility.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
23 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbsdk:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 7s

    at checkExecSyncError (child_process.js:602:13)
    at execFileSync (child_process.js:622:13)
    at runOnAllDevices (C:\Users\Monroe\tourney\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\Users\Monroe\tourney\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at then.result (C:\Users\Monroe\tourney\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

I am stuck and have been on this for days. I really appreciate any info or advice you have. Have a great day!

@stnmonroe What version of React Native are you using?

I am facing similar issues while trying to build @react-native-community/netinfo package for android.

`D:\ReactNative\TestProjectnode_modules\@react-native-community\netinfo\android\src\main\java\comreactnativecommunity\netinfo\NetInfoModule.java:14: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\ReactNative\TestProjectnode_modules\@react-native-community\netinfo\android\src\main\java\comreactnativecommunity\netinfo\NetInfoModule.java:17: error: cannot find symbol
@ReactModule(name = NetInfoModule.NAME)
^
symbol: class ReactModule

2 errors`

I am facing this error in both 0.60.5 and 0.59.0

@BarinderGrewal If you are having an issue in the netinfo library, you should open an issue there or comment on the already open issue.

I'm facing the same problem here! My dependencies are listed below:

"dependencies": {
    "blueimp-md5": "^2.12.0",
    "expo-asset": "^7.0.0",
    "expo-constants": "^7.0.0",
    "expo-file-system": "^7.0.0",
    "expo-font": "^7.0.0",
    "react": "^16.10.2",
    "react-dom": "^16.11.0",
    "react-native": "^0.59.2",
    "react-native-bluetooth-serial": "^1.0.0-rc1",
    "react-native-elements": "^0.19.1",
    "react-native-gesture-handler": "^1.1.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^3.13.0",
    "react-redux": "^6.0.1",
    "redux": "^4.0.4"
}

@AbanoubNassem in my case adding:

maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}

to the allprojects config worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StevenMasini picture StevenMasini  Â·  22Comments

Krizzu picture Krizzu  Â·  36Comments

josmithua picture josmithua  Â·  20Comments

Waqas-Jani picture Waqas-Jani  Â·  28Comments

cpojer picture cpojer  Â·  34Comments