CANT项目摇篮迁移的Andr​​oid工作室摇篮、工作室、项目、CANT

2023-09-05 01:59:29 作者:37℃梦

我有我的机器人工作室已经运行项目。

I have a project that I already run in Android Studio.

我已经开了Android的工作室我得到的消息项目后:

After I've opened the project in Android Studio I got the message:

项目迁移到摇篮? 本项目不使用摇篮构建系统。我们建议您迁移到使用摇篮构建系统。 有关迁移到摇篮更多信息 不要再显示此消息。

Migrate Project to Gradle? This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system. More Information about migrating to Gradle Don't show this message again.

更多信息有关迁移到摇篮虽然我已经在 Android的工作室我跟着选项Migrating从项目的IntelliJ 。

Following the link of More Information about migrating to Gradle although I'm already on Android Studio I've followed the option Migrating from IntelliJ Projects .

既然我已经有一个 build.gradle 文件在我的项目的根,我修改,包括一些依赖。

Since I've already have a build.gradle file at the root of my project I've modified to include some dependencies.

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

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

    compile "com.android.support:support-v4:18.0.+"
    compile "com.android.support:appcompat-v7:18.0.+"
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

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

按照指示,我已经跑了摇篮assembleDebug Android的工作室终端窗口,但被得到一些错误。为了解决这个错误,我要创建一个 local.properties sdk.dir = C:\\程序文件(x86)\\的Andr​​oid \\ Android的SDK 并从该 Android的支持 - v4.jar 文件 /库文件夹,并从 Libraries-&GT;库项目结构

As instructed, i've ran gradle assembleDebug on the Android Studio terminal windows but was getting some errors. To solve this errors I had to create a local.properties with sdk.dir=C:\\Program Files (x86)\\Android\\android-sdk and remove the android-support-v4.jar file from the /libs folder and from the Libraries->libs from the Project Structure.

我现在又跑摇篮assembleDebug 这一次,它完成且没有任何错误。

I now ran again gradle assembleDebug and this time it finishes without any errors.

我已经重新启动 Android的工作室但在重新启动后,我已经看到在外部库项目没有支持-V4 appcompat-V7 在我的班级之一,我有进口android.support.v4.widget.CursorAdapter; ,因为无法解析符号光标适配器

I've restarted Android Studio but after restarting I've saw that on the External Libraries of the project there were no support-v4 and appcompat-v7 and in one of my classes I have the import android.support.v4.widget.CursorAdapter; marked as error since Cannot resolve symbol Cursor Adapter.

如果我preSS的按钮,我得到的消息同步项目摇篮文件项目MyProject的是不是一个摇篮为基础的项目

If I press the button Sync project with gradle filesi got the message: The project MyProject is not a Gradle-based project

有人可以帮助我弄清楚如何解决此问题?

Can someone help me figuring out how to solve this?

下面是我的项目结构

推荐答案

该项目认为,它仍然是一个非摇篮基础的项目;它不是在的presence build.gradle 的文件,使之摇篮为主,但它的项目是如何设置摆在首位。你需要重新导入您的项目,以完成转换到摇篮。

The project thinks it's still a non-Gradle based project; it's not the presence of the build.gradle file that makes it Gradle-based, but it's how the project was set up in the first place. You'll need to re-import your project to finish the conversion to Gradle.

不过,首先,它看起来像你没有一个 settings.gradle 的文件;它看起来像你需要一个。既然你已经设置了您的项目作为一个单独的模块项目,那么你可以把你的项目的根目录下的文件,旁边的 build.gradle。它应该包含这样的:

First, though, it looks like you don't have a settings.gradle file; it looks like you need one. Since you've set up your project as a single-module project, then you can put the file in your project's root directory, next to build.gradle. It should contain this:

import ':'

在以后如果添加更多的模块到你的项目,你可能需要将其转换为一个多模块的目录结构,但你并不需要担心,现在。在任何情况下,现在你需要做重新导入Android中工作室:

In the future if you add more modules to your project you may want to convert it to a multi-module directory structure, but you don't need to worry about that now. In any event, now you need to do the re-import in Android Studio:

关闭项目 备份你的项目 删除 .idea 文件夹中的项目的根目录 删除所有的 .iml 项目中的文件 导入Android的工作室项目,并提示您输入文件的对话框中,选择 build.gradle 文件。 Close your project Back up your project Delete the .idea folder in the root directory of the project Delete all the .iml files in your project Import your project in Android Studio, and in the dialog that prompts you for a file, choose the build.gradle file.

在此,你应该是好去。