程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在 jitpack 错误上创建 android 库大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决在 jitpack 错误上创建 android 库?

开发过程中遇到在 jitpack 错误上创建 android 库的问题如何解决?下面主要结合日常开发的经验,给出你关于在 jitpack 错误上创建 android 库的解决方法建议,希望对你解决在 jitpack 错误上创建 android 库有所启发或帮助;

我正在学习教程:https://medium.com/@anujguptawork/how-to-create-your-own-android-library-and-publish-it-750e0f7481bf

创建安卓库。一切正常,但是当我转到 Jitpack 时,“LOG”下的脚本为红色。这意味着有错误,我无法在 androID 项目中使用 m 库。

当我打开它时脚本是这样说的:

Build starTing...
Start: Thu Apr 1 20:33:20 UTC 2021 186300955b87
Git:
1.0.3-0-ga8b71cf
commit a8b71cf19b5b42e08f044d3ede72dd6475e54908
Author: HaroDev 
Date:   Thu Apr 1 22:32:08 2021 +0200

update setTings.gradle


Found AndroID manifest
AndroID SDK version: 30. Build tools: 30.0.3
Installing AndroID platform 30
Installing Build-tools 30.0.3 
Found gradle
Gradle build script
Found gradle version: 6.8.
Using gradle wrapper
Picked up JAVA_TOol_OPTIONS: -Dfile.enCoding=UTF-8 -Dhttps.protocols=TLSv1.2
Downloading https://services.gradle.org/diStributions/gradle-6.8-bin.zip
.10%.20%.30%.40%.50%.60%.70%.80%.90%.100%

------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------

Build time:   2021-01-08 16:38:46 UTC
Revision:     b7e82460c5373e194fb478a998c4fcfe7da53a7e

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          1.8.0_252 (Private Build 25.252-b09)
OS:           linux 4.18.0-25-generic amd64

0m3.382s
GetTing tasks: ./gradlew tasks --all
Picked up JAVA_TOol_OPTIONS: -Dfile.enCoding=UTF-8 -Dhttps.protocols=TLSv1.2

FAILURE: Build Failed with an exception.

* Where:
Build file '/home/jitpack/build/build.gradle' line: 2

* what went wrong:
Plugin [ID: 'com.androID.library'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespacE)
- Plugin RepositorIEs (plugin dependency must include a version number for this sourcE)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --deBUG option to get more log output. Run with --scan to get full insights.

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

BUILD Failed in 2s
Tasks: 

WARNING:
Gradle 'install' task not found. Please add the 'maven' or 'androID-maven' plugin.
See the documentation and examples: https://jitpack.io/docs/

Adding androID plugin
Adding maven plugin
Found androID library build file in .
Running: ./gradlew clean -Pgroup=com.github.HaroDeveloper -Pversion=1.0.3 install
Picked up JAVA_TOol_OPTIONS: -Dfile.enCoding=UTF-8 -Dhttps.protocols=TLSv1.2

FAILURE: Build Failed with an exception.

* Where:
Build file '/home/jitpack/build/build.gradle' line: 81

* what went wrong:
Could not compile build file '/home/jitpack/build/build.gradle'.
> startup Failed:
  build file '/home/jitpack/build/build.gradle': 81: all buildscript {} blocks must appear before any plugins {} blocks in the script
  
  See https://docs.gradle.org/6.8/userguIDe/plugins.HTML#sec:plugins_block for information on the plugins {} block
  
   @ line 81,column 1.
     buildscript {
     ^
  
  1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --deBUG option to get more log output. Run with --scan to get full insights.

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

BUILD Failed in 488ms
Build tool exit code: 0
Looking for artifacts...
Picked up JAVA_TOol_OPTIONS: -Dfile.enCoding=UTF-8 -Dhttps.protocols=TLSv1.2
Picked up JAVA_TOol_OPTIONS: -Dfile.enCoding=UTF-8 -Dhttps.protocols=TLSv1.2
Looking for pom.xml in build directory and ~/.m2
2021-04-01T20:33:55.548468308Z
Exit code: 0

ERROR: No build artifacts found

这是我的 build.gradle:

plugins {
    ID 'com.androID.library'
    ID 'kotlin-androID'
}

androID {
    compileSdkVersion 30
    buildToolsversion "30.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionname "1.0"

        testinstrumentationRunner "androIDx.test.runner.AndroIDJUnitRunner"
        consumerProguardfiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            MinifyEnabled false
            proguardfiles getDefaultProguardfile('proguard-androID-optimize.txt'),'proguard-rules.pro'
        }
    }
    compiLeoptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinoptions {
        jvmTarget = '1.8'
    }
}

task wrapper(type: Wrapper) {
    gradLeversion = '6.8'
}

dependencIEs {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androIDx.core:core-ktx:1.3.2'
    implementation 'androIDx.appcompat:appcompat:1.2.0'
    implementation 'com.Google.androID.material:material:1.3.0'
    testImplementation 'junit:junit:4.+'
    androIDTestImplementation 'androIDx.test.ext:junit:1.1.2'
    androIDTestImplementation 'androIDx.test.espresso:espresso-core:3.3.0'
}

有人知道如何解决这个问题吗?

解决方法

出了什么问题:插件 [id: 'com.android.library'] 未在以下任何来源中找到:

你应该在下面使用

plugins {
    id 'com.android.library'
    id 'android-maven'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

仅供参

确保库列在您的 setTings.gradle 文件的顶部,如下所示,名为 "testLib" 的库:

include ':app',':testLib'

然后打开应用模块的 build.gradle 文件并向依赖项块添加新行,如以下代码段所示:

dependencies {
    implementation project(":testLib")
}

大佬总结

以上是大佬教程为你收集整理的在 jitpack 错误上创建 android 库全部内容,希望文章能够帮你解决在 jitpack 错误上创建 android 库所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:android