Android Studio中的modules classes.jar错误(尝试连接到Firebase时)中发现的重复类是什么?如何解决?
我试图在Android应用程序中使用Firebase数据库,但我遇到了一些错误: 我首先得到了这个错误:Android Studio中的modules classes.jar错误(尝试连接到Firebase时)中发现的重复类是什么?如何解决?,android,firebase-realtime-database,dependencies,build.gradle,androidx,Android,Firebase Realtime Database,Dependencies,Build.gradle,Androidx,我试图在Android应用程序中使用Firebase数据库,但我遇到了一些错误: 我首先得到了这个错误: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-24:19 to override.
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.appv1">
<application
tools:node="replace"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle(模块:应用程序):
apply插件:“com.android.application”
安卓{
编译DK28版
默认配置{
applicationId“com.example.appv1”
明斯克版本16
targetSdkVersion 28
版本代码1
版本名称“1.0”
TestInstrumentRunner“android.support.test.runner.AndroidJUnitRunner”
}
建筑类型{
释放{
minifyEnabled false
proguard文件GetDefaultProGuard文件('proguard-android-optimize.txt'),'proguard rules.pro'
}
}
}
依赖关系{
实现文件树(目录:“libs”,包括:['*.jar'])
实现'com.android.support:appcompat-v7:28.0.0'
实现'com.android.support:design:28.0.0'
实现'com.android.support.constraint:constraint布局:1.1.3'
测试实现'junit:junit:4.12'
androidTestImplementation'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2'
//显示图像
实现'com.github.bumptech.glide:glide:3.6.1'
//火基
实现'com.google.firebase:firebase数据库:9.6.0'
//添加要在应用程序中使用的任何其他Firebase产品的SDK
//例如,使用Firebase身份验证和云Firestore
实现'com.google.firebase:firebase auth:19.1.0'
实现'com.google.firebase:firebase-firestore:21.2.1'
实现'com.firebaseui:firebaseui auth:4.3.1'
}
存储库{
jcenter()
maven{//您正在使用需要androidx库的firebase版本。是的,谢谢@Gabriele Mariotti!我已通过将库更改为androidx所需的库来解决此错误!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.appv1">
<application
tools:node="replace"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.appv1"
minSdkVersion 16
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:design: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'
// Displaying images
implementation 'com.github.bumptech.glide:glide:3.6.1'
// Firebase
implementation 'com.google.firebase:firebase-database:9.6.0'
// Add the SDKs for any other Firebase products you want to use in your app
// For example, to use Firebase Authentication and Cloud Firestore
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.firebase:firebase-firestore:21.2.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
}
repositories {
jcenter()
maven { // <-- Add this
url 'https://maven.google.com/'
}
}
apply plugin: 'com.google.gms.google-services'
build.gradle (Project:Appv1)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}