React-native-contacts: Cannot install on latest Android (rnc 5.x.x -> 4.x.x)

Created on 28 Jul 2019  路  9Comments  路  Source: morenoh149/react-native-contacts

  symbol:   class NonNull                                                                                                                                                                          location: class ContactsManager                                                                                                                                                                C:\Users\Luis\Documents\web-development\react-native\calando\node_modules\react-native-contacts\android\src\main\java\com\rt2zz\reactnativecontacts\ContactsManager.java:925: error: cannot find symbol                                                                                                                                                                                                                                                @NonNull int[] grantResults) {                                                                                                                                                                    ^                                                                                                                                            symbol:   class NonNull                                                                                                                                                                          location: class ContactsManager                                                                                                                                                                C:\Users\Luis\Documents\web-development\react-native\calando\node_modules\react-native-contacts\android\src\main\java\com\rt2zz\reactnativecontacts\ContactsProvider.java:239: error: cannot find symbol                                                                                                                                                                                              @NonNull                                                                                                                                                                                          ^                                                                                                                                                                                             symbol:   class NonNull                                                                                                                                                                          location: class ContactsProvider                                                                                                                                                               C:\Users\Luis\Documents\web-development\react-native\calando\node_modules\react-native-contacts\android\src\main\java\com\rt2zz\reactnativecontacts\ReactNativeContacts.java:35: error: cannot find symbol
    public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                                                                    ^
  symbol:   class NonNull
  location: class ReactNativeContacts
C:\Users\Luis\Documents\web-development\react-native\calando\node_modules\react-native-contacts\android\src\main\java\com\rt2zz\reactnativecontacts\ReactNativeContacts.java:35: error: cannot find symbol
    public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                                                                                                   ^
  symbol:   class NonNull
  location: class ReactNativeContacts
C:\Users\Luis\Documents\web-development\react-native\calando\node_modules\react-native-contacts\android\src\main\java\com\rt2zz\reactnativecontacts\ContactsManager.java:921: error: cannot find symbol
        ActivityCompat.requestPermissions(currentActivity, new String[]{PERMISSION_READ_CONTACTS}, PERMISSION_REQUEST_CODE);
        ^
  symbol:   variable ActivityCompat
  location: class ContactsManager

Most helpful comment

i fixed this issue installing react-native-contacts:^4.0.2 :)

All 9 comments

I cannot help with windows. If any windows users see this please chime in. @luism3861 also try formatting your stack trace in triple backticks (`) so we can tell where the stack trace ends.

looks like an issue compiling java, ContactsManager.java:921: error: cannot find symbol. Please make sure you can use other react native libraries on android and doublecheck the android installation steps.

i fixed this issue installing react-native-contacts:^4.0.2 :)

Others have reported that installing 4.0.2 works as well. What android version is your project targeting? 5.0.2 should be working on the latest android versions and latest react native versions.

What android version were you targeting? I think the new min android api version for react native apps is 28.

@morenoh149 I got a similar issue when upgraded from from v4.0.2 to v5.0.2.

We use RN 0.59.10 and these are the versions we are using in our build.gradle:

buildToolsVersion = "28.0.3"
minSdkVersion = 18
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"

Tried to use v5.0.0 and still get the same error when I build the app. So apparently it's the Android X api 28 which is breaking it.

Justin case, here's the our error from the build log:

> Task :react-native-contacts:compileDebugJavaWithJavac FAILED
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:3: error: cannot find symbol
import androidx.annotation.NonNull;
                          ^
  symbol:   class NonNull
  location: package androidx.annotation
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:26: error: cannot find symbol
import androidx.annotation.NonNull;
                          ^
  symbol:   class NonNull
  location: package androidx.annotation
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:27: error: package androidx.core.app does not exist
import androidx.core.app.ActivityCompat;
                        ^
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java:7: error: cannot find symbol
import androidx.annotation.NonNull;
                          ^
  symbol:   class NonNull
  location: package androidx.annotation
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:35: error: cannot find symbol
    public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                                                                    ^
  symbol:   class NonNull
  location: class ReactNativeContacts
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ReactNativeContacts.java:35: error: cannot find symbol
    public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                                                                                                   ^
  symbol:   class NonNull
  location: class ReactNativeContacts
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:924: error: cannot find symbol
    protected static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                                                       ^
  symbol:   class NonNull
  location: class ContactsManager
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:925: error: cannot find symbol
                                                     @NonNull int[] grantResults) {
                                                      ^
  symbol:   class NonNull
  location: class ContactsManager
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java:239: error: cannot find symbol
    @NonNull
     ^
  symbol:   class NonNull
  location: class ContactsProvider
/Users/yamov/dev/react-native-app/node_modules/react-native-contacts/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsManager.java:921: error: cannot find symbol
        ActivityCompat.requestPermissions(currentActivity, new String[]{PERMISSION_READ_CONTACTS}, PERMISSION_REQUEST_CODE);
        ^
  symbol:   variable ActivityCompat
  location: class ContactsManager

so that's it, for RN 60+ you have to use android x and rnc 5.x will work then. https://facebook.github.io/react-native/blog/2019/07/03/version-60#androidx-support mystery solved

So, do versions 5.0.0+ only work on RN 60+ with Android X support?
If so, I guess it can make sense to add a note to the Readme (and release notes, since it was a breaking change?). At the moment that is not apparent at all 馃 .

I'll add a note. This is general react native details.

Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

caglardurmus picture caglardurmus  路  5Comments

uriva picture uriva  路  6Comments

fabriziomoscon picture fabriziomoscon  路  8Comments

dubbelnisse picture dubbelnisse  路  10Comments

kaminskypavel picture kaminskypavel  路  7Comments