如何将 eclipse 库项目从 github 导入到 android studio 项目? [英] How to import eclipse library project from github to android studio project?
问题描述
我想在我的 android studio 项目中使用 ),因此您必须为库编写自己的构建文件.实际上,使用新建模块"向导设置构建文件和目录结构可能更容易,然后您可以将其修剪并复制文件.这组步骤应该可以让您启动并运行.这似乎有很多步骤,但希望它应该会很快.
- 从文件菜单中,选择新建模块...
- 从出现的向导中,选择 Android 库
- 在向导的下一页中,为其指定模块名称 HoloCircularProgressBar,并取消选中创建自定义启动器图标 和创建活动 的选项.
- 单击向导上的完成".
它应该将新模块添加到您的项目中,因此您最终会得到这样的结果:
- 删除 src/main 文件夹中的所有内容.
- 现在从 HoloCircularProgressBar 复制
AndroidManfiest.xml
、ic_launcher-web.png
、res
和src
源到src/main
文件夹. - 将刚刚复制到
src/main
中的src
文件夹重命名为java
. - 新模块向导在
HoloCircularProgresBar
模块/目录中的build.gradle
文件中留下了一些东西(确保您正在编辑那个,而不是用于您的主应用程序模块)我们不需要.删除dependencies
块和release
块.
此时您应该希望能够成功构建.现在,如果您想实际使用该模块:
- 转到文件 > 项目结构... > 模块 > 您的主模块 > 依赖.
- 单击 + 按钮添加依赖项,选择模块依赖项,然后从列表中选择
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.
- From the File menu, choose New Module...
- From the wizard that comes up, choose Android Library
- 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.
- Click Finish on the wizard.
It should add the new module to your project, so you'll end up with something like this:
- Delete everything inside the src/main folder.
- Now copy
AndroidManfiest.xml
,ic_launcher-web.png
,res
, andsrc
from the HoloCircularProgressBar source into thesrc/main
folder. - Rename the
src
folder that you just copied intosrc/main
tojava
. - The New Module wizard left some things in the
build.gradle
file in yourHoloCircularProgresBar
module/directory (make sure you're editing that one, not the one for your main app module) we don't need. Remove thedependencies
block and therelease
block.
At this point you should hopefully be able to build successfully. Now if you want to actually use the module:
- Go to File > Project Structure... > Modules > Your main module > Dependencies.
- 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屋!