Richou / react-native-android-location-enabler

Display a GoogleMap like android popup to ask for user to enable location services if disabled
MIT License
209 stars 52 forks source link

Error: Cannot find symbol @NonNull Task, v1.2.0 #30

Open xempie opened 5 years ago

xempie commented 5 years ago

I recently updated react native and RN android location enabler but I get this error when I run the project:

=========================================

Task :react-native-android-location-enabler:compileDebugJavaWithJavac FAILED ...\node_modules\react-native-android-location-enabler\android\src\main\java\com\heanoria\library\reactnative\locationenabler\RNAndroidLocationEnablerModule.java:8: error: package androidx.annotation does not exist import androidx.annotation.NonNull; ^ ...\node_modules\react-native-android-location-enabler\android\src\main\java\com\heanoria\library\reactnative\locationenabler\RNAndroidLocationEnablerModule.java:98: error: cannot find symbol public void onComplete(@NonNull Task task) { ^ symbol: class NonNull location: class RNAndroidLocationEnablerModule 2 errors

FAILURE: Build failed with an exception.

"react": "^16.10.1", "react-native": "0.57.8", "react-native-android-location-enabler": "^1.2.0",

Anyone knows how to fix it?

je-martinez commented 4 years ago

This works for me:

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"

Extra: At ProjectFolder/android delete .idea folder in case that cache it's causing a trouble.

Original Solution Source: At Pavan Garre response: https://stackoverflow.com/questions/40380519/error-package-com-android-annotations-does-not-exist

Richou commented 4 years ago

For versions ReactNative < 0.60.0, please use react-native-android-location-enabler@1.1.0