github开源项目使用小技巧
2017-06-12 本文已影响263人
08_carmelo
前言
如果每次都是把开源库下载到本地,再用AndroidStudio打开,太耗时间了。在此提供便捷阅读开源项目的方法,包括开源库的查找,源码预览,快速运行。
1.查找开源库
开源库收录网站
http://www.ctolib.com/
http://p.codekk.com/
2.快速预览运行开源项目
Chrome安装插件octotree,无需下载直接在github预览开源库的源码:

本地建一个目录,git clone这个项目到本地
命令:git clone 项目地址

cd到开源库根目录,执行命令直接安装到测试机看效果:
命令:./gradlew clean ./gradlew installDebug

如果这个库的gradle版本和你本地的不一致,将会开始下载Gradle,完成后app开始运行
3.直接在AndroidStudio使用jCenter的开源库
比如我要使用Okhttp这个开源库,可以在github找到这个库的仓库地址,手动添加到build.gradle
compile 'com.squareup.okhttp3:okhttp:3.8.0'
也可以直接在项目下的Dependency在线搜索

项目同步完成后,在这里可以看到这个依赖库

右键点击:LibraryProperties,可以找到这个库的源码下载的本地位置:
