我有一个项目(MyProject),其中有一个库(customlib)模块,该库模块正在使用一个jar文件commontask.jar,我已将其导入了int模块。我也想在Android项目中使用相同的jar文件。我在MyProject中导入了该模块(customlib),但是如果我尝试访问自定义库的类(CustomActivity.java),则给出错误信息将无法访问CustomActivity.java。
customlib gradle文件
apply plugin: 'com.android.library'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/customtask.jar')
}
Myproject Gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':customlib')
}
如果我在该项目中导入了customtask.jar,并且在生成apk时给出了错误
Program type already present: com.task.common.Helper