我在 android studio 中构建我的应用程序时遇到错误
I'm having an error building my application in android studio
enter image description here
// 这是 build.gradle(module:App)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
编译SDK版本30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.authapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
mlModelBinding true
}
}
依赖项{
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.mlkit:image-labeling:17.0.5'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
应用插件:'com.google.gms.google-services'
// 这是 Build.gradle(项目: auth_app)
//
Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
// Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我不知道如何解决这个错误,任何人都可以帮助我
这是我们项目中的错误
Task :app:mergeDebugJavaResource FAILED
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'androidsupportmultidexversion.txt' from inputs:
- C:\Users921\.gradle\caches\transforms-2\files-2.10913dfb7b73ce9375e43aa9e1a997f\multidex-2.0.0\jars\classes.jar
- C:\Users921\.gradle\caches\transforms-2\files-2.1f2dc8a20d0b51cf9b4d1765b971973c\multidex-1.0.3\jars\classes.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
尝试将此添加到您的 gradle 文件中:
packagingOptions{
pickFirst “androidsupportmultidexversion.txt”
}
这将通过选取第一个 androidsupportmultidexversion.txt
文件来解决冲突。
enter image description here
// 这是 build.gradle(module:App)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android { 编译SDK版本30 buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.authapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
mlModelBinding true
}
}
依赖项{
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.mlkit:image-labeling:17.0.5'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} 应用插件:'com.google.gms.google-services'
// 这是 Build.gradle(项目: auth_app)
//
Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
// Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我不知道如何解决这个错误,任何人都可以帮助我
这是我们项目中的错误
Task :app:mergeDebugJavaResource FAILED
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'androidsupportmultidexversion.txt' from inputs:
- C:\Users921\.gradle\caches\transforms-2\files-2.10913dfb7b73ce9375e43aa9e1a997f\multidex-2.0.0\jars\classes.jar
- C:\Users921\.gradle\caches\transforms-2\files-2.1f2dc8a20d0b51cf9b4d1765b971973c\multidex-1.0.3\jars\classes.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
尝试将此添加到您的 gradle 文件中:
packagingOptions{
pickFirst “androidsupportmultidexversion.txt”
}
这将通过选取第一个 androidsupportmultidexversion.txt
文件来解决冲突。