2015-07-22 96 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

相关问题