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

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

问题描述

我想在我的 android studio 项目中使用 ),因此您必须为库编写自己的构建文件.实际上,使用新建模块"向导设置构建文件和目录结构可能更容易,然后您可以将其修剪并复制文件.这组步骤应该可以让您启动并运行.这似乎有很多步骤,但希望它应该会很快.

  1. 文件菜单中,选择新建模块...
  2. 从出现的向导中,选择 Android 库
  3. 在向导的下一页中,为其指定模块名称 HoloCircularProgressBar,并取消选中创建自定义启动器图标创建活动 的选项.
  4. 单击向导上的完成".

它应该将新模块添加到您的项目中,因此您最终会得到这样的结果:

  1. 删除 src/main 文件夹中的所有内容.
  2. 现在从 HoloCircularProgressBar 复制 AndroidManfiest.xmlic_launcher-web.pngressrc源到 src/main 文件夹.
  3. 将刚刚复制到 src/main 中的 src 文件夹重命名为 java.
  4. 新模块向导在 HoloCircularProgresBar 模块/目录中的 build.gradle 文件中留下了一些东西(确保您正在编辑那个,而不是用于您的主应用程序模块)我们不需要.删除 dependencies 块和 release 块.

此时您应该希望能够成功构建.现在,如果您想实际使用该模块:

  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天全站免登陆