在使用android sdk 28进行编译之前,我已经正确实现了mapbox,现在mapbox仅在发布模式下会崩溃,因为我的minifyEnabled为true。如果将其设置为false,则不会崩溃。 例外是
Binary XML Error inflating com.mapbox.mapboxsdk.maps.MapView.
我在片段上使用mapbox,然后调用
Mapbox.getInstance(getContext(), "TOKEN")
在onCreateView方法中扩大视图之前。即使如此,同样的问题。
我认为这是一个难题,那就是
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.31.0'
}
}
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
android {
signingConfigs {
debug {
keyAlias 'ewhfpiqwufgqeifbqeifb'
keyPassword 'dbhedeiqlgdqoiefqwouf'
}
release {
}
}
compileSdkVersion 28
defaultConfig {
applicationId "widjpewoqhfqiwfhuw"
minSdkVersion 19
targetSdkVersion 27
versionCode 65
versionName "1.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled true
ext.enableCrashlytics = true
useProguard false
}
debug {
debuggable true
applicationIdSuffix ".debug"
minifyEnabled false
useProguard false
ext.enableCrashlytics = true
}
}
flavorDimensions "release", "debug"
productFlavors {
debugFlavor {
dimension "debug"
}
releaseFlavor {
dimension "release"
applicationIdSuffix ""
versionNameSuffix ""
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation ('androidx.test.espresso:espresso-core:3.1.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.baoyz.swipemenulistview:library:1.3.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.5.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0'){
transitive=true
}
implementation 'com.hbb20:ccp:2.2.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.android.volley:volley:1.1.0'
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
关于崩溃的其他信息:
Exception in onDidFinishLoadingStyle
java.lang.NullPointerException: throw with null exception
Abort message: 'terminating with uncaught exception of type
jni::PendingJavaException'
/data/app/mypkg-
qtZprFdEiYN4aOjj_lCtiA==/lib/arm64/libmapbox-gl.so
答案 0 :(得分:0)
将minifyEnabled设置为true时,它将启用代码收缩,混淆和优化,以删除未使用的类。
使用proguard解决此问题:
https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/proguard-rules.pro