Kotlin项目集成Mapbox时libc++_shared.so冲突问题求助
问题描述
已按Mapbox官方文档配置项目级build.gradle,配置内容如下:
allprojects { repositories { gradlePluginPortal() google() mavenCentral() maven { url = uri("https://api.mapbox.com/downloads/v2/releases/maven") // Do not change the username below. It should always be "mapbox" (not your username). credentials.username = "mapbox" // Use the secret token stored in gradle.properties as the password credentials.password = providers.gradleProperty("MAPBOX_DOWNLOADS_TOKEN").get() authentication { basic(BasicAuthentication) } } } }
但构建时触发libc++_shared.so文件冲突,提示存在两个路径的该文件:
- C:\Users\johanke.gradle\caches\transforms-3\b8c059599cd20d9173eec748d219fd64\transformed\jetified-pdfium-android-1.9.0\jni\arm64-v8a\libc++_shared.so
- C:\Users\johanke.gradle\caches\transforms-3\1d2cd570d97102124d90dc5c2939e546\transformed\jetified-common-24.3.1\jni\arm64-v8a\libc++_shared.so
尝试在packagingOptions中排除各架构下的libc++_shared.so,配置如下:
android { ... packagingOptions { exclude 'lib/arm64-v8a/libc++_shared.so' exclude 'lib/x86_64/libc++_shared.so' exclude 'lib/x86/libc++_shared.so' exclude 'lib/armeabi-v7a/libc++_shared.so' } ... }
编译虽能成功,但应用启动后直接崩溃。推测是依赖冲突导致,希望在保留所有依赖的前提下解决该问题。
项目依赖列表
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10" implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.fragment:fragment-ktx:1.6.2' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation "androidx.room:room-rxjava2:2.6.1" implementation "androidx.gridlayout:gridlayout:1.0.0" implementation "androidx.legacy:legacy-support-v4:1.0.0" // Compose implementation "androidx.compose.runtime:runtime:1.5.4" implementation "androidx.compose.runtime:runtime-livedata:1.5.4" implementation "androidx.compose.runtime:runtime-rxjava2:1.5.4" //Retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' //Lifecycle implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.2" implementation "androidx.lifecycle:lifecycle-common-java8:2.6.2" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //Kotlin Coroutines implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1" //Hilt implementation 'com.google.dagger:hilt-android:2.48.1' implementation 'androidx.viewpager2:viewpager2:1.0.0' kapt 'com.google.dagger:hilt-android-compiler:2.48.1' //Room implementation "androidx.room:room-runtime:2.6.0" implementation "androidx.room:room-ktx:2.6.0" kapt "androidx.room:room-compiler:2.6.0" //Navigation implementation "androidx.navigation:navigation-fragment-ktx:2.7.4" implementation "androidx.navigation:navigation-ui-ktx:2.7.4" implementation 'com.google.android.gms:play-services-maps:18.2.0' //Glide implementation 'com.github.bumptech.glide:glide:4.15.1' kapt 'com.github.bumptech.glide:compiler:4.15.1' //Timber implementation 'com.jakewharton.timber:timber:5.0.1' // okHttp3 用于文档下载 implementation("com.squareup.okhttp3:okhttp:4.10.0") implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' // Google定位服务 implementation 'com.google.android.gms:play-services-location:21.0.1' // JWT implementation 'io.jsonwebtoken:jjwt-api:0.11.5' implementation 'io.jsonwebtoken:jjwt-impl:0.11.5' implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5' // PDF implementation 'com.itextpdf:itextpdf:5.5.13.2' implementation ('com.github.barteksc:android-pdf-viewer:3.2.0-beta.1') // Firebase依赖 // 导入Firebase平台BoM implementation platform('com.google.firebase:firebase-bom:31.2.3') implementation 'com.google.firebase:firebase-crashlytics-ktx' // Crashlytics implementation 'com.google.firebase:firebase-config-ktx' // 远程配置 implementation 'com.google.firebase:firebase-analytics-ktx' // 统计分析 implementation 'com.google.firebase:firebase-perf-ktx' // 性能监控 // 推送通知Worker implementation "androidx.work:work-runtime:2.8.1" // Picasso implementation 'com.squareup.picasso:picasso:2.5.2' // 轮播组件 implementation 'com.synnapps:carouselview:0.1.4' // 骨架加载器 implementation "com.facebook.shimmer:shimmer:0.5.0" // 加密SharedPreference implementation "androidx.security:security-crypto:1.1.0-alpha06" // Mapbox implementation 'com.mapbox.maps:android:11.3.1' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
额外信息
- Kotlin版本:1.9.10
- Gradle JDK:JetBrains Runtime Version 17.0.10
内容的提问来源于stack exchange,提问作者johan.krrn
相关产品推荐
相关产品推荐

