如何将eclipse库项目从github导入到android studio项目中? [英] How to import eclipse library project from github to android studio project?

查看:228
本文介绍了如何将eclipse库项目从github导入到android studio项目中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android工作室项目中使用),因此您必须为库创建自己的构建文件。实际上,使用新建模块向导可能会更容易地设置构建文件和目录结构,然后可以对其进行修剪并复制文件。这套步骤应该让你开始运行。似乎很多步骤,但希望能够快速地进行。


  1. 文件菜单中选择新模块...

  2. 从出现的向导中,选择 Android库

  3. 从向导的下一页中,给出模块名称HoloCircularProgressBar,并取消选中创建自定义启动器图标创建活动的选项。

  4. 在向导中单击完成。

它应该将新模块添加到项目中,所以最终会这样的一个例子:




  1. 删除src / main文件夹中的所有内容。

  2. 复制 AndroidManfiest.xml ic_launcher-web.png res ,和 src 从HoloCircularProgressBar源插入到 src / main 文件夹中。

  3. 将您刚刚复制到 src / main src 文件夹重命名为 java

  4. 新建模块向导在您的<$ c $中的 build.gradle 文件中留下了一些内容c> HoloCircularProgresBar module / directory(确保你正在编辑那个,而不是你的主应用程序模块),我们不需要。删除依赖关系块和版本块。

在这一点上,您应该希望能够成功构建。现在,如果你想实际使用这个模块:


  1. 转到文件> 项目结构... > 模块> 您的主要模块> 依赖关系

  2. 点击+按钮添加依赖关系,选择模块依赖关系,然后从中选择 HoloCircularProgressBar 列表。

现在 import 库的语句和用法应该可以工作,你应该很好去。


I want to use HoloCircullarProgressBar as a library project in my android studio project. I tried to do it by copying into pre-created "library" folder in my project and then to add it to project in "Project Structure". But it's not working somehow.

Could anyone give a very specific step-by-step tutorial on how to do that in android studio 0.3.6?

解决方案

If you're importing a library as source code into a Gradle-based project, then at the moment there's no super-easy way to do it (sorry, it's on the to-do list, see https://code.google.com/p/android/issues/detail?id=62122) so you'll have to author your own build file for the library. Actually, it might be easier to use the New Module wizard to set up the build file and directory structure, then you can trim it down and copy the files over. This set of steps should get you up and running. It seems like a lot of steps but it should hopefully go pretty quick.

  1. From the File menu, choose New Module...
  2. From the wizard that comes up, choose Android Library
  3. From the next page of the wizard, give it the module name HoloCircularProgressBar, and uncheck the options for Create custom launcher icon and Create activity.
  4. Click Finish on the wizard.

It should add the new module to your project, so you'll end up with something like this:

  1. Delete everything inside the src/main folder.
  2. Now copy AndroidManfiest.xml, ic_launcher-web.png, res, and src from the HoloCircularProgressBar source into the src/main folder.
  3. Rename the src folder that you just copied into src/main to java.
  4. The New Module wizard left some things in the build.gradle file in your HoloCircularProgresBar module/directory (make sure you're editing that one, not the one for your main app module) we don't need. Remove the dependencies block and the release block.

At this point you should hopefully be able to build successfully. Now if you want to actually use the module:

  1. Go to File > Project Structure... > Modules > Your main module > Dependencies.
  2. Click on the + button to add a dependency, choose Module dependency, and select HoloCircularProgressBar from the list.

Now import statements and usages of the library should work, and you should be good to go.

这篇关于如何将eclipse库项目从github导入到android studio项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆