自从我安装react-native-community/geolocation
以来,我的应用一直在启动时停止运行,并且在两个控制台上的模拟器中都没有看到任何错误。如何调试呢?
我所做的只是运行npm install @react-native-community/geolocation --save
并将<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
添加到AndroidManifest.xml。
我试图重新启动VS Code和整个PC。
我删除了node_modules并再次运行npm install
。
构建成功。
我已将更改恢复为安装前的状态,但应用程序仍保持停止状态。在模拟器和物理设备上也会发生同样的情况。
编辑1:我从磁盘上删除了存储库,并再次为项目运行git clone
,这使我可以运行项目,但仍然没有地理位置。我还尝试安装Agontuk/react-native-geolocation-service
,但它会导致相同的问题,并且还原更改并不能解决问题。
在我运行npm install Agontuk/react-native-geolocation-service
和npx react-native run-android
之后,我在控制台中看到了这一点,应用开始在运行时停止:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1139 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
> Task :react-native-community_async-storage:compileDebugJavaWithJavac
> Task :react-native-gesture-handler:compileDebugJavaWithJavac
> Task :react-native-geolocation-service:compileDebugJavaWithJavac
> Task :react-native-reanimated:compileDebugJavaWithJavac
> Task :react-native-screens:compileDebugJavaWithJavac
> Task :app:compileDebugJavaWithJavac
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libfolly_json.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libnative-filters.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libglog_init.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libhermes-inspector.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libflipper.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
> Task :app:stripDebugDebugSymbols
Compatible side by side NDK version was not found.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libyoga.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libevent-2.1.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libimagepipeline.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libevent_core-2.1.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libimagepipeline.so' due to missing strip tool for ABI 'X86'.
Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libhermes-executor-release.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libevent_core-2.1.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libfolly_json.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libjsc.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libglog_init.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libjsinspector.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libnative-filters.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libfb.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libjscexecutor.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libflipper.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libfb.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libjscexecutor.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libevent_extra-2.1.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libhermes-executor-release.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libnative-filters.so' due to missing strip tool for ABI
'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libhermes-executor-release.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libimagepipeline.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libglog_init.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libevent_extra-2.1.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libjsc.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libfb.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libflipper.so' due to missing strip tool for ABI 'X86_64'.
Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libhermes-executor-debug.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libnative-filters.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libhermes-executor-debug.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libevent-2.1.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libhermes-executor-debug.so' due to missing strip tool for
ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libnative-imagetranscoder.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libfolly_json.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libreactnativeblob.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libfolly_json.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libyoga.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libglog_init.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libreactnativeblob.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libnative-imagetranscoder.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libfb.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libreactnativeblob.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libhermes-executor-debug.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libyoga.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libjsinspector.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libreactnativejni.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libjscexecutor.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libnative-imagetranscoder.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libreactnativejni.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libyoga.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libjsc.so' due to missing strip tool for ABI 'X86'. Packaging
it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libhermes-executor-release.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libjsc.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libhermes-inspector.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libfolly_futures.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libfolly_futures.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libevent-2.1.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libjsijniprofiler.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libevent_extra-2.1.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libfolly_futures.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libevent_extra-2.1.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libflipper.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libhermes-inspector.so' due to missing strip tool for
ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libjsinspector.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libnative-imagetranscoder.so' due to missing strip tool
for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libfolly_futures.so' due to missing strip tool for ABI 'X86'.
Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86_64\libevent-2.1.so' due to missing strip tool for ABI 'X86_64'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libevent_core-2.1.so' due to missing strip tool for ABI
'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libjscexecutor.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libjsinspector.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libreactnativejni.so' due to missing strip tool for ABI
'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libreactnativejni.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libhermes-inspector.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\armeabi-v7a\libreactnativeblob.so' due to missing strip tool for ABI 'ARMEABI_V7A'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\x86\libevent_core-2.1.so' due to missing strip tool for ABI 'X86'. Packaging it as is.
Unable to strip library 'C:\pathToApp\android\app\build\intermediates\merged_native_libs\debug\out\lib\arm64-v8a\libimagepipeline.so' due to missing strip tool for ABI 'ARM64_V8A'. Packaging it as is.
> Task :app:installDebug
03:52:58 V/ddms: execute: running am get-config
03:52:58 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
03:52:58 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Pixel_3a_API_28(AVD) - 9' for app:debug
03:52:58 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
03:52:58 D/Device: Uploading file onto device 'emulator-5554'
03:52:58 D/ddms: Reading file permision of C:\pathToApp\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
03:52:58 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
03:52:59 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
03:52:59 V/ddms: execute: returning
03:52:59 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
03:52:59 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
03:52:59 V/ddms: execute: returning
Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 31s
187 actionable tasks: 51 executed, 136 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.appname/.MainActivity }
答案 0 :(得分:1)
首先, Android API> = 23需要执行其他步骤进行检查。因此,除了添加之外,您还必须使用PermissionsAndroid API
来请求ACCESS_FINE_LOCATION
权限
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
文件中的AndroidManifest.xml
。您可以通过以下方式请求许可:
将这些行添加到AndroidManifest.xml
文件中。
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
然后您的屏幕代码将如下所示:
import { View, Text, PermissionsAndroid } from 'react-native';
export default class TestScreen extends React.Component {
async componentDidMount() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Example App',
'message': 'Example App access to your location '
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the location")
alert("You can use the location");
} else {
console.log("location permission denied")
alert("Location permission denied");
}
} catch (err) {
console.warn(err)
}
}
render() {
return (
<View>
<Text>Test Screen</Text>
</View>
);
}
}