2016-06-30 105 views
0

林建設上一個離子的應用程序,當我運行此::transformClassesWithDexForDebug錯誤建築離子應用

 ionic build android 

它給了我這樣的:

:compileDebugSources UP-TO-DATE 
:transformClassesWithDexForDebugjava.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 
     at java.lang.ClassLoader.defineClass1(Native Method) 
     FAILED 
     ..... 
     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) 
Exception in thread "main" 

BUILD FAILED 

Total time: 3.567 secs 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':transformClassesWithDexForDebug'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\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. 
Error: Error code 1 for command: cmd with args: /s,/c,"C:\Users\ggfre\Desktop\primerapp\platforms\android\gradlew cdvBuildDebug -b C:\Users\ggfre\Desktop\primerapp\platforms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true" 

我真的不知道還有什麼這樣做,我已經修改了文件的gradle並重新安裝了Android SDK

回答

0

這是我的gradle這個文件:

android { 
    compileSdkVersion 24 
    buildToolsVersion '24' 
    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
      jniLibs.srcDirs = ['libs'] 
     } 
    } 

    defaultConfig { 
     versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0") 
     applicationId privateHelpers.extractStringFromManifest("package") 
     targetSdkVersion 21 


     if (cdvMinSdkVersion != null) { 
      minSdkVersion cdvMinSdkVersion 
     } 
    } 

    lintOptions { 
     abortOnError false; 
    } 

    compileSdkVersion cdvCompileSdkVersion 
    buildToolsVersion cdvBuildToolsVersion 

    if (Boolean.valueOf(cdvBuildMultipleApks)) { 
     productFlavors { 
      armv7 { 
       versionCode defaultConfig.versionCode + 2 
       ndk { 
        abiFilters "armeabi-v7a", "" 
       } 
      } 
      x86 { 
       versionCode defaultConfig.versionCode + 4 
       ndk { 
        abiFilters "x86", "" 
       } 
      } 
      all { 
       ndk { 
        abiFilters "all", "" 
       } 
      } 
     } 
    } else if (!cdvVersionCode) { 
     def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion") 
     // Vary versionCode by the two most common API levels: 
     // 14 is ICS, which is the lowest API level for many apps. 
     // 20 is Lollipop, which is the lowest API level for the updatable system webview. 
     if (minSdkVersion >= 20) { 
     defaultConfig.versionCode += 9 
     } else if (minSdkVersion >= 14) { 
     defaultConfig.versionCode += 8 
     } 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    if (cdvReleaseSigningPropertiesFile) { 
     signingConfigs { 
      release { 
       // These must be set or Gradle will complain (even if they are overridden). 
       keyAlias = "" 
       keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph. 
       storeFile = null 
       storePassword = "__unset" 
      } 
     } 
     buildTypes { 
      release { 
       signingConfig signingConfigs.release 
      } 
     } 
     addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release) 
    } 
    if (cdvDebugSigningPropertiesFile) { 
     addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug) 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    // SUB-PROJECT DEPENDENCIES START 
    debugCompile project(path: "CordovaLib", configuration: "debug") 
    releaseCompile project(path: "CordovaLib", configuration: "release") 
    // SUB-PROJECT DEPENDENCIES END 
} 

def promptForReleaseKeyPassword() { 
    if (!cdvReleaseSigningPropertiesFile) { 
     return; 
    } 
    if ('__unset'.equals(android.signingConfigs.release.storePassword)) { 
     android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ') 
    } 
    if ('__unset'.equals(android.signingConfigs.release.keyPassword)) { 
     android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: '); 
    } 
} 

gradle.taskGraph.whenReady { taskGraph -> 
    taskGraph.getAllTasks().each() { task -> 
     if (task.name == 'validateReleaseSigning') { 
      promptForReleaseKeyPassword() 
     } 
    } 
} 
2

嘗試改變buildToolsVersion '24'buildToolsVersion '23 .0.2'