Swe*_*gar 44 chat gradle androidx
我正在开发新闻应用程序,但从Gradle控制台中收到以下错误
(androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class androidx.core.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class androidx.core.internal.package-info found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0)
Duplicate class androidx.versionedparcelable.CustomVersionedParcelable found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.NonParcelField found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.ParcelField found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.ParcelImpl found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.ParcelImpl$1 found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.ParcelUtils found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcel found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcel$1 found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcel$ParcelException found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelParcel found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelStream found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelStream$FieldBuffer found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelStream$InputBuffer found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelable found in modules classes.jar (androidx.versionedparcelable:versionedparcelable:1.0.0) and classes.jar (com.android.support:versionedparcelable:28.0.0)
Duplicate class androidx.versionedparcelable.VersionedParcelize found in modules class
Run Code Online (Sandbox Code Playgroud)
在我的app.gradle下面
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.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'
implementation 'com.github.bassaer:chatmessageview:2.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Run Code Online (Sandbox Code Playgroud)
nic*_*e j 93
您可以在gradle.properties
文件中添加以下几行:
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
Pab*_*nso 20
将这些行添加到 gradle.properties 文件可以解决“重复类”错误:
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
但是,这在我的项目中产生了新的错误:
“包 android.support.annotation 不存在”
“找不到符号类片段”
“包 android.support.v4.content 不存在”
“程序类型已经存在”
等等。
但是,重构对我有用:
Migrate your project to AndroidX by selecting Refactor >
"Migrate to AndroidX" from the menu bar.
Select Build > Clean project
Restore Android Studio
Run Code Online (Sandbox Code Playgroud)
现在,我的项目 (Match4app) 与 AndroidX 配合使用,并且我能够在 PlayStore 中发布它而没有任何问题。
评论:此任务还允许我升级所有其他依赖于 AndroidX 的库(即 com.firebaseui:firebase-ui-auth:6.0.2、com.google.android.gms:play-services-games:18.0.1、 com.google.android.gms:play-services-auth:17.0.0、com.google.android.gms:play-services-ads:18.2.0 等)。
Shr*_*sey 10
只需在gradle.properties文件中添加这两行,
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
现在您的项目将不会有任何重复的类错误并且可以正常工作,
谢谢
I run into something like this, and below is based on my other answer:
Your project (or one of its sub-projects) is referring to a dependency using the + plus-sign at its end, like com.google.firebase:firebase-auth:+
, which means, use any higher version when possible, and that newer version is no longer using android.support
libraries and instead is using androidx
; to fix this issue follow the below steps.
ANDROID_HOME
environment-variable is set, and then, open a console window (like git-bash, because it keeps the whole command output), and cd
into your android
directory (for Ionic projects it should be platforms/android
)../gradlew :app:dependencies
Run Code Online (Sandbox Code Playgroud)androidx
.16.0.8 -> 19.0.0
or + -> 19.0.0
, which both mean that the version was auto-resolved (to something higher than specified by you because of +).clear
the console).To Force specific version of the dependencies add to your root build.gradle
file something like below (which is what worked for me) but of course edit below and add your own rules (because these might not work for your case):
allprojects {
// ...
configurations.all {
resolutionStrategy {
force 'com.google.firebase:firebase-common:17.0.0'
force 'com.google.android.gms:play-services-basement:16.2.0'
force 'com.google.firebase:firebase-iid:16.0.0'
force 'com.google.firebase:firebase-auth:17.0.0'
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 9
我遇到了同样的问题,这就是我解决它的方法
展开 Gradle Scripts,然后转到 graddle.properties 并添加这两行
注意:也许第一行 android.useAndroidX=true 已经存在所以不要重复。
android.useAndroidX=true android.enableJetifier=true
归档时间: |
|
查看次数: |
38872 次 |
最近记录: |