错误:";程序类型已存在:androidx.versionedparcelable.CustomVersionedParcelable";
我遇到以下错误-->错误:程序类型已存在:androidx.versionedparcelable.CustomVersionedParcelable 当我单击“生成错误”时,它会显示以下内容:错误:";程序类型已存在:androidx.versionedparcelable.CustomVersionedParcelable";,android,gradle,error-handling,android-gradle-plugin,runtime-error,Android,Gradle,Error Handling,Android Gradle Plugin,Runtime Error,我遇到以下错误-->错误:程序类型已存在:androidx.versionedparcelable.CustomVersionedParcelable 当我单击“生成错误”时,它会显示以下内容: AGPBI: {"kind":"error","text":"Program type already present: androidx.versionedparcelable.CustomVersionedParcelable","sources":[{}],"tool":"D8"} :app:tr
AGPBI: {"kind":"error","text":"Program type already present: androidx.versionedparcelable.CustomVersionedParcelable","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
我不明白是什么原因导致了这个问题,因为我正在使用Parcelable library,但从未导致过这种类型的错误
这是我项目的gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.package.name"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Lottie
implementation 'com.airbnb.android:lottie:2.8.0'
//Gson
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//Dagger 2
implementation 'com.google.dagger:dagger:2.18'
implementation "com.google.dagger:dagger-android-support:2.18"
annotationProcessor 'com.google.dagger:dagger-compiler:2.18'
//Asyncjob
implementation 'com.arasthel:asyncjob-library:1.0.3'
//Butterknife
implementation 'com.jakewharton:butterknife:9.0.0-rc1'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
}
这是我在Android Studio中的构建面板
有什么想法吗??谢谢
更新(2018年1月12日)
我想我已经找到了这个问题的答案。我听说所有的支持库都将迁移到androidx库
因此,我阅读了Android开发者文档,并解释了如何将所有的Android.support.
库迁移到androidx
您只需进入Android Studio,并从菜单栏将重构>>迁移到AndroidX
这是有关详细信息的链接-->请将其添加到
gradle.properties
文件中
android.useAndroidX=true
android.enableJetifier=true
问题: 错误:程序类型已存在: androidx.versionedparcelable.CustomVersionedParcelable 解决方案:将其添加到顶部的gradle.properties文件中
android.useAndroidX=true
android.enableJetifier=true
您的项目将在构建期间迁移到androidx,不会出现任何错误经过长时间的搜索,只有此解决方案对我有效 Android Studio菜单->构建->重建项目
来源。这几乎就是我在更新中解释的解决方案,但我的解决方案是由Android Studio自动生成的。顺便说一句,谢谢!如果我们因为与其他库冲突而不想使用AndroidX怎么办?@Mayoul看到我的答案了。在使用
迁移到AndroidX
选项后,重建对我来说已经足够好了。以上应该是选择的答案!为我工作,我尝试了很多东西~。非常感谢。