本文介绍了Android Studio和gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Android Studio中导入Xabber(GitHub),我做了git init等。
现在我发现我可以为这个问题启动应用程序Gradle,我到处寻找,但找不到任何可以工作的东西。



问题是:

 错误:任务':app:dexBetaDebug'的执行失败。 
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java''已完成与非零退出值1

堆栈:

 信息:Gradle任务[:app:assembleBetaDebug] 
:app:preBuild UP-TO-DATE
:app:preBetaDebugBuild UP-TO-DATE
:app:checkBetaDebugManifest
:app:preBetaReleaseBuild UP-TO-DATE
:app:preDevDebugBuild UP-TO-DATE
:app:preDevReleaseBuild最新日期
: app:otr4j:compileJava UP-TO-DATE
:app:otr4j:processResources UP-TO-DATE
:app:otr4j:classes UP-TO-DATE
:app:otr4j:jar升级日期
:app:prepareComAndroidSupportAppcompatV72220Library升级日期
:app:prepareComAndroidSupportDesign2220Library升级日期
:app:prepareComAndroidSupportMultidex101Library升级日期
:app :prepareComAndroidSupportRecyclerviewV72102Library UP-TO-DATE
:app:prepare ComAndroidSupportSupportV132220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareComGithubKsoichiroAndroidObservablescrollview150Library UP-TO-DATE
:app:prepareComMelnykovFloatingactionbutton120Library UP-TO-DATE
: app:prepareDeHdodenhofCircleimageview122Library UP-TO-DATE
:app:prepareBetaDebugDependencies
:app:compileBetaDebugAidl UP-TO-DATE
:app:compileBetaDebugRenderscript UP-TO-DATE
:app:generateBetaDebugBuildConfig UP-TO-DATE
:app:generateBetaDebugAssets UP-TO-DATE
:app:mergeBetaDebugAssets UP-TO-DATE
:app:generateBetaDebugResValues UP-TO-DATE
:app :generateBetaDebugResources UP-TO-DATE
:app:mergeBetaDebugResources UP-TO-DATE
:app:processBetaDebugManifest UP-TO-DATE
:app:processBetaDebugResources UP-TO-DATE
:app:generateBetaDebugSources UP-TO-DATE
:app:processBetaDebugJavaRes UP-TO-DATE
:app:compileBetaDebugJava UP-TO-DATE
:app:compileBetaDebugNdk UP-TO-DATE
:app:compileBetaDebugSources UP-TO-DATE
:app:collectBetaDebugMultiDexComponents UP-TO-DATE
:app:packageAllBetaDebugClassesForMultiDex UP-TO-DATE
:app :shrinkBetaDebugMultiDexComponents UP-TO-DATE
:app:createBetaDebugMainDexClassList UP-TO-DATE
:app:dexBetaDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf。 iface.ParseException:com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
在com.android中的错误类文件magic(cafebabe)或版本(0034.0000)
。 dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android。 dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android。 dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.M ain.access $ 300(Main.java:83)
at com.android.dx.command.dexer.Main $ 1.processFileBytes(Main.java:602)
at com.android.dx.cf。 direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf。 direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command。 dexer.Main.processAllFiles(Main.java:490)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
at com.android.dx.command。 dexer.Main.run(Main.java:244)
在com.android.dx.command.dexer.Main.main(Main.java:215)
在com.android.dx.command。 Main.main(Main.java:106)
...解析net / java / otr4j / OtrEngineHost.class
warning:忽略匿名内部类的InnerClasses属性
(org.xbill .DNS.UDPClient $ 1)不包含
关联d EnclosingMethod属性。这个类可能是由一个
编译器生成的,它没有针对现代.class文件格式。推荐的
解决方案是使用最新的编译器
从源代码重新编译该类,而不指定任何-target类型选项。忽略
这个警告的结果是这个类的反射操作不正确地
表明它不是*内部类。
warning:忽略匿名内部类
(jnamed $ 3)的InnerClasses属性,该属性不包含
关联的EnclosingMethod属性。这个类可能是由一个
编译器生成的,它没有针对现代.class文件格式。推荐的
解决方案是使用最新的编译器
从源代码重新编译该类,而不指定任何-target类型选项。忽略
这个警告的结果是这个类的反射操作不正确地
表明它不是*内部类。
warning:忽略匿名内部类
(jnamed $ 1)的InnerClasses属性,该属性不包含
关联的EnclosingMethod属性。这个类可能是由一个
编译器生成的,它没有针对现代.class文件格式。推荐的
解决方案是使用最新的编译器
从源代码重新编译该类,而不指定任何-target类型选项。忽略
这个警告的结果是这个类的反射操作不正确地
表明它不是*内部类。
warning:忽略匿名内部类
(jnamed $ 2)的InnerClasses属性,该属性不包含
关联的EnclosingMethod属性。这个类可能是由一个
编译器生成的,它没有针对现代.class文件格式。推荐的
解决方案是使用最新的编译器
从源代码重新编译该类,而不指定任何-target类型选项。忽略
这个警告的结果是这个类的反射操作不正确地
表明它不是*内部类。
意外的顶级例外:
com.android.dx.cf.iface.ParseException:在com.android.dx.cf中的错误的类文件magic(cafebabe)或版本(0034.0000)
.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf .direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command .dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command .dexer.Main.access $ 300(Main.java:83)
at com.android.dx.command.dexer.Main $ 1.processFileBytes(Main.java:602)
at com.android.dx .cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:244)
at com.android.dx.command.dexer.Main.main(Main.java:215)
在com.android.dx.command.Main.main(Main.java:106)
...解析net / java / otr4j / OtrException.class
2错误;中止
错误:任务':app:dexBetaDebug'的执行失败。
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java''已完成非零退出值1
信息:BUILD FAILED
信息:总时间:18.654秒
信息:1个错误
信息:0个警告
信息:查看完整输出到控制台

应用Gradle文件:

  apply plugin:'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion22.0.1

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 193
versionName'1.0.21'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
// ge的问题neratedapplicationId字符串资源
禁用'MissingTranslation'
}

productFlavors {
$ b $ dev {
applicationIdcom.xabber.androiddev
resValue'string','application_package',applicationId
}

beta {
applicationIdcom.xabber.android.beta
resValue'字符串','application_package',applicationId
}

}
}

储存库{
mavenCentral()
}

依赖项{
compile'c​​om.android.support:design:22.2.0'
compile'c​​om.android.support:appcompat-v7:22.2.0'
编译'com.android.support:support-v13:22.2.0'
编译'com.github.ksoichiro:android-observablescrollview:1.5.0'
编译'de.hdodenhof:circleimageview:1.2 .2'
compile'c​​om.melnykov:floatingactionbutton:1.2.0'
compile'dnsjava :dnsjava:2.1.7'
compile'c​​om.github.bumptech.glide:glide:3.6.0'
编译项目('otr4j')
}

otr4j Gradle文件:

 存储库{
mavenCentral()
}
apply plugin:'java-library-distribution'

dependencies {
compile'org.bouncycastle:bcprov- jdk15on:1.49'
testCompile'junit:junit:4.11'
testCompile'org.mockito:mockito-all:1.9.5'
testCompile'org.apache.commons:commons-lang3: 3.3.2'
}

Xabber Gradle文件:

  //顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。 
buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle:1.2.3'



allprojects {
知识库{
jcenter()
}
}

谢谢 所以我在此


I tried importing Xabber ( GitHub ) within Android Studio , I did the git init etc .Now I find that I can start the app for that problem Gradle , I've looked everywhere , but could not find anything that would work ..

The problem is:

Error:Execution failed for task ':app:dexBetaDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

Stack:

Information:Gradle tasks [:app:assembleBetaDebug]
:app:preBuild UP-TO-DATE
:app:preBetaDebugBuild UP-TO-DATE
:app:checkBetaDebugManifest
:app:preBetaReleaseBuild UP-TO-DATE
:app:preDevDebugBuild UP-TO-DATE
:app:preDevReleaseBuild UP-TO-DATE
:app:otr4j:compileJava UP-TO-DATE
:app:otr4j:processResources UP-TO-DATE
:app:otr4j:classes UP-TO-DATE
:app:otr4j:jar UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2220Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72102Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV132220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareComGithubKsoichiroAndroidObservablescrollview150Library UP-TO-DATE
:app:prepareComMelnykovFloatingactionbutton120Library UP-TO-DATE
:app:prepareDeHdodenhofCircleimageview122Library UP-TO-DATE
:app:prepareBetaDebugDependencies
:app:compileBetaDebugAidl UP-TO-DATE
:app:compileBetaDebugRenderscript UP-TO-DATE
:app:generateBetaDebugBuildConfig UP-TO-DATE
:app:generateBetaDebugAssets UP-TO-DATE
:app:mergeBetaDebugAssets UP-TO-DATE
:app:generateBetaDebugResValues UP-TO-DATE
:app:generateBetaDebugResources UP-TO-DATE
:app:mergeBetaDebugResources UP-TO-DATE
:app:processBetaDebugManifest UP-TO-DATE
:app:processBetaDebugResources UP-TO-DATE
:app:generateBetaDebugSources UP-TO-DATE
:app:processBetaDebugJavaRes UP-TO-DATE
:app:compileBetaDebugJava UP-TO-DATE
:app:compileBetaDebugNdk UP-TO-DATE
:app:compileBetaDebugSources UP-TO-DATE
:app:collectBetaDebugMultiDexComponents UP-TO-DATE
:app:packageAllBetaDebugClassesForMultiDex UP-TO-DATE
:app:shrinkBetaDebugMultiDexComponents UP-TO-DATE
:app:createBetaDebugMainDexClassList UP-TO-DATE
:app:dexBetaDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.processClass(Main.java:704)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
    at com.android.dx.command.dexer.Main.access$300(Main.java:83)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:632)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:490)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:244)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
...while parsing net/java/otr4j/OtrEngineHost.class
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xbill.DNS.UDPClient$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(jnamed$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.processClass(Main.java:704)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
    at com.android.dx.command.dexer.Main.access$300(Main.java:83)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:632)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:244)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
...while parsing net/java/otr4j/OtrException.class
2 errors; aborting
Error:Execution failed for task ':app:dexBetaDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 18.654 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

App Gradle File:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 193
        versionName '1.0.21'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    lintOptions {
        // problems with generated "applicationId" string resource
        disable 'MissingTranslation'
    }

    productFlavors {

        dev {
            applicationId "com.xabber.androiddev"
            resValue 'string', 'application_package', applicationId
        }

        beta {
            applicationId "com.xabber.android.beta"
            resValue 'string', 'application_package', applicationId
        }

    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v13:22.2.0'
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
    compile 'de.hdodenhof:circleimageview:1.2.2'
    compile 'com.melnykov:floatingactionbutton:1.2.0'
    compile 'dnsjava:dnsjava:2.1.7'
    compile 'com.github.bumptech.glide:glide:3.6.0'
    compile project('otr4j')
}

otr4j Gradle File:

repositories {
    mavenCentral()
}
apply plugin: 'java-library-distribution'

dependencies {
    compile 'org.bouncycastle:bcprov-jdk15on:1.49'
    testCompile 'junit:junit:4.11'
    testCompile 'org.mockito:mockito-all:1.9.5'
    testCompile 'org.apache.commons:commons-lang3:3.3.2'
}

Xabber Gradle File:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

thanks

解决方案

So I have found the solution at this http://www.alonsoruibal.com/my-gradle-tips-and-tricks/.

The trick is in your Java Library module's build.gradle file you need to include the following.

apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6

Wrong Java Compiler When Including a Java Module as Dependency in Android Studio

这篇关于Android Studio和gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:50