繁体   English   中英

如何在Android Studio中正确导入Android项目?

[英]How to properly import Android projects in Android studio?

我已经与Android Studio战斗了2天,因为我无法在IDE中导入2个eclipse项目。

这些项目是2个Eclipse项目,我通过执行FILE> EXPORT> Generate build.gradle文件将其导出。

当我尝试在Android Studio中导入项目时,出现此错误:

Failed to refresh Gradle project 'SourceFiles'
You are using Gradle version 1.11, which is not supported. Please use version 1.9.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Fix Gradle wrapper and re-import project Gradle settings

如您所见,我使用了最新版的gradle(1.11版),但仍然无法正常工作。 有人可以告诉我在Android Studio中导入这些项目的正确方法吗?

我在Linux OpenSuse版本13.1 Android Studio:0.4.2 Java:1.7

[编辑]我的项目由目录Sourcefiles组成,其中包含2个子目录SkeletonsTestcase Skeletons包含源文件, TestCase包含与Skeletons中与项目关联的测试用例。

这是Eclipse生成的build.gradle:在SourceFiles级别:

task wrapper(type: Wrapper) {
    gradleVersion = '1.9'
}

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

在“骨骼”级别:

android {
    compileSdkVersion 18
    buildToolsVersion "19.0.2"

    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')
    }
}

在测试用例级别的目录中:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':Skeletons:FragmentsLab')
}

android {
    compileSdkVersion 18
    buildToolsVersion "19.0.2"

    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')
    }
}

我还必须承认,我仍然是菜鸟。 我还在canary频道中更新了Android Studio的最新版本,并在我的项目中引用了gradle的Verison 1.9。 任何帮助,将不胜感激。

我想使用Eclipse IDE,但是它一直崩溃。

最新的gradle版本有很多问题,您应该尝试使用旧版本,1.9很好。 将其添加到root build.gradle并从控制台运行gradle wrapper

task wrapper(type: Wrapper) {
    gradleVersion = '1.9'
}

它应该在您的项目中创建一个gradle路径。 此后,在Android Studio中创建项目时, gradle在命令行中使用gradlew代替gradle或选择“可自定义的gradle包装器”选项。

如果你会遇到其他问题与版本改变的值distributionUrlgradle\\wrapper\\gradle-wrapper.properties

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM