I struggle to import library 'PageSlidingTapStrip'(https://github.com/astuetz/PagerSlidingTabStrip).
我很难导入库“PageSlidingTapStrip”(https://github.com/astuetz/PagerSlidingTabStrip)。
I found this question(How to import eclipse library project from github to android studio project?), and I follow this solution.
我发现了这个问题(如何将eclipse库项目从github导入到android studio项目?)
cf)I'm using win 8.1 , android studio version 0.3.6
我使用的是win 8.1, android studio 0.3.6版本
First, build new project like this condition.
首先,构建这样的新项目。
Second, go to File -> New Module click, create new module as android library and make condition like this.( Unchecked create custom launcher icon, activity )
其次,点击File ->新建模块,创建新的模块作为android库,并设置如下条件。(未选中创建自定义启动图标、活动)
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”、“目标SDK”、“编译与”,我应该选择哪个版本?按照项目的版本吗?(我先创建这个窗口时,图像显示默认值。)
Anyway, I progress under condition ' Minimum required SDK : API 9 / Target SDK : API 19 / Compile with : API 19 '
无论如何,我在条件“最低要求SDK: API 9 / Target SDK: API 19 /编译with: API 19”的条件下取得了进展。
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.
第三,删除'Project/PageSlidingTabStrip/src/main/'下的文件,复制外部库'res'、'src'、'AndroidManifest '下的folder&file。然后转到“Project/PageSlidingTabStrip/src/main/”,然后将src改名为java。
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)
然后项目和文件夹变成这样。(我根据问题a,告诉我复制和移动文件'ic_launcer-web。png'除了'res', 'src', 'manifest',但我找不到那个文件)
Fourth, go to 'File -> Project setting -> Module -> click project module -> '+' button -> select Module dependency' then apply.
第四,去“文件->项目设置->模块->点击项目模块-> '+'按钮->选择模块依赖”然后应用。
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?
之后,我面对这个错误,不能解决r,我不能走下一步,不能完成导入库。我应该做什么?
Is there any other solution?
还有别的办法吗?
Thanks for seeing long question. I hope to get a solution!
谢谢大家的提问。我希望得到一个解决方案!
3 个解决方案
#1
7
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项目,一切正常。我不确定是否可以通过IDE(->毫无问题地添加库项目)。请尝试通过编辑如下等级文件来添加图书馆项目:
- first delete your module
PagerSlidingTabStrip
- 首先删除您的模块PagerSlidingTabStrip。
- then create a folder in your root project directory (->
NewOne
) named 'libs' - 然后在根项目目录(-> NewOne)中创建一个名为“libs”的文件夹
- copy the complete folder 'library' of the
PagerSlidingTabStrip
project on git into 'libs' - 将PagerSlidingTabStrip项目的完整文件夹“库”复制到“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"
- 将刚才复制的文件夹重命名为“library”。“PagerSlidingTabStripLibrary”(为了避免混淆)——重命名之后,>应该有这样的路径:“NewOne/libs/PagerSlidingTabStripLibrary”
-
now add this library in your
settings.gradle
with the following command:现在在设置中添加这个库。等级与以下命令:
include ':libs:PagerSlidingTabStripLibrary'
-
go to your
build.gradle
file of your AppProjectaps
and add the following line to your 'dependencies':去您的构建。您的AppProject aps的渐变文件,并在您的“依赖项”中添加以下行:
compile project(':libs:PagerSlidingTabStripLibrary')
-
at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files
至少你必须同步你的等级文件:工具-> Android ->同步项目与等级文件
Please try this. If you get errors please post the log file.
请试试这个。如果您收到错误,请张贴日志文件。
#2
4
For update up to Android Studio 1.2.1.1
更新到Android Studio 1.2.1.1。
There are basically three types of dependencies which we have to add in project of android Studio
基本上我们需要在android Studio项目中添加三种依赖项
Add Normal Dependencies like Support files
添加诸如支持文件之类的正常依赖项。
- Right click on project->open module settings
- 右键单击project->打开模块设置
- Select dependencies->Now press right "+" icon button ->Select library Dependencies
- 选择依赖项->现在按右“+”图标按钮->选择库依赖项。
- Enter Name and Search
- 输入名称和搜索
- Select file and press ok button.
- 选择file并按ok按钮。
Add Git Hub Dependencies
添加Git中心附件
Find the dependencies of git repository for example compile 'com.jakewharton:butterknife:6.1.0' from https://github.com/JakeWharton/butterknife
查找git存储库的依赖关系,例如,从https://github.com/jwharton /butterknife找到“com.jakewharton:butterknife:6.1.0”
A. open build.gradle(module:app) file
B. Add lines compile 'com.jakewharton:butterknife:6.1.0'
OR
或
Follow as describe above in Normal Dependencies Step by just enter dependencies in search bar
按照上面描述的一般依赖项步骤,在搜索栏中输入依赖项
Add Jar files Dependencies
添加Jar文件附件
- Right click on project->open module settings
- 右键单击project->打开模块设置
- press left "+" icon (insert new Module) button -> Select import Jar or .AAR package->browse Jar file and finish
- 按左“+”图标(插入新模块)按钮->选择导入Jar或.AAR包->浏览Jar文件并完成
- Now select dependencies-> press right "+" icon button ->Select module Dependencies->select jar files->press ok button.
- 现在选择依赖->按右“+”图标按钮->选择模块依赖->选择jar文件->按下ok按钮。
#3
2
For what it's worth I had this problem and eventually solved it by consistently using the same sdk version & build tools across projects.
值得注意的是,我遇到了这个问题,并最终通过跨项目一致地使用相同的sdk版本和构建工具来解决它。
#1
7
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项目,一切正常。我不确定是否可以通过IDE(->毫无问题地添加库项目)。请尝试通过编辑如下等级文件来添加图书馆项目:
- first delete your module
PagerSlidingTabStrip
- 首先删除您的模块PagerSlidingTabStrip。
- then create a folder in your root project directory (->
NewOne
) named 'libs' - 然后在根项目目录(-> NewOne)中创建一个名为“libs”的文件夹
- copy the complete folder 'library' of the
PagerSlidingTabStrip
project on git into 'libs' - 将PagerSlidingTabStrip项目的完整文件夹“库”复制到“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"
- 将刚才复制的文件夹重命名为“library”。“PagerSlidingTabStripLibrary”(为了避免混淆)——重命名之后,>应该有这样的路径:“NewOne/libs/PagerSlidingTabStripLibrary”
-
now add this library in your
settings.gradle
with the following command:现在在设置中添加这个库。等级与以下命令:
include ':libs:PagerSlidingTabStripLibrary'
-
go to your
build.gradle
file of your AppProjectaps
and add the following line to your 'dependencies':去您的构建。您的AppProject aps的渐变文件,并在您的“依赖项”中添加以下行:
compile project(':libs:PagerSlidingTabStripLibrary')
-
at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files
至少你必须同步你的等级文件:工具-> Android ->同步项目与等级文件
Please try this. If you get errors please post the log file.
请试试这个。如果您收到错误,请张贴日志文件。
#2
4
For update up to Android Studio 1.2.1.1
更新到Android Studio 1.2.1.1。
There are basically three types of dependencies which we have to add in project of android Studio
基本上我们需要在android Studio项目中添加三种依赖项
Add Normal Dependencies like Support files
添加诸如支持文件之类的正常依赖项。
- Right click on project->open module settings
- 右键单击project->打开模块设置
- Select dependencies->Now press right "+" icon button ->Select library Dependencies
- 选择依赖项->现在按右“+”图标按钮->选择库依赖项。
- Enter Name and Search
- 输入名称和搜索
- Select file and press ok button.
- 选择file并按ok按钮。
Add Git Hub Dependencies
添加Git中心附件
Find the dependencies of git repository for example compile 'com.jakewharton:butterknife:6.1.0' from https://github.com/JakeWharton/butterknife
查找git存储库的依赖关系,例如,从https://github.com/jwharton /butterknife找到“com.jakewharton:butterknife:6.1.0”
A. open build.gradle(module:app) file
B. Add lines compile 'com.jakewharton:butterknife:6.1.0'
OR
或
Follow as describe above in Normal Dependencies Step by just enter dependencies in search bar
按照上面描述的一般依赖项步骤,在搜索栏中输入依赖项
Add Jar files Dependencies
添加Jar文件附件
- Right click on project->open module settings
- 右键单击project->打开模块设置
- press left "+" icon (insert new Module) button -> Select import Jar or .AAR package->browse Jar file and finish
- 按左“+”图标(插入新模块)按钮->选择导入Jar或.AAR包->浏览Jar文件并完成
- Now select dependencies-> press right "+" icon button ->Select module Dependencies->select jar files->press ok button.
- 现在选择依赖->按右“+”图标按钮->选择模块依赖->选择jar文件->按下ok按钮。
#3
2
For what it's worth I had this problem and eventually solved it by consistently using the same sdk version & build tools across projects.
值得注意的是,我遇到了这个问题,并最终通过跨项目一致地使用相同的sdk版本和构建工具来解决它。