如何在机器人工作室引入外部库? [英] How to import external library in android studio?

查看:170
本文介绍了如何在机器人工作室引入外部库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难导入库PageSlidingTapStrip(<一href="https://github.com/astuetz/PagerSlidingTabStrip">https://github.com/astuetz/PagerSlidingTabStrip).

I struggle to import library 'PageSlidingTapStrip'(https://github.com/astuetz/PagerSlidingTabStrip).

我发现这个问题(<一href="http://stackoverflow.com/questions/20310164/how-to-import-eclipse-library-project-from-github-to-android-studio-project">How从github上导入Eclipse库项目到Android Studio项目?),我按照这个解决方案。

I found this question(How to import eclipse library project from github to android studio project?), and I follow this solution.

CF),我使用的是赢得8.1,Android的演播室版本0.3.6

cf)I'm using win 8.1 , android studio version 0.3.6

首先,建立这样的条件下新的项目。

First, build new project like this condition.

二,进入文件 - >新建模块点击,创造新的模块的Andr​​oid库,使病情是这样的(未选中创建自定义启动器图标,活动)

Second, go to File -> New Module click, create new module as android library and make condition like this.( Unchecked create custom launcher icon, activity )

这部分我得到了第一个问题。哪个版本我应该选择版本关于最低要求SDK,目标SDK,编译与'?只需按照项目版本? (当我第一次创建此窗口的图像显示的默认值。)

And this part I got a first question. Which version should I choice version about 'Minimum required SDK' , 'Target SDK', 'Compile with'? Just Follow project version? (image show default value when I create this window first.)

不管怎样,我的条件下进步要求的最低SDK:API 9 /目标SDK:API 19 /编译有:API 19

Anyway, I progress under condition ' Minimum required SDK : API 9 / Target SDK : API 19 / Compile with : API 19 '

第三,在删除文件项目/ PageSlidingTabStrip / src目录/主/'和复制文件夹和放大器;在外部库水库,SRC,AndroidManifest.xml中文件,并进入项目/ PageSlidingTabStrip / src目录/主/,然后重命名SRC到Java。

Third, delete files under 'Project/PageSlidingTabStrip/src/main/' and copy folder&file under external library 'res', 'src', 'AndroidManifest.xml' and move into 'Project/PageSlidingTabStrip/src/main/' then renamed src to java.

然后项目和放大器;文件夹变成了这个样子。 (我跟着的问题是,告诉我从'水库'复制和移动文件ic_launcer-web.png分开,SRC,清单,但我无法找到该文件)

And then project & folder become like this. (what I followed question as , told me copy and move file 'ic_launcer-web.png' apart from 'res', 'src', 'manifest' , but I can't find that file)

四,进入文件 - >项目设置 - >模块 - >单击项目模块 - >+按钮 - >选择模块依赖然后应用。

Fourth, go to 'File -> Project setting -> Module -> click project module -> '+' button -> select Module dependency' then apply.

在这之后,我面对这个错误,无法解决R. 我不能走下一步,无法完成导入库。 我该怎么办?

After that, I face this error and cannot resolve R. And I can't go next step, can't finish import library. What should I do?

有没有其他解决办法?

感谢您看长的问题。我希望能得到解决!

Thanks for seeing long question. I hope to get a solution!

推荐答案

我还使用了 PagerSlidingTabStrip 项目在我的应用程序,一切工作正常。 我不知道,如果它已经可以通过IDE添加一个库项目( - >没有任何问题)。 请尝试通过编辑文件摇篮这样添加库项目:

I also use the PagerSlidingTabStrip Project in my app and everything works fine. I'm not sure if it's already possible to add a library project via the IDE (-> without any problems). Please try to add the library project by editing the gradle files like this:

  • 先删除你的模块 PagerSlidingTabStrip
  • 然后在您的项目根目录创建一个文件夹( - > NewOne )命名为库
  • 在混帐的 PagerSlidingTabStrip 项目的整个文件夹图书馆复制到库
  • 重命名文件夹图书馆您刚才复制到如PagerSlidingTabStripLibrary(只是为了避免混淆) - >后重命名你应该有以下路径:NewOne /库/ PagerSlidingTabStripLibrary
  • 现在添加此库的 settings.gradle 用下面的命令:

  • first delete your module PagerSlidingTabStrip
  • then create a folder in your root project directory (-> NewOne) named 'libs'
  • copy the complete folder 'library' of the PagerSlidingTabStrip project on git into 'libs'
  • rename the folder 'library' that you just copied to e.g. "PagerSlidingTabStripLibrary" (just to avoid confusion) -> after the renaming you should have the path: "NewOne/libs/PagerSlidingTabStripLibrary"
  • now add this library in your settings.gradle with the following command:

include ':libs:PagerSlidingTabStripLibrary'

  • 去你AppProject你的 build.gradle 文件 APS 并添加下面一行到你依赖:

  • go to your build.gradle file of your AppProject aps and add the following line to your 'dependencies':

    compile project(':libs:PagerSlidingTabStripLibrary')
    

  • 至少你必须同步您的摇篮文件:工具 - > Android的 - >同步工程与摇篮文件

  • at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files

    请试试这个。如果出现错误,请张贴日志文件。

    Please try this. If you get errors please post the log file.

    这篇关于如何在机器人工作室引入外部库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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