我有一个Java库作为Android Studio中的模块构建。它有一个用于测试的Java主类,如果我从库代码中的主类启动Java应用程序(不是android)进行测试,则它的构建和工作都非常完美。现在,我想将其包含在Android应用程序中。在应用程序build.gradle中,我添加了:
implementation project(path: ':ProxyLibrary')
但是在构建时,我得到:错误:程序类型已经存在:错误:程序类型已经存在:com.corundumstudio.socketio.AckCallback
这种疯狂可能有什么问题?这是完整的build.gradle文件:
图书馆的:
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.corundumstudio.socketio:netty-socketio:1.7.16'
compile 'io.socket:socket.io-client:1.0.0'
compile 'com.google.code.gson:gson:2.7'
// compile 'kryonet:kryonet:2.21'
compile 'com.esotericsoftware:kryonet:2.22.0-RC1'
}
sourceCompatibility = "7"
targetCompatibility = "7"
jar {
manifest {
attributes 'Main-Class': 'com.proxyapp.proxylibrary.Main'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
应用的:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.proxyapp.proxyapplication"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/INDEX.LIST'
pickFirst 'META-INF/io.netty.versions.properties'
pickFirst 'publicsuffixes.gz'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project(path: ':ProxyLibrary')
}