添加播放服务库后出错:':app:transformClassesWithJarMergingForDebug' [英] Error after adding play-services library : ':app:transformClassesWithJarMergingForDebug'

查看:22
本文介绍了添加播放服务库后出错:':app:transformClassesWithJarMergingForDebug'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目与包含的那些库完美配合:

//支持库编译'com.android.support:support-v4:23.1.0'编译'com.android.support:appcompat-v7:23.1.0'编译'com.android.support:cardview-v7:23.1.0'编译'com.android.support:recyclerview-v7:23.1.0'//其他的东西编译'com.jakewharton:butterknife:7.0.1'编译'com.squareup.picasso:picasso:2.5.2'编译'com.google.code.gson:gson:2.3'编译'com.squareup.retrofit:retrofit:1.9.0'编译 'com.afollestad:material-dialogs:0.7.8.1'编译'com.jpardogo.materialtabstrip:library:1.1.0'编译'com.melnykov:floatingactionbutton:1.3.0'编译'com.code-troopers.betterpickers:library:2.0.0'编译'com.loopj.android:android-async-http:1.4.9'编译'com.squareup.okhttp:okhttp:2.5.0'编译'com.facebook.fresco:fresco:0.7.0'

现在我尝试按照本教程进行操作:在 Android 上设置 GCM 客户端应用程序

我加了

<块引用>

  1. 将依赖项添加到项目的顶级 build.gradle:
    classpath 'com.google.gms:google-services:1.4.0-beta3'
  2. 将插件添加到您的应用级 build.gradle:
    应用插件:'com.google.gms.google-services'

然后我补充说:

编译com.google.android.gms:play-services:8.1.0"

现在,当我尝试同步、清理或重建时.Gradle 向我显示它已成功完成.

错误:当我尝试运行应用程序并选择设备时.我收到此错误:

错误:任务:app:transformClassesWithJarMergingForDebug"的执行失败.>com.android.build.transform.api.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl.class

这是我的应用级 build.gradle 的最后一个版本:

应用插件:'com.android.application'应用插件:'com.google.gms.google-services'安卓 {包装选项{排除元信息/依赖项"排除元信息/许可证"排除 'META-INF/LICENSE.txt'排除 'META-INF/license.txt'排除元信息/通知"排除 'META-INF/NOTICE.txt'排除 'META-INF/notice.txt'排除 'META-INF/ASL2.0'排除'META-INF/services/javax.annotation.processing.Processor'}compileSdkVersion 23构建工具版本23.0.0"默认配置{applicationId "com.mbh.gcmTest"minSdk 版本 15目标SDK版本23版本代码 12版本名称1.2.2"//启用多索引支持.试图修复multiDexEnabled true}lintOptions {禁用无效包"}构建类型{释放 {minifyEnabled false}}dexOptions {preDexLibraries = false}产品风味{}}//编译fileTree(include: ['*.jar'], dir: 'libs')//debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'//releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'依赖{提供'org.glassfish:javax.annotation:10.0-b28'//支持库编译'com.android.support:support-v4:23.1.0'编译'com.android.support:appcompat-v7:23.1.0'编译'com.android.support:cardview-v7:23.1.0'编译'com.android.support:recyclerview-v7:23.1.0'编译'com.jakewharton:butterknife:7.0.1'编译'com.squareup.picasso:picasso:2.5.2'编译'com.google.code.gson:gson:2.3'编译'com.squareup.retrofit:retrofit:1.9.0'编译 'com.afollestad:material-dialogs:0.7.8.1'编译'com.jpardogo.materialtabstrip:library:1.1.0'编译'com.melnykov:floatingactionbutton:1.3.0'编译'com.code-troopers.betterpickers:library:2.0.0'编译'com.loopj.android:android-async-http:1.4.9'编译'com.squareup.okhttp:okhttp:2.5.0'编译'com.facebook.fresco:fresco:0.7.0'//对于 GCM编译'com.android.support:multidex:1.0.1'编译 'com.google.android.gms:play-services:8.1.0'}

在尝试了@JBirdVegas 提供的答案后,我收到了这个错误:

错误:任务:app:transformClassesWithDexForDebug"的执行失败.>com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' 以非零退出值 1 结束

这是 gradle 日志:

注:配置引用类'com.emse.emseportal3.App'中的未知方法'void attachBaseContext(android.content.Context)'注意:有 1 个对未知类成员的引用.您应该检查您的配置是否有错别字.注意:有 14 个类尝试使用反射访问注释.您应该考虑保留注释属性(使用'-keepattributes *Annotation*').(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)注意:有 20 个类试图使用反射访问通用签名.您应该考虑保留签名属性(使用-keepattributes 签名").(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)注意:有 3 个类试图使用反射访问封闭类.您应该考虑保留内部类属性(使用-keepattributes InnerClasses").(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)注意:有 15 个未解析的对类或接口的动态引用.您应该检查是否需要指定其他程序 jar.(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)注:通过自省的方式访问班级成员的次数为 33 次.您应该考虑明确保留提到的类成员(使用-keep"或-keepclassmembers").(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)注意:您忽略了所有警告!准备输出 jar [D:\EmseArge\Mohamad\Android\EmsePortal2\app\build\intermediates\multi-dex\debug\componentClasses.jar]从程序 jar 复制资源 [D:\EmseArge\Mohamad\Android\EmsePortal2\app\build\intermediates\transforms\CLASSES\FULL_PROJECT\jarMerging\debug\classes.jar]:app:transformClassesWithDexForDebug未捕获的翻译错误:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:超出 GC 开销限制未捕获的翻译错误:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:超出 GC 开销限制未捕获的翻译错误:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:超出 GC 开销限制3个错误;中止错误:任务 ':app:transformClassesWithDexForDebug' 的执行失败.>com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' 以非零退出值 1 结束信息:构建失败

解决方案

看起来 play-services 已经包含 support-v4.尝试将其从类路径中排除

compile('com.google.android.gms:play-services:8.1.0') {排除组:'com.android.support',模块:'support-v4'}

第二个错误是不同的.首先不要使用 Java8 它不支持而是使用 Java7 另外你使用的是什么版本的 Android Gradle 插件?试试最新的 com.android.tools.build:gradle:1.4.0-beta4

也尽量不要使用最新的 play-services 我遇到了针对 8.1.0 编译但不是 7.8.0 的问题>

My project was working perfectly with those libraries included:

// Support libraries
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
// Other stuff
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.afollestad:material-dialogs:0.7.8.1'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.code-troopers.betterpickers:library:2.0.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.facebook.fresco:fresco:0.7.0'

now i tried to follow this tutorial: Set up a GCM Client App on Android

I added

  1. Add the dependency to your project's top-level build.gradle:
    classpath 'com.google.gms:google-services:1.4.0-beta3'
  2. Add the plugin to your app-level build.gradle:
    apply plugin: 'com.google.gms.google-services'

Then i added :

compile "com.google.android.gms:play-services:8.1.0"

Now when i try to sync, clean, or rebuild. Gradle shows me it is done successfully.

THE ERROR: When i try to run the app and choose device. I get this error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl.class

This is the last version of my app-level build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    defaultConfig {
        applicationId "com.mbh.gcmTest"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 12
        versionName "1.2.2"

        // Enabling multidex support. trying to fix 
        multiDexEnabled true
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    buildTypes {
        release {
            minifyEnabled false
        }
    }
    dexOptions {
        preDexLibraries = false
    }
    productFlavors {
    }
}

//compile fileTree(include: ['*.jar'], dir: 'libs')
//debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
//releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
dependencies {
    provided 'org.glassfish:javax.annotation:10.0-b28'

    // Support Libraries
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'

    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.afollestad:material-dialogs:0.7.8.1'
    compile 'com.jpardogo.materialtabstrip:library:1.1.0'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'com.code-troopers.betterpickers:library:2.0.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.facebook.fresco:fresco:0.7.0'

    // FOR GCM
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services:8.1.0'
}

after trying the answer provided by @JBirdVegas I got this error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 1

this is gradle log:

Note: the configuration refers to the unknown method 'void attachBaseContext(android.content.Context)' in class 'com.emse.emseportal3.App'
Note: there were 1 references to unknown class members.
      You should check your configuration for typos.
Note: there were 14 classes trying to access annotations using reflection.
      You should consider keeping the annotation attributes
      (using '-keepattributes *Annotation*').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 20 classes trying to access generic signatures using reflection.
      You should consider keeping the signature attributes
      (using '-keepattributes Signature').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 3 classes trying to access enclosing classes using reflection.
      You should consider keeping the inner classes attributes
      (using '-keepattributes InnerClasses').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 15 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 33 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Note: you're ignoring all warnings!
Preparing output jar [D:\EmseArge\Mohamad\Android\EmsePortal2\app\build\intermediates\multi-dex\debug\componentClasses.jar]
  Copying resources from program jar [D:\EmseArge\Mohamad\Android\EmsePortal2\app\build\intermediates\transforms\CLASSES\FULL_PROJECT\jarMerging\debug\classes.jar]
:app:transformClassesWithDexForDebug
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
3 errors; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED

解决方案

Looks like play-services already contains support-v4. Try excluding it from the classpath

compile('com.google.android.gms:play-services:8.1.0') {
    exclude group: 'com.android.support', module: 'support-v4'
}

The second error is different. First thing don't use Java8 it's not supported instead use Java7 Also what version of the Android Gradle Plugin are you using? Try the latest com.android.tools.build:gradle:1.4.0-beta4

Also try not using the latest play-services I ran into an issue compiling against 8.1.0 but not 7.8.0

这篇关于添加播放服务库后出错:':app:transformClassesWithJarMergingForDebug'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆