React Native 地图仅使用 apk 崩溃
React Native map crashes only with apk
我正在开发一个具有多个屏幕的 React 本机应用程序。它有一个加载反应本机地图的屏幕。当我 运行 react-native run-android
时,它在调试时工作得很好。但是当我创建签名的 apk 并将其安装在设备上时,其他屏幕工作正常,但是当我导航到带有地图的屏幕时,应用程序崩溃了。这只发生在 apk 上。所以,我也找不到理由。这就是我实现地图的方式。
/app/build.gradle/
dependencies {
implementation project(':react-native-linear-gradient')
implementation project(':react-native-orientation')
implementation project(':@react-native-community_geolocation')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:12.0.0'
implementation 'com.google.android.gms:play-services-maps:12.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-vector-icons')
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
android/build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.campaign">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true" tools:targetApi="28"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API KEY"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
代码
<MapView style={[styles.mapStyle, { flex: 1, width: this.state.mapWidth }]}
initialRegion={{
latitude: this.state.latitude,
longitude: this.state.longitude,
latitudeDelta: 0.1,
longitudeDelta: 0.1,
}}
provider={PROVIDER_GOOGLE}
onPress={this.onMapPress.bind(this)}
showsUserLocation={true}
followsUserLocation={true}
showsMyLocationButton={true}
showsCompass={true}
showsTraffic={true}
toolbarEnabled={true}
onMapReady={() => this.setState({ width: width - 1 })}
>
<Marker draggable
coordinate={{
latitude: this.state.latitude,
longitude: this.state.longitude,
}}
onDragEnd={(e) => this.setState({ x: e.nativeEvent.coordinate })}
/>
<Circle
center={{
latitude: this.state.latitude,
longitude: this.state.longitude,
}}
radius={this.state.radius}
fillColor='rgba(253, 48, 4,0.5)'
strokeColor='rgba(253, 48, 4,1)'
/>
来自 android 工作室的崩溃报告
2020-01-23 12:01:07.449 542-542/? E/ThermalBinder: mThermalService is NULL!
2020-01-23 12:01:07.449 542-542/? E/Thermal-daemon: Report temperature: [battery] temp :34 report_threshold:1
2020-01-23 12:01:12.123 413-490/? E/PF_IPA: [configValues:218] open file [/sys/class/thermal/thermal_zone1/mode] failed!
2020-01-23 12:01:12.454 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.457 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.485 1873-2988/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.490 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.491 1873-2988/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.502 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() start
2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() end
2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages start
2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages end
2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: startService end
2020-01-23 12:01:12.518 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.522 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.522 1873-2667/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.528 1873-2667/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.548 1873-7253/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.550 1873-7253/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.570 1873-2669/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.572 1873-2669/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.583 1873-2113/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.586 1873-2113/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.589 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.591 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.595 1873-2987/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.598 1873-2987/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:12.599 1478-1778/? E/HwSystemManager: LeisureTrafficSetting:result is empty
2020-01-23 12:01:12.649 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-5
2020-01-23 12:01:12.657 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-4
2020-01-23 12:01:12.677 1478-1778/? E/HwSystemManager: NotificationUtil:Month Warning Notification not create
2020-01-23 12:01:13.123 413-490/? E/PF_IPA: [resetValues:163] open file [/sys/class/thermal/thermal_zone1/mode] failed!
2020-01-23 12:01:13.502 413-490/? E/PF_IPA: [configValues:218] open file [/sys/class/thermal/thermal_zone1/mode] failed!
2020-01-23 12:01:14.444 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.447 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.473 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.476 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.476 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.478 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.498 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.503 413-490/? E/PF_IPA: [resetValues:163] open file [/sys/class/thermal/thermal_zone1/mode] failed!
2020-01-23 12:01:14.509 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() start
2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() end
2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages start
2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages end
2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: startService end
2020-01-23 12:01:14.529 1873-2670/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.532 1873-2670/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.544 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.547 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.558 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.560 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.571 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.574 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.578 1873-2989/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.581 1873-2989/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.583 1478-1778/? E/HwSystemManager: LeisureTrafficSetting:result is empty
2020-01-23 12:01:14.596 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.600 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:14.634 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-5
2020-01-23 12:01:14.644 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-4
2020-01-23 12:01:14.672 1478-1778/? E/HwSystemManager: NotificationUtil:Month Warning Notification not create
2020-01-23 12:01:14.870 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=4, toe=TOC/1263751200.000000
2020-01-23 12:01:14.870 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=4, toe=TOC/1263751200.000000
2020-01-23 12:01:14.876 28742-28742/? E/Lss: GNSS or predictor state for GPS SV 3 is bad, prediction not done
2020-01-23 12:01:15.082 2221-2312/? E/LogCollectService: illegal eventid
2020-01-23 12:01:15.083 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=32, toe=TOC/1263751200.000000
2020-01-23 12:01:15.083 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=32, toe=TOC/1263751200.000000
2020-01-23 12:01:15.089 28742-28742/? E/Lss: GNSS or predictor state for GPS SV 31 is bad, prediction not done
2020-01-23 12:01:15.230 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=9, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.230 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=9, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.235 28742-28742/? E/Lss: GNSS or predictor state for SV 8 is bad, prediction not done
2020-01-23 12:01:15.256 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=12, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.256 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=12, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.261 28742-28742/? E/Lss: GNSS or predictor state for SV 11 is bad, prediction not done
2020-01-23 12:01:15.369 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=19, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.369 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=19, toe=TOC, gps_secs=1263748518.000000
2020-01-23 12:01:15.374 28742-28742/? E/Lss: GNSS or predictor state for SV 18 is bad, prediction not done
2020-01-23 12:01:15.448 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 28 is invalid.
2020-01-23 12:01:15.448 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 28 is invalid.
2020-01-23 12:01:15.453 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 27 is bad, prediction not done
2020-01-23 12:01:15.457 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 19 is invalid.
2020-01-23 12:01:15.457 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 19 is invalid.
2020-01-23 12:01:15.462 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 18 is bad, prediction not done
2020-01-23 12:01:15.465 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 16 is invalid.
2020-01-23 12:01:15.465 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 16 is invalid.
2020-01-23 12:01:15.471 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 15 is bad, prediction not done
2020-01-23 12:01:15.631 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: prediction disabled for gnss=3, svId=2, toe=TOC/1263747614.000000
2020-01-23 12:01:15.631 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: prediction disabled for gnss=3, svId=2, toe=TOC/1263747614.000000
2020-01-23 12:01:15.636 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 1 is bad, prediction not done
2020-01-23 12:01:16.757 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:16.764 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null
2020-01-23 12:01:17.455 542-542/? E/Thermal-daemon: [battery] temp_new :33 temp_old :34
2020-01-23 12:01:17.456 542-542/? E/ThermalBinder: mThermalService is NULL!
2020-01-23 12:01:17.456 542-542/? E/Thermal-daemon: Report temperature: [battery] temp :33 report_threshold:1
2020-01-23 12:01:17.458 542-542/? E/Thermal-daemon: [ap] temp_new :40 temp_old :39
2020-01-23 12:01:17.459 542-542/? E/ThermalBinder: mThermalService is NULL!
2020-01-23 12:01:17.459 542-542/? E/Thermal-daemon: Report temperature: [ap] temp :40 report_threshold:1
我做错了什么吗?我应该怎么做才能让它发挥作用?任何帮助将不胜感激。
您必须将此代码块添加到 android/build。gradle 并检查您的版本
buildscript {
ext {
...
googlePlayServicesVersion = "16.1.0" // or set latest version
androidMapsUtilsVersion = "0.5+"
}
}
您必须将此代码块添加到 AndroidManifest.xml
<application>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
如果您在 2022 年遇到此问题,请确保:
- 在您的 app/build.gradle 中添加最新的 Google 播放服务版本。您可以通过检查:here 并搜索
gms:play-services-maps:
来找到最新的 playServicesVersion。对我来说,我必须这样做:
dependecies {
...
implementation 'com.google.android.gms:play-services-base:18.0.1'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
...
}
- 将您的 Google 地图 API 密钥添加到
android/app/src/main/AndroidManifest.xml
文件的 <application />
块下。例如:
<meta-data android:name="com.google.android.geo.API_KEY" android:value="your-API-key-goes-here"/>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
清理并重建您的项目,然后在设备上试用。
我正在开发一个具有多个屏幕的 React 本机应用程序。它有一个加载反应本机地图的屏幕。当我 运行 react-native run-android
时,它在调试时工作得很好。但是当我创建签名的 apk 并将其安装在设备上时,其他屏幕工作正常,但是当我导航到带有地图的屏幕时,应用程序崩溃了。这只发生在 apk 上。所以,我也找不到理由。这就是我实现地图的方式。
/app/build.gradle/
dependencies {
implementation project(':react-native-linear-gradient')
implementation project(':react-native-orientation')
implementation project(':@react-native-community_geolocation')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:12.0.0'
implementation 'com.google.android.gms:play-services-maps:12.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-vector-icons')
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
android/build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.campaign">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true" tools:targetApi="28"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API KEY"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
代码
<MapView style={[styles.mapStyle, { flex: 1, width: this.state.mapWidth }]}
initialRegion={{
latitude: this.state.latitude,
longitude: this.state.longitude,
latitudeDelta: 0.1,
longitudeDelta: 0.1,
}}
provider={PROVIDER_GOOGLE}
onPress={this.onMapPress.bind(this)}
showsUserLocation={true}
followsUserLocation={true}
showsMyLocationButton={true}
showsCompass={true}
showsTraffic={true}
toolbarEnabled={true}
onMapReady={() => this.setState({ width: width - 1 })}
>
<Marker draggable
coordinate={{
latitude: this.state.latitude,
longitude: this.state.longitude,
}}
onDragEnd={(e) => this.setState({ x: e.nativeEvent.coordinate })}
/>
<Circle
center={{
latitude: this.state.latitude,
longitude: this.state.longitude,
}}
radius={this.state.radius}
fillColor='rgba(253, 48, 4,0.5)'
strokeColor='rgba(253, 48, 4,1)'
/>
来自 android 工作室的崩溃报告
2020-01-23 12:01:07.449 542-542/? E/ThermalBinder: mThermalService is NULL! 2020-01-23 12:01:07.449 542-542/? E/Thermal-daemon: Report temperature: [battery] temp :34 report_threshold:1 2020-01-23 12:01:12.123 413-490/? E/PF_IPA: [configValues:218] open file [/sys/class/thermal/thermal_zone1/mode] failed! 2020-01-23 12:01:12.454 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.457 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.485 1873-2988/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.490 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.491 1873-2988/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.502 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() start 2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() end 2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages start 2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages end 2020-01-23 12:01:12.510 2986-2986/? E/Mms_TXM_SVC: startService end 2020-01-23 12:01:12.518 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.522 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.522 1873-2667/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.528 1873-2667/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.548 1873-7253/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.550 1873-7253/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.570 1873-2669/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.572 1873-2669/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.583 1873-2113/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.586 1873-2113/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.589 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.591 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.595 1873-2987/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.598 1873-2987/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:12.599 1478-1778/? E/HwSystemManager: LeisureTrafficSetting:result is empty 2020-01-23 12:01:12.649 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-5 2020-01-23 12:01:12.657 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-4 2020-01-23 12:01:12.677 1478-1778/? E/HwSystemManager: NotificationUtil:Month Warning Notification not create 2020-01-23 12:01:13.123 413-490/? E/PF_IPA: [resetValues:163] open file [/sys/class/thermal/thermal_zone1/mode] failed! 2020-01-23 12:01:13.502 413-490/? E/PF_IPA: [configValues:218] open file [/sys/class/thermal/thermal_zone1/mode] failed! 2020-01-23 12:01:14.444 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.447 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.473 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.476 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.476 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.478 1873-2103/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.498 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.503 413-490/? E/PF_IPA: [resetValues:163] open file [/sys/class/thermal/thermal_zone1/mode] failed! 2020-01-23 12:01:14.509 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() start 2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: isSecondaryUser() end 2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages start 2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: removeCallbacksAndMessages end 2020-01-23 12:01:14.516 2986-2986/? E/Mms_TXM_SVC: startService end 2020-01-23 12:01:14.529 1873-2670/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.532 1873-2670/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.544 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.547 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.558 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.560 1873-1886/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.571 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.574 1873-16600/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.578 1873-2989/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.581 1873-2989/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.583 1478-1778/? E/HwSystemManager: LeisureTrafficSetting:result is empty 2020-01-23 12:01:14.596 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.600 1873-16376/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:14.634 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-5 2020-01-23 12:01:14.644 1478-1778/? E/HwSystemManager: CommonMethodUtil:No package name to uid:-4 2020-01-23 12:01:14.672 1478-1778/? E/HwSystemManager: NotificationUtil:Month Warning Notification not create 2020-01-23 12:01:14.870 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=4, toe=TOC/1263751200.000000 2020-01-23 12:01:14.870 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=4, toe=TOC/1263751200.000000 2020-01-23 12:01:14.876 28742-28742/? E/Lss: GNSS or predictor state for GPS SV 3 is bad, prediction not done 2020-01-23 12:01:15.082 2221-2312/? E/LogCollectService: illegal eventid 2020-01-23 12:01:15.083 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=32, toe=TOC/1263751200.000000 2020-01-23 12:01:15.083 28742-28742/? E/[EELIB] GpsOrbitPredictor: initialize: prediction disabled for gnss=1, svId=32, toe=TOC/1263751200.000000 2020-01-23 12:01:15.089 28742-28742/? E/Lss: GNSS or predictor state for GPS SV 31 is bad, prediction not done 2020-01-23 12:01:15.230 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=9, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.230 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=9, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.235 28742-28742/? E/Lss: GNSS or predictor state for SV 8 is bad, prediction not done 2020-01-23 12:01:15.256 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=12, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.256 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=12, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.261 28742-28742/? E/Lss: GNSS or predictor state for SV 11 is bad, prediction not done 2020-01-23 12:01:15.369 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=19, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.369 28742-28742/? E/[EELIB] GlonassOrbitPredictor: initialize: prediction disabled for gnss=2, svId=19, toe=TOC, gps_secs=1263748518.000000 2020-01-23 12:01:15.374 28742-28742/? E/Lss: GNSS or predictor state for SV 18 is bad, prediction not done 2020-01-23 12:01:15.448 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 28 is invalid. 2020-01-23 12:01:15.448 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 28 is invalid. 2020-01-23 12:01:15.453 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 27 is bad, prediction not done 2020-01-23 12:01:15.457 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 19 is invalid. 2020-01-23 12:01:15.457 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 19 is invalid. 2020-01-23 12:01:15.462 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 18 is bad, prediction not done 2020-01-23 12:01:15.465 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 16 is invalid. 2020-01-23 12:01:15.465 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: Rejects an ephemeris because SVID number 16 is invalid. 2020-01-23 12:01:15.471 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 15 is bad, prediction not done 2020-01-23 12:01:15.631 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: prediction disabled for gnss=3, svId=2, toe=TOC/1263747614.000000 2020-01-23 12:01:15.631 28742-28742/? E/[EELIB] BeidouOrbitPredictor: initialize: prediction disabled for gnss=3, svId=2, toe=TOC/1263747614.000000 2020-01-23 12:01:15.636 28742-28742/? E/Lss: GNSS or predictor state for Beidou SV 1 is bad, prediction not done 2020-01-23 12:01:16.757 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:16.764 1873-1873/? E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 2020-01-23 12:01:17.455 542-542/? E/Thermal-daemon: [battery] temp_new :33 temp_old :34 2020-01-23 12:01:17.456 542-542/? E/ThermalBinder: mThermalService is NULL! 2020-01-23 12:01:17.456 542-542/? E/Thermal-daemon: Report temperature: [battery] temp :33 report_threshold:1 2020-01-23 12:01:17.458 542-542/? E/Thermal-daemon: [ap] temp_new :40 temp_old :39 2020-01-23 12:01:17.459 542-542/? E/ThermalBinder: mThermalService is NULL! 2020-01-23 12:01:17.459 542-542/? E/Thermal-daemon: Report temperature: [ap] temp :40 report_threshold:1
我做错了什么吗?我应该怎么做才能让它发挥作用?任何帮助将不胜感激。
您必须将此代码块添加到 android/build。gradle 并检查您的版本
buildscript {
ext {
...
googlePlayServicesVersion = "16.1.0" // or set latest version
androidMapsUtilsVersion = "0.5+"
}
}
您必须将此代码块添加到 AndroidManifest.xml
<application>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
如果您在 2022 年遇到此问题,请确保:
- 在您的 app/build.gradle 中添加最新的 Google 播放服务版本。您可以通过检查:here 并搜索
gms:play-services-maps:
来找到最新的 playServicesVersion。对我来说,我必须这样做:
dependecies {
...
implementation 'com.google.android.gms:play-services-base:18.0.1'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
...
}
- 将您的 Google 地图 API 密钥添加到
android/app/src/main/AndroidManifest.xml
文件的<application />
块下。例如:
<meta-data android:name="com.google.android.geo.API_KEY" android:value="your-API-key-goes-here"/>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
清理并重建您的项目,然后在设备上试用。