美文网首页
上传自己的库到github 并作为依赖

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

作者: NB一沓 | 来源:发表于2018-06-22 15:59 被阅读0次

    本文介绍如何把自己的代码封装成库并传到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。

    相关文章

      网友评论

          本文标题:上传自己的库到github 并作为依赖

          本文链接:https://www.haomeiwen.com/subject/jbwkyftx.html