当我尝试添加mongodb驱动程序实现到build.gradle的依赖块时,我得到了这个构建错误。我尝试降级并启用enableDexEnable来解决这个问题,但问题仍在继续。我几乎搜索互联网,但无法找到解决方案
> Task :app:mergeExtDexDebug
AGPBI: {"kind":"error","text":"Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.","sources":[{}],"tool":"D8"}
Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.
> Task :app:mergeExtDexDebug FAILED
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform bson-record-codec-4.8.1.jar (org.mongodb:bson-record-codec:4.8.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingNoClasspathTransform: C:\Users\user\.gradle\caches\modules-2\files-2.1\org.mongodb\bson-record-codec\4.8.1\339c92291f24acf896334ba9a2a5bf52fd462115\bson-record-codec-4.8.1.jar.
> Error while dexing.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
build.gradle page;
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.appname'
compileSdk 33
defaultConfig {
applicationId "com.example.appname"
minSdk 21
multiDexEnabled true
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
buildToolsVersion '33.0.1'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.mongodb:mongodb-driver-sync:4.8.2' //<-mongodb here
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
1条答案
按热度按时间q7solyqu1#
遇到同样的问题,将mongodb驱动程序版本降级到4.5.1,问题就消失了。
implementation 'org.mongodb:mongodb-driver-sync:4.5.1'
可能与Java版本和使用较新Java特性的Mongodb驱动程序有关(例如Java 16-〉中的记录功能)。不过我没有调查,因为降级在我的情况下工作得很好。