简体   繁体   English

AndroidStudio:在“ Gradle”中迁移项目

[英]AndroidStudio : Migrate project in “Gradle”

I'm a french student, so i'm sorry for my english.. 我是一名法国学生,所以我对我的英语感到抱歉。

I am working on an application on Android with AndroidStudio. 我正在使用AndroidStudio在Android上开发应用程序。 I received some source code by someone. 我收到某人的一些源代码。 But when i want to open the project which i received, AndroidStudio tells me 但是当我想打开我收到的项目时,AndroidStudio告诉我

"This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system." “该项目不使用Gradle构建系统。我们建议您迁移到使用Gradle构建系统。”

And i have more information here : 我在这里有更多信息:

http://tools.android.com/tech-docs/new-build-system/intellij_to_gradle http://tools.android.com/tech-docs/new-build-system/intellij_to_gradle

But i don't understand what i have to make.. 但是我不明白我要做什么。

Thank you for your answers ! 谢谢您的回答 !

EDIT : I try to import the folder with Android Studio, but there is an error : 编辑:我尝试使用Android Studio导入文件夹,但是出现错误:

Failed to sync Gradle project 'name_project' 无法同步Gradle项目“ name_project”

Failed to find target with hash string 'android-16' in ... 无法在...中找到带有哈希字符串“ android-16”的目标

Android studio give you error whenever you try to open any non-gradle based project and failed find gradle configuration/files in your project. 每当您尝试打开任何基于非渐变的项目并在项目中找不到gradle配置/文件时,Android Studio都会给您错误。

If it's eclipse project then you just need to import it into the Android studio and it would take care of most of required things. 如果它是eclipse项目,则只需将其导入Android Studio,即可处理大多数必需的事情。

From documentation: Migrating from Eclipse projects to Android studio 从文档中: 从Eclipse项目迁移到Android Studio

Importing the Eclipse project directly into Studio. 将Eclipse项目直接导入Studio。 This is the preferred approach, and has numerous advantages: 这是首选方法,具有许多优点:

  • It will detect many source libraries (such as ActionBarSherlock) and binary libraries (eg guava.jar), and will replace these with maven dependencies instead, which means you no longer have to maintain the libraries manually 它将检测许多源库(例如ActionBarSherlock)和二进制库(例如guava.jar),并将其替换为maven依赖项,这意味着您不再需要手动维护库
  • It will rewrite the project using the new canonical Android Gradle project structure, which supports instrumentation tests in the same project as the tested code, flavor and build type specific resources, etc 它将使用新的规范Android Gradle项目结构重写该项目,该结构支持与测试代码,风味和特定于构建类型的资源等在同一项目中的检测测试。

You do not have nothing to worry about. 您没有什么可担心的。 When Ever you try to open the Eclipse project into a Android studio , this is a question that is asked by Android studio, to move up to gradle , as Android studio uses Gradle to build the applications. 当Ever尝试将Eclipse项目打开到Android Studio中时,这是Android Studio提出的一个问题,因为Android Studio使用Gradle来构建应用程序,所以这个问题一直没有解决。

So you just need to import that project into the android studio, android studio would take care of code itself. 因此,您只需要将该项目导入到android studio中,android studio就会自己处理代码。 If that eclipse project was using some kind of library , then let the android studio download the library and add them in the dependency 如果那个eclipse项目正在使用某种库,那么让android studio下载该库并将其添加到依赖项中

well you can do this manually. 好吧,您可以手动执行此操作。

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

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