上传自己的库到github 并作为依赖

本文介绍如何把自己的代码封装成库并传到JitPack

参考文章:https://blog.csdn.net/hmh0512/article/details/53818058

1.把要封装成库的类统一放到一个新建的moudle下面

在项目的build.gradle里添加如下:


applyplugin:'maven'

group ='com.github.yourname'

2.上传完整的项目(包括要打包成库的moudle)到github上面,并发布一个relase版本:

image

3.把刚刚上传到github的项目上传到jitpack上

打开jitpack官网,在“look up ”框里搜索自己的github项目,然后jitpack会自动检测项目里的moudle模块,并将其编译成二进制文件,如果成功的话会出现 get it绿色按钮,否则编译失败,可以点击log查看错误信息。

image

jitpack打包时遇到两次错误,现已修复,记录下

1.修改compile project(path:':singletonfactory')------>implementation project(path:':singletonfactory')修复了这个issue

报错log如下:


** What went wrong:*

*A problem occurred configuring project ':app'.*

*> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi*

** Try:*

*Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.*

** Get more help at https://help.gradle.org*

*BUILD FAILED in 14s*

*WARNING:*

*Gradle 'install' task not found. Please add the 'maven' or 'android-maven' plugin.*

*See the documentation and examples: https://jitpack.io/docs/*

*Adding maven plugin*

*Found android library build file in singletonfactory*

*Running: ./gradlew clean -Pgroup=com.github.NByida -Pversion=1.1 install*

*Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all*

*Download https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/2.0/android-maven-gradle-plugin-2.0.pom*

*Download https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/2.0/android-maven-gradle-plugin-2.0.jar*

*Gradle version Gradle 4.1*

*Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.*

*FAILURE: Build failed with an exception.*

* * *

*2.FAILURE: Build failed with an exception.*

* What went wrong:

Task 'install' is ambiguous in root project 'build'. Candidates are: 'installDebug', 'installDebugAndroidTest'.

* Try:

Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

EXIT_CODE=1

2018-06-13T02:58:21.682902464Z

Exit code: 1

No build artifacts found

修改方法:

在项目的build.gradle里添加如下:


applyplugin:'maven'

group ='com.github.yourname'

解决bug。

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 181,139评论 25赞 708
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 6,729评论 1赞 9
  • 文/踏歌娘 “那一日,我在留仙台上吃了不少菱角做的糕,喝了许多菱角酿的酒。缈落白日里一直都没出现。” 东华的声音一...
    踏歌娘阅读 31,362评论 33赞 58
  • “你们看芈月传没有,里面孙俪拿着卫生卷纸式的和氏璧,样子太搞笑了。”一个同事在午餐时挑起了话题。 “是啊,这编剧也...
    甜食小怪兽阅读 524评论 6赞 7
  • 1. 生词跟短语 competition n. 比赛,竞争compete v. 比赛,竞争The kids com...
    张无忌_阅读 687评论 0赞 0

友情链接更多精彩内容