React-native-fbsdk: error: cannot find symbo import androidx.annotation.Nullable;

Created on 22 Jul 2019  路  10Comments  路  Source: facebook/react-native-fbsdk

After running react-native run-android
This happens

node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBLoginButtonManager.java:62: error: cannot find symbol
public void setDefaultAudience(RCTLoginButton loginButton, @Nullable String defaultAudience) {
^
symbol: class Nullable
location: class FBLoginButtonManager
node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\FBLoginButtonManager.java:69: error: cannot find symbol
@Nullable ReadableArray publishPermissions) {
^
symbol: class Nullable
location: class FBLoginButtonManager
\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\Utility.java:306: error: cannot find symbol
public static @Nullable List reactArrayToStringList(@Nullable ReadableArray array) {
^
symbol: class Nullable
location: class Utility
\node_modules\react-native-fbsdk\android\src\main\java\com\facebook\reactnative\androidsdk\Utility.java:306: error: cannot find symbol
public static @Nullable List reactArrayToStringList(@Nullable ReadableArray array) {
^
symbol: class Nullable
location: class Utility
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: 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.
12 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.

Most helpful comment

in android/gradle.properties add below two line. in my case solve issue using this.

android.useAndroidX=true
android.enableJetifier=true

All 10 comments

Any solution for above? Facing the same issue.

Same issue here :(

in android/gradle.properties add below two line. in my case solve issue using this.

android.useAndroidX=true
android.enableJetifier=true

in android/gradle.properties add below two line. in my case solve issue using this.

android.useAndroidX=true
android.enableJetifier=true

Thanks

Hi,
It looks like I have a similar problem as topic started.
I have modified graddle.properties as theyasirahmad suggested, but that did not help.

How to reproduce:

  1. clone the repo
  2. yarn install && yarn run start in example/ folder
  3. in another terminal run npx react-native run-android
    as a result I get a lot of errors as above:
ImagePickerModule.java:15: error: package androidx.annotation does not exist
import androidx.annotation.NonNull;

Any ideas?

Genial Funciona 100 Puntos 馃憤馃憤 @theyasirahmad Gracias 馃挭

android.useAndroidX=true
android.enableJetifier=true

i get an error like this

Task :react-native-gesture-handler:compileDebugJavaWithJavac
/Users/fandupratamalakuana/test-interview/react-native/<my_folder>/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java:37: error: cannot find symbol
import androidx.annotation.Nullable;

end then this methods its works

Add the following two flags to true in your gradle.properties file at ProjectFolder/android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

Execute:
npm install --save-dev jetifier
npx jetify
npx react-native run-android

In your package.json add the following to scripts
"postinstall" : "npx jetify"

https://stackoverflow.com/questions/40380519/error-package-com-android-annotations-does-not-exist

add
implementation("com.google.code.findbugs:jsr305:3.0.2")
to build.gradle.kts

Was this page helpful?
0 / 5 - 0 ratings