skip to Main Content

I’m trying to build my apk & I’m getting this error while building my release apk in react native. Is there any way to fix this react-native-location error?

2

Answers


  1. Chosen as BEST ANSWER

    I was facing this issue while building my apk in react native. To solve this issue you need to:

    1- cd android and then ./gradlew clean
    2- then in your root directory run yarn jetify or npx jetify
    

  2. In my project, with React Native 0.71.0, I got this error due to package android.support.annotation. So I followed the instructions provided here and added a patch (trough patch-package) to update the react-native-location source code. So here is the final result, under patches/react-native-location+2.5.0.patch

    index 6dbdd3b..1a4de95 100644
    --- a/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/RNPlayServicesLocationProvider.java
    +++ b/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/RNPlayServicesLocationProvider.java
    @@ -6,8 +6,9 @@ import android.content.Intent;
     import android.content.IntentSender;
     import android.content.pm.PackageManager;
     import android.location.Location;
    -import android.support.annotation.NonNull;
    -import android.support.v4.app.ActivityCompat;
    +
    +import androidx.annotation.NonNull;
    +import androidx.core.app.ActivityCompat;
     
     import com.facebook.react.bridge.Arguments;
     import com.facebook.react.bridge.Promise;
    diff --git a/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/Utils.java b/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/Utils.java
    index 6059fdc..b66dd63 100644
    --- a/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/Utils.java
    +++ b/node_modules/react-native-location/android/src/main/java/com/github/reactnativecommunity/location/Utils.java
    @@ -2,7 +2,7 @@ package com.github.reactnativecommunity.location;
     
     import android.location.Location;
     import android.os.Build;
    -import android.support.annotation.Nullable;
    +import androidx.annotation.Nullable;
     
     import com.facebook.react.bridge.Arguments;
     import com.facebook.react.bridge.ReactApplicationContext;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search