在 jitpack 错误上创建 android 库
creating android library on jitpack error
我正在学习教程:https://medium.com/@anujguptawork/how-to-create-your-own-android-library-and-publish-it-750e0f7481bf
创建 android 库。一切正常,但当我转到 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'
}
有人知道如何解决这个问题吗?
What went wrong: Plugin [id: 'com.android.library'] was not found in any of the following sources:
你应该使用下面的
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")
}
我正在学习教程:https://medium.com/@anujguptawork/how-to-create-your-own-android-library-and-publish-it-750e0f7481bf
创建 android 库。一切正常,但当我转到 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'
}
有人知道如何解决这个问题吗?
What went wrong: Plugin [id: 'com.android.library'] was not found in any of the following sources:
你应该使用下面的
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")
}