【发布时间】:2019-04-09 13:38:48
【问题描述】:
我有一个项目(MyProject),其中有一个库(customlib)模块,该库模块正在使用我导入的 int 模块的一个 jar 文件 commontask.jar。我也想在 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')
}
我的项目 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
【问题讨论】:
-
你检查过这个 StackOverflow question吗?
标签: android android-gradle-plugin