Android Studio导入github上的项目or框架
2015-03-07 19:35
507 查看
举个栗子什么的说明最清楚了
第一步
在github上下载项目,就是那个压缩包啦,这里先随便下两个
https://github.com/Yalantis/Pull-to-Refresh.Rentals-Android https://github.com/daimajia/AndroidSwipeLayout
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/0f8b468bb2540385c3220004d57194ab)
我下载在桌面上
第二步
新建个工程
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/dc427100fe5e1c80476472a075b6a2cc)
目前结构是这个样子滴
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/361d8692936ff0986f668dfe371d93e3)
右击app,选择open module settings
这里说下module是神马东东
其实就是androidstudio和eclipse命名不同
eclipse的结构是workspace->Project对吧
AndroidStudio就是Project->Module
module就是对应eclipse的Project
而Project比如这里我们新建的ImportTest对应原来的workspace
get it?
而这个app是自动生成的
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/589ff11bb6439f651d5538a5aefcd1d1)
跳出这么个东西,点左上角的绿色+号
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/69d0410d289fddb548fadc662e4718cc)
点击import exiting project
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/2b26b6beabdd8c71d1ad35814b5aead9)
这里打开在github上下的那个压缩包,解压出来的文件夹,会识别到里面的模块,这里有两个,library和sample,library就是那个我们需要使用的框架,而sample是这个框架开发者做的基于这个框架的demo,所以看下面如果勾选了sample,library是必须勾选的,当然我们这里sample是没用的,不勾选,然后finish,就导入啦
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/1eab36910cc7c0862c663e7e47993fd4)
然后结构就变成这样了,多了个library
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/aa5a3e4865f057fd2bad0943aea477fc)
看见build.gradle(app)了吗,打开,添加compile 'com.yalantis:pulltorefresh:1.0.0'
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/dc35ddc2965dac55572e654e8f98da4d)
好啦,这个就算导入拉,library里面的代码我们就可以使用了
实现下咯
main_layout里插入这么一段,然后执行
[java] view
plaincopy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.yalantis.pulltorefresh.library.PullToRefreshView
android:id="@+id/pull_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list_view"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.yalantis.pulltorefresh.library.PullToRefreshView>
</RelativeLayout>
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/5c19e7566e2f3dc62fba9df8427dd492)
搞定啦
这个项目很简单啦
我刚才有下载两个项目,现在把另一个也导入
导入的library命名叫library2好了,因为不能冲突
艹艹艹艹艹,报错鸟
Error:(4, 0) Could not find property 'ANDROID_BUILD_SDK_VERSION' on project ':library2'.
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/15c1f9a41157269deb10cfdb103e1dbb)
没定义这个东东
好吧,那就定义吧
看到gradle.properties了吧,打开,添加
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21
(对应自己的版本啦,改下版本号)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/fee2a3025bafaee8ae4fef2ee0672774)
右上角try again点击
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/2b6527a15a6907ada9c165edd93fbe69)
还有错
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/3e6e5f5974084e5a8eaa2b8e5668b6fa)
在library2的build.gradle里有这么一行,apply from: './gradle-mvn-push.gradle',注释掉
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/18/80beefab69326d0dfa39fb5602ef84f7)
然后try again在构建下,搞定,这次是真的!
好啦,两个项目导进来啦,可以用人家的代码了
那如果是想要导入jar包呢?
app下有个libs文件夹,把jar包拷进去就行了
第一步
在github上下载项目,就是那个压缩包啦,这里先随便下两个
https://github.com/Yalantis/Pull-to-Refresh.Rentals-Android https://github.com/daimajia/AndroidSwipeLayout
我下载在桌面上
第二步
新建个工程
目前结构是这个样子滴
右击app,选择open module settings
这里说下module是神马东东
其实就是androidstudio和eclipse命名不同
eclipse的结构是workspace->Project对吧
AndroidStudio就是Project->Module
module就是对应eclipse的Project
而Project比如这里我们新建的ImportTest对应原来的workspace
get it?
而这个app是自动生成的
跳出这么个东西,点左上角的绿色+号
点击import exiting project
这里打开在github上下的那个压缩包,解压出来的文件夹,会识别到里面的模块,这里有两个,library和sample,library就是那个我们需要使用的框架,而sample是这个框架开发者做的基于这个框架的demo,所以看下面如果勾选了sample,library是必须勾选的,当然我们这里sample是没用的,不勾选,然后finish,就导入啦
然后结构就变成这样了,多了个library
看见build.gradle(app)了吗,打开,添加compile 'com.yalantis:pulltorefresh:1.0.0'
好啦,这个就算导入拉,library里面的代码我们就可以使用了
实现下咯
main_layout里插入这么一段,然后执行
[java] view
plaincopy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.yalantis.pulltorefresh.library.PullToRefreshView
android:id="@+id/pull_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list_view"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.yalantis.pulltorefresh.library.PullToRefreshView>
</RelativeLayout>
搞定啦
这个项目很简单啦
我刚才有下载两个项目,现在把另一个也导入
导入的library命名叫library2好了,因为不能冲突
艹艹艹艹艹,报错鸟
Error:(4, 0) Could not find property 'ANDROID_BUILD_SDK_VERSION' on project ':library2'.
没定义这个东东
好吧,那就定义吧
看到gradle.properties了吧,打开,添加
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21
(对应自己的版本啦,改下版本号)
右上角try again点击
还有错
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
在library2的build.gradle里有这么一行,apply from: './gradle-mvn-push.gradle',注释掉
然后try again在构建下,搞定,这次是真的!
好啦,两个项目导进来啦,可以用人家的代码了
那如果是想要导入jar包呢?
app下有个libs文件夹,把jar包拷进去就行了
相关文章推荐
- android studio github 项目导入问题
- 导入github ViewPagerIndicator 项目到 android studio
- Android studio导入github项目
- eclipse 和android studio 导入github项目
- Android Studio导入github中的项目
- android studio github 项目导入问题
- Android Studio,Eclipse怎样导入Github中的项目
- 【已解决】Android Studio导入GitHub上的项目常见问题
- 解决将Github上的项目导入到Android Studio中去
- 将Github下载的项目导入android studio
- Android Studio导入GitHub上的项目常见问题(以图片轮播开源项目为实例)
- android studio导入github项目
- ADT、GitHub 导入项目到Android Studio
- Android Studio导入github的开源项目,Slidingmenu为例
- Android Studio 导入Github的开源项目
- Android Studio 导入Github的开源项目
- Android Studio导入GitHub上的项目常见问题
- Android Studio导入github上面的项目以及发生的问题
- Android Studio导入GitHub第一个项目PullToRefresh
- 关于android studio导入GitHub项目