Android Studio 4.1.2: Type com.hoho.android.usbserial.BuildConfig is defined multiple times
Matthew Barrera
so AS tells me that "Type com.hoho.android.usbserial.BuildConfig is defined multiple times:
...\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 ' } }
}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\://don't know how to resolve this.
21 Answer
So it looks like you are referencing the same library twice, with
dependencies { implementation project(':usbSerialForAndroid')
}
dependencies { implementation 'com.github.mik3y:usb-serial-for-android:3.3.0
}This means that Grade is finding two libraries with the same package name which obviously causes a clash.
So you should only be declaring your dependencies in your app: build.grade file.
I presume you've cloned the repository locally, if there's a particular reason for this (you've made changes) then keep the project implementation, otherwise just use the other one, but move it to the app:build.gradle file.