【问题标题】:Migration from Eclipse to Android Studio issues从 Eclipse 迁移到 Android Studio 问题
【发布时间】:2015-12-28 03:32:11
【问题描述】:

我正在尝试将我的项目从 Eclipse 移动到 Android Studio。 我尝试了两种方法:

  • 在 Android Studio IDE 中使用 Import 导入当前项目。

  • 将当前项目导出为成绩项目

(虽然我没有等级 在我的eclipse项目中设置),然后将其导入Android Studio。

使用第一种方法时,我遇到了 gradle 和 API 错误,例如:

没有可用于 com.android.support:support-v4:jar 的版本 (我安装了 22 和 23 sdk,它们都没有解决问题)。

错误:(15, 0) Gradle DSL 方法未找到: 'android()' 可能 原因:该项目可能正在使用的 Gradle 版本 不包含方法。摇篮 settings.构建文件可能缺少 Gradle 插件。应用 Gradle 插件

使用项目资源管理器中的第二种方法,我只看到没有 res 文件夹的 Java src 文件。

这是 Gradle 代码:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}
apply plugin: 'com.android.application'

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

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.0'

    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')
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

正确的方法是什么? 我这样做基本上是为了将 Gradle 添加到我的项目中。

谢谢!

【问题讨论】:

标签: java android eclipse android-studio android-gradle-plugin


【解决方案1】:

你用第一种方式去改变安卓支持版本。

步骤: 您转到打开模块设置,然后删除旧的依赖项。 并选择下面的支持文件,然后同步项目。

第 23 版: 支持-v4 (com.android.support:support-v4:23.0.1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多