2015-07-22 94 views
-1

你好我是android studio的新手。我有一個現有的eclipse項目,只能運行在(2.3.3 android api 10)上。從eclipse遷移到android studio時出錯

當我將現有的eclipse項目遷移到android studio。我面臨着錯誤。

Error:Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'. 
Possible causes for this unexpected error include: 
You are using JDK version 'java version "1.7.0_75"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle. 
Please update to a newer version (e.g. 1.7.0_67). 
Open JDK Settings 
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) 
Re-download dependencies and sync project (requires network) 
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. 
Stop Gradle build processes (requires restart) 
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes. 

這是我的build.gradle文件。

apply plugin: 'android' 
buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.0.0+' 
    } 
} 

allprojects { 
    repositories { 
     mavenCentral() 
    } 
} 
dependencies { 
    compile fileTree(include: '*.jar', dir: 'libs') 
    } 
android { 
    compileSdkVersion 10 
    buildToolsVersion "10" 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
    defaultConfig { 
     minSdkVersion 8 
     targetSdkVersion 10 
    } 
} 

任何人都可以幫助我。提前致謝。

+1

錯誤說是不是它本身?請更新您的JDK。這與你的項目無關,只是你的系統。 – mhenryk

+0

我已經有了一個更新的java版本1.7.0_75。但它不起作用。 –

回答

0

我解決了這個問題。

我只需要更改我的buildToolsVersion。

buildToolsVersion "10" 

buildToolsVersion "19.1.0" 

現在,它的作品完美。

謝謝,

-1

請確保您的sdk比jdk1.7.0_67更新。 打開你的android studio首選項頁面進行檢查。 screenshot

+0

我已經檢查過它。它是最新的jdk1.7.0_75。 –

+0

我覺得很抱歉,你的sdk版本比main(1.7.0.67)更新。 1.7.0.67適用於android studio中的gradle,你可以將你的jdk恢復到這個版本嗎? – banking

+0

順便說一句,我的gradle版本是2.4。我從這裏手動下載:https://services.gradle.org/distributions/gradle-2.4-bin.zip – banking

相關問題