【问题标题】:Import project from eclipse to android studio getting error将项目从 eclipse 导入到 android studio 出现错误
【发布时间】:2016-02-08 09:09:55
【问题描述】:

我是 Android Studio 的新手,我只是在 Android Studio 中导入了一个在 Eclipse 中运行的项目。解决了一些错误,但这还没有解决。

这是错误 -

错误:任务 ':app:transformResourcesWithMergeJavaResForDebug' 执行失败。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在 APK META-INF/LICENSE.txt 中复制的文件重复 文件 1:/home/user86/Downloads/IAH/app/libs/httpmime-4.2.3.jar 文件2:/home/user86/Downloads/IAH/app/libs/httpclient-4.2.3.jar 文件3:/home/user86/Downloads/IAH/app/libs/httpcore-4.2.2.jar

这里是 build.gradle 文件代码。

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.packagename"
    minSdkVersion 14
    targetSdkVersion 23
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
}}


dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/Parse-1.4.0.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/httpcore-4.2.2.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/picasso-2.5.2.jar')
compile files('libs/volley.jar')
}

帮助解决它。提前致谢。

更新的 gradle 文件

apply plugin: 'com.android.application'


dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/Parse-1.4.0.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/httpcore-4.2.2.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/picasso-2.5.2.jar')
compile files('libs/volley.jar')}



android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.instantassignmenthelp"
    minSdkVersion 14
    targetSdkVersion 23
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
}}


packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'}

【问题讨论】:

标签: android android-studio build.gradle


【解决方案1】:
  1. packagingOptions 标签存在问题

建议

避免致电+

不要

compile 'com.google.android.gms:play-services:+'

compile 'com.google.android.gms:play-services:7.8.0' // Or latest stable version

终于

 buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
}


packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'

}
}

【讨论】:

    【解决方案2】:

    packageOptions 应该在 android 标签内。

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
    defaultConfig {
        applicationId "com.instantassignmenthelp"
        minSdkVersion 14
        targetSdkVersion 23
    }
    
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
    
    
    
    
     packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        }
    }
    

    【讨论】:

      【解决方案3】:

      尝试这样做,可能会解决您的问题

      如果您使用的是compile files('libs/volley.jar'),则不需要关注

      尝试删除

      compile files('libs/httpclient-4.2.3.jar')
      compile files('libs/httpcore-4.2.2.jar')
      compile files('libs/httpmime-4.2.3.jar')
      compile files('libs/picasso-2.5.2.jar')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-03
        • 1970-01-01
        • 1970-01-01
        • 2015-05-21
        • 1970-01-01
        • 2016-06-21
        相关资源
        最近更新 更多