2016-12-07 60 views
0

我的應用程序出現問題! build.gradle同步並沒有錯誤,但是當我想運行應用程序錯誤!這是錯誤:錯誤:執行任務失敗':找到我:transformResourcesWithMergeJavaResForDebug'

Error:Execution failed for task ':Find Me:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE File1: C:\Users****\workspace\Find Me\libs\httpclient-4.5.1.jar

File2: C:\Users****\workspace\Find Me\libs\httpclient-cache-4.5.1.jar

File3: C:\Users****\workspace\Find Me\libs\httpclient-win-4.5.1.jar

File4: C:\Users****\workspace\Find Me\libs\httpcore-4.4.3.jar

其的build.gradle:

apply plugin: 'com.android.application' 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile project(':android-support-v7-appcompat') 
    compile project(':CircularImageView') 
    compile project(':FacebookSDK') 
    compile project(':google-play-services_lib') 
    compile project(':google-play-services_lib') 
    compile project(':FacebookSDK') 
    compile project(':android-support-v7-appcompat') 
    compile project(':CircularImageView') 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "25.0.1" 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 

謝謝

回答

0

在你grandle文件你有compile project(':google-play-services_lib') compile project(':google-play-services_lib') compile project(':FacebookSDK') compile project(':android-support-v7-appcompat') compile project(':CircularImageView') 2倍

刪除它們,只能用一次,每

apply plugin: 'com.android.application' 

dependencies { 
compile fileTree(dir: 'libs', include: '*.jar') 
compile project(':android-support-v7-appcompat') 
compile project(':CircularImageView') 
compile project(':FacebookSDK') 
compile project(':google-play-services_lib') 

} 

android { 
compileSdkVersion 23 
buildToolsVersion "25.0.1" 

sourceSets { 
    main { 
     manifest.srcFile 'AndroidManifest.xml' 
     java.srcDirs = ['src'] 
     resources.srcDirs = ['src'] 
     aidl.srcDirs = ['src'] 
     renderscript.srcDirs = ['src'] 
     res.srcDirs = ['res'] 
     assets.srcDirs = ['assets'] 
    } 

    // Move the tests to tests/java, tests/res, etc... 
    instrumentTest.setRoot('tests') 

    // Move the build types to build-types/<type> 
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
    // This moves them out of them default location under src/<type>/... which would 
    // conflict with src/ being used by the main source set. 
    // Adding new build types or product flavors should be accompanied 
    // by a similar customization. 
    debug.setRoot('build-types/debug') 
    release.setRoot('build-types/release') 
} 
} 

編輯:裏面添加的Android {}

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' 
} 
+0

謝謝,但還是同樣的錯誤! – user2003857

+0

@ user2003857你能告訴我你使用編譯項目的原因嗎?你在編輯這些文件嗎? –

+0

@ user2003857檢查我的編輯 –

0

正如@VygintasB說,刪除重複的依賴關係,並嘗試添加在你的模塊級的build.gradle文件該塊,錯誤說重複的文件複製這些行在APK META-INF/LICENSE所以只是排除那些並嘗試

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

    } 
+0

謝謝你的回答。謝謝你的回答。發生這個錯誤!錯誤:(2,0)找不到方法org.gradle.api.Project的項目':Find Me'中的參數[build_7m54jl7uaw8y6qoof85j6ic93 $ _run_closure1 @ 41a63d94]的方法packagingOptions()。 – user2003857

+0

你可以發佈你的更新的gradle文件 – Raghavendra

+0

@ user2003857你在哪裏把packagingOptions()塊?請放入Android塊內的gradle文件 – Raghavendra

相關問題