gpt4 book ai didi

android - AndroidError:程序类型已存在:当我尝试从Android Studio生成Signed APK时,android_serialport_api.SerialPort

转载 作者:行者123 更新时间:2023-12-03 05:23:10 28 4
gpt4 key购买 nike

将.aar文件添加到应用gradle后,我得到指定的异常:程序类型已存在:android_serialport_api.SerialPort
当我尝试构建Debug APK时,它可以工作,但是当我尝试构建Signed APK时,则给出了指定的异常(exception)。
以下是我的应用程序等级文件

 apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "XX.XX.XX"
minSdkVersion 22
targetSdkVersion 28
versionCode 27
versionName "6.6"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
useProguard true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
configurations {
all*.exclude group: 'com.squareup.okhttp3';
all*.exclude group: 'com.squareup.okio';
}

}

repositories {
maven { url "jitpack.io" }
maven { name 'glide-snapshot'; url 'oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}

dependencies {

implementation files('libs/apache-httpcomponents-httpclient.jar')
implementation files('libs/apache-httpcomponents-httpcore.jar')

implementation files('libs/commons-codec-1.11.jar')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-location:11.0.4'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.jakewharton.timber:timber:4.5.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.antonKozyriatskyi:CircularProgressIndicator:1.3.0'

implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
//implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54'
implementation 'com.google.android.gms:play-services-maps:11.0.4'

/*implementation(name: 'merchantsdk', ext: 'aar')*/
/*implementation(name: 'merchantsdk', ext: 'aar'){
exclude module: 'SerialPort'
}*/
/*implementation(name: 'ezetapandroidsdk', ext: 'aar')*/

implementation project(':merchantsdk')
implementation project(':ezetapandroidsdk')

testImplementation 'junit:junit:4.12'
implementation files('libs/org.apache.commons.io.jar')
}


apply plugin: 'com.google.gms.google-services'
以下是Project Gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
maven { url "https://jcenter.bintray.com"}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
以下是异常(exception)
  > Task :app:transformClassesAndResourcesWithR8ForRelease FAILED
AGPBI: {"kind":"error","text":"Program type already present: android_serialport_api.a","sources":[{}],"tool":"R8"}

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete
调试apk正常运行,但是当我尝试构建上述异常的签名APK时。
请对此提供帮助。谢谢。

最佳答案

问题是您使用android_serialport_api.SerialPort有一个以上的软件包。
有两种处理方法。首先是检查每个库并检查它是否正在使用它,或者可以通过运行以下命令找到重复的库:

gradlew -q dependencies yourProject:dependencies --configuration implementation
您也可以将其从 merchantsdk中排除,如下所示:
implementation(name: 'merchantsdk', ext: 'aar'){
exclude module: 'SerialPort'
}

关于android - AndroidError:程序类型已存在:当我尝试从Android Studio生成Signed APK时,android_serialport_api.SerialPort,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62749329/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com