任务:react-native-location:compileDebugJavaWithJavac 在构建 apk 时失败

问题描述 投票:0回答:2

我正在尝试构建我的 apk 并且在本机反应中构建我的发布 apk 时遇到此错误。有什么办法可以修复这个 react-native-location 错误吗?

react-native
2个回答
1
投票

我在构建我的 apk 时遇到了这个问题。要解决此问题,您需要:

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

0
投票

在我的项目中,使用 React Native 0.71.0,由于包 android.support.annotation,我得到了这个错误。所以我按照 here 提供的说明添加了一个补丁(通过补丁包)来更新 react-native-location 源代码。所以这是最终结果,在

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;
© www.soinside.com 2019 - 2024. All rights reserved.