从eclipse迁移到android studio时出错

时间:2015-07-22 07:35:02

标签: android eclipse android-studio

你好我是android studio的新手。我有一个现有的eclipse项目,它只在(2.3.3 android api 10)上运行。

当我将现有的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
    }
}

任何人都可以帮助我。提前谢谢。

2 个答案:

答案 0 :(得分:0)

我解决了这个问题。

我只需要更改buildToolsVersion。

buildToolsVersion "10"

 buildToolsVersion "19.1.0"

现在它完美无缺。

谢谢,

答案 1 :(得分:-1)

请确保您的sdk比jdk1.7.0_67更新。  打开你的android studio首选项页面进行检查。 screenshot