我正在本机android中构建一个聊天应用程序
当我尝试运行项目时出现此错误-
........
Duplicate class android.arch.lifecycle.AndroidViewModel found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ComputableLiveData found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.ComputableLiveData$1 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.ComputableLiveData$2 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.ComputableLiveData$3 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.LiveData found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-core-1.1.1-runtime.jar (android.arch.lifecycle:livedata-core:1.1.1)
Duplicate class android.arch.lifecycle.LiveData$1 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-core-1.1.1-runtime.jar (android.arch.lifecycle:livedata-core:1.1.1)
Duplicate class android.arch.lifecycle.LiveData$LifecycleBoundObserver found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-core-1.1.1-runtime.jar (android.arch.lifecycle:livedata-core:1.1.1)
Duplicate class android.arch.lifecycle.MediatorLiveData found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.MediatorLiveData$Source found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.MutableLiveData found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-core-1.1.1-runtime.jar (android.arch.lifecycle:livedata-core:1.1.1)
Duplicate class android.arch.lifecycle.Observer found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-core-1.1.1-runtime.jar (android.arch.lifecycle:livedata-core:1.1.1)
Duplicate class android.arch.lifecycle.Transformations found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.Transformations$1 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.Transformations$2 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.Transformations$2$1 found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and livedata-1.1.1-runtime.jar (android.arch.lifecycle:livedata:1.1.1)
Duplicate class android.arch.lifecycle.ViewModel found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ViewModelProvider found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ViewModelProvider$Factory found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ViewModelProvider$NewInstanceFactory found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ViewModelStore found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
Duplicate class android.arch.lifecycle.ViewModelStoreOwner found in modules extensions-1.0.0-beta1-runtime.jar (android.arch.lifecycle:extensions:1.0.0-beta1) and viewmodel-1.1.1-runtime.jar (android.arch.lifecycle:viewmodel:1.1.1)
转到文档以了解如何解决依赖关系解析错误。
.........
我的应用程序级别gradle文件-
apply plugin: 'com.android.application'
/**
* This is a part of ChatApp Project (https://github.com/h01d/ChatApp)
* Licensed under Apache License 2.0
*
* @author Raf (https://github.com/h01d)
* @version 1.1
* @since 27/02/2018
*/
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.namandevloper.satyampublic"
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v13'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
//https://github.com/square/picasso (Apache License 2.0)
implementation 'com.squareup.okhttp:okhttp:2.5.0'
//https://github.com/square/okhttp (Apache License 2.0)
implementation 'de.hdodenhof:circleimageview:2.2.0'
//https://github.com/hdodenhof/CircleImageView (Apache License 2.0)
implementation 'com.sothree.slidinguppanel:library:3.4.0'
//https://github.com/umano/AndroidSlidingUpPanel (Apache License 2.0)
implementation 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
//https://github.com/dmytrodanylyk/android-process-button (MIT)
implementation 'com.github.XunMengWinter:CircularAnim:0.3.4'
//https://github.com/XunMengWinter/CircularAnim (No license)
implementation 'com.github.florent37:diagonallayout:1.0.8'
//https://github.com/florent37/DiagonalLayout (Apache License 2.0)
implementation 'com.flaviofaria:kenburnsview:1.0.7'
//https://github.com/flavioarfaria/KenBurnsView (Apache License 2.0)
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
//https://github.com/ogaclejapan/SmartTabLayout (Apache License 2.0)
implementation 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
//https://github.com/ogaclejapan/SmartTabLayout (Apache License 2.0)
implementation 'me.jahirfiquitiva:FABsMenu:1.1.1'
//https://github.com/jahirfiquitiva/FABsMenu (Apache License 2.0)
}
apply plugin: 'com.google.gms.google-services'
项目级Gradle-
/**
* This is a part of ChatApp Project (https://github.com/h01d/ChatApp)
* Licensed under Apache License 2.0
*
* @author Raf (https://github.com/h01d)
* @version 1.1
* @since 27/02/2018
*/
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我该怎么办?我已经搜索并尝试了很多东西,但没有一个能帮助我。
答案 0 :(得分:2)
将项目迁移到 Androidx 应该会有所帮助。
可以通过以下方式完成:
Android Studio>重构>迁移到Androidx