Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓工作室赢得';我不能建立我的APK?_Java_Android_Android Studio_Gradle_Duplicates - Fatal编程技术网

Java 安卓工作室赢得';我不能建立我的APK?

Java 安卓工作室赢得';我不能建立我的APK?,java,android,android-studio,gradle,duplicates,Java,Android,Android Studio,Gradle,Duplicates,我正在开发一款Android应用程序,为期4周。我正在使用Skype for Business-app SDK for Android-preview()制作一个应用程序。该应用程序已准备好进行alpha测试,因此我想在Google Play商店中发布APK。我需要有一个APK文件,上传到谷歌播放开发控制台 如果我尝试构建APK(Topmenu>build>build APK),我会收到以下错误消息: com.android.build.api.transform.TransformExcept

我正在开发一款Android应用程序,为期4周。我正在使用Skype for Business-app SDK for Android-preview()制作一个应用程序。该应用程序已准备好进行alpha测试,因此我想在Google Play商店中发布APK。我需要有一个APK文件,上传到谷歌播放开发控制台

如果我尝试构建APK(Topmenu>build>build APK),我会收到以下错误消息:

com.android.build.api.transform.TransformException:java.util.zip.zipeException:重复条目:okhttp3/Address.class

但最奇怪的是,如果我在调试模式下运行应用程序,它就可以正常工作

也许我的gradle构建文件有问题

android {

compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
buildToolsVersion BUILD_TOOLS_VERSION

defaultConfig {
    applicationId "com.microsoft.office.sfb.sfbdemo"
    minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
    targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

buildTypes {
    debug {
        minifyEnabled false
        debuggable true
        jniDebuggable true
    }
    release {
        debuggable false
    }
}

packagingOptions {
    exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
    exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
    exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
    exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/MSFTSIG.RSA'
    exclude 'META-INF/BCKEY.DSA'
    exclude 'META-INF/BCKEY.SF'
    exclude 'META-INF/MSFTSIG.SF'
}

dexOptions {
    preDexLibraries false
    jumboMode true
    incremental true
    javaMaxHeapSize "4g"
}
}

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')

    testCompile 'junit:junit:4.12'

    compile(name: "libucmp", ext: 'aar')
    compile(name: "platform", ext: 'aar')
    compile(name: "injector", ext: 'aar')
    compile(name: "SkypeForBusiness", ext: 'aar')
    compile(name: "ucmp-enums", ext: 'aar')
    compile(name: "TelemetryClient2", ext: 'aar')
    compile(name: "TelemetryService", ext: 'aar')
    compile(name: "android-database-sqlcipher", ext: 'aar')

    compile "com.android.support:multidex:1.0.1"
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'

    compile ('com.squareup.retrofit2:retrofit:2.1.0') {
        exclude module: 'com.squareup.okio'
    }

    compile ('com.squareup.retrofit2:converter-gson:2.1.0') {
        exclude module: 'com.squareup.okio'
    }
}
Android Studio中的消息列表:

Information:Gradle tasks [:sfbdemo:assembleDebug]
:sfbdemo:preBuild UP-TO-DATE
:sfbdemo:preDebugBuild UP-TO-DATE
:sfbdemo:checkDebugManifest
:sfbdemo:preReleaseBuild UP-TO-DATE
:sfbdemo:prepareAndroidDatabaseSqlcipherLibrary UP-TO-DATE
:sfbdemo:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:sfbdemo:prepareComAndroidSupportCardviewV72221Library UP-TO-DATE
:sfbdemo:prepareComAndroidSupportDesign2221Library UP-TO-DATE
:sfbdemo:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:sfbdemo:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
:sfbdemo:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:sfbdemo:prepareInjectorLibrary UP-TO-DATE
:sfbdemo:prepareLibucmpLibrary UP-TO-DATE
:sfbdemo:preparePlatformLibrary UP-TO-DATE
:sfbdemo:prepareSkypeForBusinessLibrary UP-TO-DATE
:sfbdemo:prepareTelemetryClient2Library UP-TO-DATE
:sfbdemo:prepareTelemetryServiceLibrary UP-TO-DATE
:sfbdemo:prepareUcmpEnumsLibrary UP-TO-DATE
:sfbdemo:prepareDebugDependencies
:sfbdemo:compileDebugAidl UP-TO-DATE
:sfbdemo:compileDebugRenderscript UP-TO-DATE
:sfbdemo:generateDebugBuildConfig UP-TO-DATE
:sfbdemo:mergeDebugShaders UP-TO-DATE
:sfbdemo:compileDebugShaders UP-TO-DATE
:sfbdemo:generateDebugAssets UP-TO-DATE
:sfbdemo:mergeDebugAssets UP-TO-DATE
:sfbdemo:generateDebugResValues UP-TO-DATE
:sfbdemo:generateDebugResources UP-TO-DATE
:sfbdemo:mergeDebugResources UP-TO-DATE
:sfbdemo:processDebugManifest UP-TO-DATE
:sfbdemo:processDebugResources UP-TO-DATE
:sfbdemo:generateDebugSources UP-TO-DATE
:sfbdemo:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:sfbdemo:compileDebugJavaWithJavac UP-TO-DATE
:sfbdemo:compileDebugNdk UP-TO-DATE
:sfbdemo:compileDebugSources UP-TO-DATE
:sfbdemo:prePackageMarkerForDebug
:sfbdemo:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task ':sfbdemo:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/Address.class
Information:BUILD FAILED
Information:Total time: 3.576 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
我还运行了gradle任务sfddemo:dependencies,构建成功。但我还是不能建造APK

依赖项列表:

$ gradle :sfbdemo:dependencies
Incremental java compilation is an incubating feature.
:sfbdemo:dependencies

------------------------------------------------------------
Project :sfbdemo
------------------------------------------------------------

_debugAndroidTestApk - ## Internal use, do not manually configure ##
\--- com.android.support:multidex-instrumentation:1.0.1
     \--- com.android.support:multidex:1.0.1

_debugAndroidTestCompile - ## Internal use, do not manually configure ##
\--- com.android.support:multidex-instrumentation:1.0.1
     \--- com.android.support:multidex:1.0.1

_debugApk - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- :libucmp:
+--- :platform:
+--- :injector:
+--- :SkypeForBusiness:
+--- :ucmp-enums:
+--- :TelemetryClient2:
+--- :TelemetryService:
+--- :android-database-sqlcipher:
+--- com.google.code.gson:gson:2.6.2 -> 2.7
+--- com.android.support:appcompat-v7:22.2.1
|    \--- com.android.support:support-v4:22.2.1
|         \--- com.android.support:support-annotations:22.2.1
+--- com.android.support:design:22.2.1
|    +--- com.android.support:appcompat-v7:22.2.1 (*)
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:recyclerview-v7:22.2.1
|    +--- com.android.support:support-annotations:22.2.1
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:cardview-v7:22.2.1
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
\--- com.squareup.retrofit2:converter-gson:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- com.google.code.gson:gson:2.7

_debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- :libucmp:
+--- :platform:
+--- :injector:
+--- :SkypeForBusiness:
+--- :ucmp-enums:
+--- :TelemetryClient2:
+--- :TelemetryService:
+--- :android-database-sqlcipher:
+--- com.google.code.gson:gson:2.6.2 -> 2.7
+--- com.android.support:appcompat-v7:22.2.1
|    \--- com.android.support:support-v4:22.2.1
|         \--- com.android.support:support-annotations:22.2.1
+--- com.android.support:design:22.2.1
|    +--- com.android.support:appcompat-v7:22.2.1 (*)
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:recyclerview-v7:22.2.1
|    +--- com.android.support:support-annotations:22.2.1
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:cardview-v7:22.2.1
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
\--- com.squareup.retrofit2:converter-gson:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- com.google.code.gson:gson:2.7

_debugUnitTestApk - ## Internal use, do not manually configure ##
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

_debugUnitTestCompile - ## Internal use, do not manually configure ##
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- :libucmp:
+--- :platform:
+--- :injector:
+--- :SkypeForBusiness:
+--- :ucmp-enums:
+--- :TelemetryClient2:
+--- :TelemetryService:
+--- :android-database-sqlcipher:
+--- com.google.code.gson:gson:2.6.2 -> 2.7
+--- com.android.support:appcompat-v7:22.2.1
|    \--- com.android.support:support-v4:22.2.1
|         \--- com.android.support:support-annotations:22.2.1
+--- com.android.support:design:22.2.1
|    +--- com.android.support:appcompat-v7:22.2.1 (*)
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:recyclerview-v7:22.2.1
|    +--- com.android.support:support-annotations:22.2.1
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:cardview-v7:22.2.1
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
\--- com.squareup.retrofit2:converter-gson:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- com.google.code.gson:gson:2.7

_releaseCompile - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- :libucmp:
+--- :platform:
+--- :injector:
+--- :SkypeForBusiness:
+--- :ucmp-enums:
+--- :TelemetryClient2:
+--- :TelemetryService:
+--- :android-database-sqlcipher:
+--- com.google.code.gson:gson:2.6.2 -> 2.7
+--- com.android.support:appcompat-v7:22.2.1
|    \--- com.android.support:support-v4:22.2.1
|         \--- com.android.support:support-annotations:22.2.1
+--- com.android.support:design:22.2.1
|    +--- com.android.support:appcompat-v7:22.2.1 (*)
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:recyclerview-v7:22.2.1
|    +--- com.android.support:support-annotations:22.2.1
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:cardview-v7:22.2.1
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
\--- com.squareup.retrofit2:converter-gson:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- com.google.code.gson:gson:2.7

_releaseUnitTestApk - ## Internal use, do not manually configure ##
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

_releaseUnitTestCompile - ## Internal use, do not manually configure ##
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

androidJacocoAgent - The Jacoco agent to use to get coverage data.
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.7.6.201602                                                                                                                                                                                               180812/org.jacoco.agent-0.7.6.201602180812.pom
\--- org.jacoco:org.jacoco.agent:0.7.6.201602180812

androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.ant/0.7.6.20160218                                                                                                                                                                                               0812/org.jacoco.ant-0.7.6.201602180812.pom
Download https://repo1.maven.org/maven2/org/jacoco/org.jacoco.report/0.7.6.20160                                                                                                                                                                                               2180812/org.jacoco.report-0.7.6.201602180812.pom
\--- org.jacoco:org.jacoco.ant:0.7.6.201602180812
     +--- org.jacoco:org.jacoco.core:0.7.6.201602180812
     |    \--- org.ow2.asm:asm-debug-all:5.0.4
     +--- org.jacoco:org.jacoco.report:0.7.6.201602180812
     |    +--- org.jacoco:org.jacoco.core:0.7.6.201602180812 (*)
     |    \--- org.ow2.asm:asm-debug-all:5.0.4
     \--- org.jacoco:org.jacoco.agent:0.7.6.201602180812

androidTestApk - Classpath packaged with the compiled 'androidTest' classes.
No dependencies

androidTestCompile - Classpath for compiling the androidTest sources.
No dependencies

androidTestProvided - Classpath for only compiling the androidTest sources.
No dependencies

androidTestWearApp - Link to a wear app to embed for object 'androidTest'.
No dependencies

apk - Classpath packaged with the compiled 'main' classes.
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compile - Classpath for compiling the main sources.
+--- :libucmp:
+--- :platform:
+--- :injector:
+--- :SkypeForBusiness:
+--- :ucmp-enums:
+--- :TelemetryClient2:
+--- :TelemetryService:
+--- :android-database-sqlcipher:
+--- com.android.support:multidex:1.0.1
+--- com.google.code.gson:gson:2.6.2 -> 2.7
+--- com.android.support:appcompat-v7:22.2.1
|    \--- com.android.support:support-v4:22.2.1
|         \--- com.android.support:support-annotations:22.2.1
+--- com.android.support:design:22.2.1
|    +--- com.android.support:appcompat-v7:22.2.1 (*)
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:recyclerview-v7:22.2.1
|    +--- com.android.support:support-annotations:22.2.1
|    \--- com.android.support:support-v4:22.2.1 (*)
+--- com.android.support:cardview-v7:22.2.1
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0
|         \--- com.squareup.okio:okio:1.8.0
\--- com.squareup.retrofit2:converter-gson:2.1.0
     +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
     \--- com.google.code.gson:gson:2.7

debugApk - Classpath packaged with the compiled 'debug' classes.
No dependencies

debugCompile - Classpath for compiling the debug sources.
No dependencies

debugProvided - Classpath for only compiling the debug sources.
No dependencies

debugWearApp - Link to a wear app to embed for object 'debug'.
No dependencies

default - Configuration for default artifacts.
No dependencies

default-mapping - Configuration for default mapping artifacts.
No dependencies

default-metadata - Metadata for the produced APKs.
No dependencies

findbugs - The FindBugs libraries to be used for this project.
No dependencies

findbugsPlugins - The FindBugs plugins to be used for this project.
No dependencies

provided - Classpath for only compiling the main sources.
No dependencies

releaseApk - Classpath packaged with the compiled 'release' classes.
No dependencies

releaseCompile - Classpath for compiling the release sources.
No dependencies

releaseProvided - Classpath for only compiling the release sources.
No dependencies

releaseWearApp - Link to a wear app to embed for object 'release'.
No dependencies

testApk - Classpath packaged with the compiled 'test' classes.
No dependencies

testCompile - Classpath for compiling the test sources.
\--- junit:junit:4.12
     \--- org.hamcrest:hamcrest-core:1.3

testDebugApk - Classpath packaged with the compiled 'testDebug' classes.
No dependencies

testDebugCompile - Classpath for compiling the testDebug sources.
No dependencies

testDebugProvided - Classpath for only compiling the testDebug sources.
No dependencies

testDebugWearApp - Link to a wear app to embed for object 'testDebug'.
No dependencies

testProvided - Classpath for only compiling the test sources.
No dependencies

testReleaseApk - Classpath packaged with the compiled 'testRelease' classes.
No dependencies

testReleaseCompile - Classpath for compiling the testRelease sources.
No dependencies

testReleaseProvided - Classpath for only compiling the testRelease sources.
No dependencies

testReleaseWearApp - Link to a wear app to embed for object 'testRelease'.
No dependencies

testWearApp - Link to a wear app to embed for object 'test'.
No dependencies

wearApp - Link to a wear app to embed for object 'main'.
No dependencies

BUILD SUCCESSFUL

Total time: 4.811 secs

我终于找到了问题的答案。在互联网上搜索了很长时间后,我找到了以下解决方案。我把每一行“编译”放在注释中,然后重建项目,看看是否一切正常

我不断重复这个过程,直到我发现是哪段代码导致了这个问题。我发现以下代码行导致了问题:

compile(name: "platform", ext: 'aar')

我希望这能帮助你解决你自己的问题

使用编译'com.squareup.Refught2:Refught2.1.0',编译'com.squareup.Refught2:converter gson:2.1.0',并删除PackageOptions{…}前2行扫描您发布完整的日志。?运行gradle任务
:app:dependencies
,查看副本来自何处。@Vadivel我删除了排除模块和前两行打包选项,但不起作用。@Raghavendra I will:),我现在正在尝试运行gradle任务:app:dependencies