【发布时间】:2021-03-08 00:10:41
【问题描述】:
所以 AS 告诉我“类型 com.hoho.android.usbserial.BuildConfig 定义了多次:
...\usb-serial-for-android\usbSerialForAndroid\build.transforms\53759cf0d63e199b707a7ba0cbe9c081\classes\classes.dex
...\usb-serial-for-android\usbSerialExamples\build\intermediates\external_libs_dex\debug\mergeExtDexDebug\classes.dex
build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
implementation 'com.github.mik3y:usb-serial-for-android:3.3.0'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url 'https://jitpack.io' }
}
}
library.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
consumerProguardFiles 'proguard-rules.pro'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments = [ // Raspi Windows LinuxVM ...
'rfc2217_server_host': '192.168.0.100',
'rfc2217_server_nonstandard_baudrates': 'true', // true false false
]
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "androidx.annotation:annotation:1.1.0"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'commons-net:commons-net:3.6'
androidTestImplementation 'org.apache.commons:commons-lang3:3.11'
implementation 'com.github.mik3y:usb-serial-for-android:3.3.0'
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.test.InstrumentationTestRunner"
missingDimensionStrategy 'device', 'anyDevice'
}
buildTypes {
release {
minifyEnabled true
}
}
}
dependencies {
implementation project(':usbSerialForAndroid')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
}
gradle-wraper.properties:
#Tue Oct 13 21:20:09 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
不知道如何解决。
【问题讨论】:
-
com.github.mik3y:usb-serial-for-android:3.3.0和project(':usbSerialForAndroid')引用的不是同一个库吗? -
好吧,我不明白 gradle 是如何工作的。在第一种情况下,它指的是在线存储库,而在第二种情况下,它指向本地文件夹。那么这两个引用都解析到同一个文件?那我要删除哪个引用?