【问题标题】:Cannot import an Android project from Eclipse to Android Studio after building a build.gradle file构建 build.gradle 文件后,无法将 Android 项目从 Eclipse 导入 Android Studio
【发布时间】:2015-07-29 17:30:50
【问题描述】:

我从 Eclipse 生成了一个 Android 项目的 Gradle 文件,以便继续在 Android Studio 中处理该项目。然后我导入 Gradle 文件在 Android Studio 中打开项目,但是非常令人困惑的是它无法构建项目,显示以下消息。

Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

我一直在 Android Studio 中处理其他 Android 项目,在这个问题上没有任何问题,所以我变得太困惑了。我也搜索了有关同一问题的问题,但似乎没有一个明确提出解决方案。

为了让你更好地理解,我给你展示了一些与构建项目相关的东西。

1. build.gradle

 apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:appcompat-v7:22.2.0'
    }

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc3"

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

2。 local.properties

sdk.dir=/Users/marshall/android-sdks

Android SDK 已按上述方向正确安装。我现在该怎么办?

【问题讨论】:

    标签: android eclipse gradle android-gradle-plugin


    【解决方案1】:

    在 ANDROID STUDIO 中导入 ECLIPSE 项目:

    如果你想在 Android Studio 中导入 Eclipse 项目:

    1. 启动 Android Studio选择 导入项目(Eclipse ADT、Gradle等.)

    2.然后没有什么特别的,只需按照向导中的说明进行操作即可。

    注意: 只需确保您选择了包含 src 文件夹的 Eclipse 项目文件夹。并确保目标文件夹为空。 您无需创建 build.gradle 或从 eclipse 导出任何内容,因为 Android Studio 不再需要此步骤

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      • 2015-12-25
      • 1970-01-01
      相关资源
      最近更新 更多