我通过手动添加不同文件(如menifest,java,res)的代码将我的eclipse项目转换为android studio。当我运行该项目时,它显示错误:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/IntegerRes.class
这是我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.tms032.demo_pos_rs"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile project(':CustomCalendarView')
compile files('libs/commons-discovery-0.2.jar')
compile files('libs/commons-lang-2.5.jar')
compile files('libs/gson-2.2.2.jar')
compile files('libs/javax.wsdl_1.6.2.v201005080631.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/picasso-2.0.0.jar')
compile files('libs/posindev.jar')
compile files('libs/printingSDK-7.5.0-javadoc.jar')
compile files('libs/sqljet.1.0.2.b885.jar')
compile files('libs/upg_bridge.jar')
testCompile 'junit:junit:4.12'
}
如何阅读此错误?我尝试了很多解决方案。但它们都不起作用。
答案 0 :(得分:0)
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/commons-discovery-0.2.jar')
您正在编辑jar文件两次,也是
当存在具有不同版本的相同库时会出现问题,
您可以将它们从jar依赖项中排除,如下所示,但这几乎无法正常工作。
sourceSets {
main {
java {
include 'com/ourcompany/somepackage/activityadapter/**'
include 'com/ourcompany/someotherpackage/**'
exclude 'com/ourcompany/someotherpackage/polling/**'
}
}
最好的选择是找到新版本的repo而不是jar。