我有一个重复的类错误,我似乎无法修复。我尝试了几天,但找不到解决方案。我正在使用 MapboxSDK 并尝试实现最新版本
implementation ('com.mapbox.maps:android:11.7.1')
,我的错误如下:
在模块 common-24.7.1.aar -> jetified-common-24.7.1-runtime (com.mapbox.common:common:24.7.1) 和 mapbox 中找到重复的类 com.mapbox.android.core.permissions.PermissionsListener -android-core-1.4.1.aar -> jetified-mapbox-android-core-1.4.1-runtime (com.mapbox.mapboxsdk:mapbox-android-core:1.4.1)
重复类 com.mapbox.android.core.permissions.PermissionsManager 在模块 common-24.7.1.aar -> jetified-common-24.7.1-runtime 中找到 (com.mapbox.common:common:24.7.1) 和 mapbox-android-core-1.4.1.aar -> jetified-mapbox-android-core-1.4.1-运行时 (com.mapbox.mapboxsdk:mapbox-android-core:1.4.1)
我还尝试排除 com.mapbox.common 或 mapbox-android-core,在排除其中之一后,我收到以下错误,表明类丢失,可能是通过排除:
FATAL EXCEPTION: main
Process: com.b.project, PID: 5138
java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.ClassNotFoundException: com.mapbox.maps.loader.MapboxMapsInitializer
at android.app.ActivityThread.installProvider(ActivityThread.java:8291)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7801)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7482)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2415)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8699)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: androidx.startup.StartupException: java.lang.ClassNotFoundException: com.mapbox.maps.loader.MapboxMapsInitializer
at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:242)
at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2644)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2613)
at android.app.ActivityThread.installProvider(ActivityThread.java:8286)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.mapbox.maps.loader.MapboxMapsInitializer
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:607)
at java.lang.Class.forName(Class.java:512)
at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:224)
... 16 more
Caused by: java.lang.ClassNotFoundException: com.mapbox.maps.loader.MapboxMapsInitializer
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:1276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:621)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
... 20 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/common/BaseMapboxInitializer;
... 20 more
2024-11-07 22:36:19.387 5138-5138 AndroidRuntime E Cause by: java.lang.ClassNotFoundException: Didn't find class "com.mapbox.common.BaseMapboxInitializer"
如果您需要更多信息,请告诉我。我希望有人知道如何解决它。
编辑:
这是我的应用程序级别 build.gradle.file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
android {
compileSdk 34
defaultConfig {
multiDexEnabled true
applicationId "com.corp.testmapboxapp"
minSdkVersion 26
targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.testY.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
vectorDrawables.useSupportLibrary = true
}
buildFeatures {
viewBinding = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
namespace 'com.corp.testmapboxapp'
buildFeatures {
buildConfig true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':core')
implementation project(':chat')
// Android Libs and UI
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'androidx.vectordrawable:vectordrawable:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.8.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.8.3'
// Mapbox dependencies
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.0.0'
// Look for mapbox sdk in core
// implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building-v7:0.5.0'
// implementation dependenciesList.mapboxServices
// Mapbox plugins
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.10.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-cluster-utils:0.1.0'
// implementation dependenciesList.mapboxPluginBuilding
// implementation dependenciesList.mapboxPluginPlaces
// implementation dependenciesList.mapboxPluginLocalization
// implementation dependenciesList.mapboxPluginTraffic
// implementation dependenciesList.mapboxPluginMarkerView
// implementation dependenciesList.mapboxPluginAnnotation
// implementation dependenciesList.mapboxPluginScalebar
// Timeline
implementation 'com.github.vipulasri:timelineview:1.1.5'
// Floating action menu / Floating action buttons
implementation 'com.github.clans:fab:1.6.4'
// Facebook API
implementation 'com.facebook.android:facebook-login:5.15.3'
// Google API OAuth
implementation "androidx.credentials:credentials:1.3.0"
implementation "androidx.credentials:credentials-play-services-auth:1.3.0"
implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"
// SMS API
implementation 'com.google.android.gms:play-services-auth:21.2.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:18.1.0'
// Google Places API
implementation 'com.google.android.libraries.places:places:4.0.0'
implementation 'androidx.credentials:credentials:1.3.0'
implementation 'com.google.android.libraries.identity.googleid:googleid:1.1.1'
// Google Maps API
// implementation 'com.google.maps.android:android-maps-utils:0.5'
// implementation 'com.google.android.gms:play-services-maps:17.0.1'
// Testing
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.6.1'
androidTestImplementation 'com.android.support.test:rules:1.2.0'
// androidTestImplementation 'org.mockito:mockito-core:2.25.0'
// androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.25.0'
// androidTestImplementation 'androidx.test:runner:1.2.0'
// GSON
implementation 'com.google.code.gson:gson:2.10.1'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
// Kotlin dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// socket.io dependencies
// implementation 'com.github.nkzawa:socket.io-client:0.6.0'
// Bug handler
implementation 'cat.ereza:customactivityoncrash:2.2.0'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'jp.wasabeef:picasso-transformations:2.4.0'
// Calendar
// Calendar added in core, look there
// implementation 'com.github.kizitonwose:CalendarView:0.3.2'
implementation 'androidx.core:core-ktx:1.13.1'
// Emoji
implementation 'com.vanniktech:emoji-google:0.6.0'
// Multidex for too many methods in file
implementation 'com.android.support:multidex:1.0.3'
// Dagger 2
api 'com.google.dagger:dagger:2.28.3'
kapt 'com.google.dagger:dagger-compiler:2.20'
}
repositories {
mavenCentral()
jcenter {}
}
有人向我指出你可以在 build.gradle 应用程序级别执行this
configurations {
all {
exclude group: 'com.mapbox.common', module: 'common'
}
}