无法在模拟器上运行应用程序"任务执行失败':app:transformClassesWithDexForDebug'"

时间:2016-04-16 11:09:04

标签: java android android-emulator

我有一个问题,最近很烦人。我刚开始使用Android Studio,我正在关注lynda.com的课程。我设置了AVD,效果很好。然后我创建默认" Hello World"应用程序 - 它已经无法在设备上运行了!

它会抛出以下错误日志:  

 AGPBI: {"kind":"error","text":"java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass1(Native Method)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass(ClassLoader.java:800)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.defineClass(URLClassLoader.java:449)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.access$100(URLClassLoader.java:71)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:361)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:355)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.security.AccessController.doPrivileged(Native Method)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.findClass(URLClassLoader.java:354)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:425)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:358)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)","sources":[{}]}
AGPBI: {"kind":"error","text":"Exception in thread \"main\" ","sources":[{}]}

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'.

    com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.604 secs

AGPBI: {"kind":"error","text":"java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass1(Native Method)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass(ClassLoader.java:800)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.defineClass(URLClassLoader.java:449)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.access$100(URLClassLoader.java:71)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:361)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:355)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.security.AccessController.doPrivileged(Native Method)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.findClass(URLClassLoader.java:354)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:425)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:358)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)","sources":[{}]} AGPBI: {"kind":"error","text":"Exception in thread \"main\" ","sources":[{}]}

我试图参考其他问题中看到的解决方案,但它们都不适合我。有任何想法吗?我没有在创建的空白活动中更改任何内容。

此处还有我的顶级Gradle代码:

    <pre><code>

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "24.0.0 rc3"

        defaultConfig {
            applicationId "com.example.hsport.catalog"
            minSdkVersion 16
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            //multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.3.0'
        compile 'com.android.support:design:23.3.0'
    }

</pre></code>

And the App-level:

<pre><code>

    // 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:2.0.0'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files


}
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:3)

  

build.gradle中的更改

buildToolsVersion "24.0.0 rc3"

buildToolsVersion "23.3.0"