1

I am following tutorial: https://medium.com/@anujguptawork/how-to-create-your-own-android-library-and-publish-it-750e0f7481bf

to create android library. Everything works fine, but when I go to Jitpack, script under "LOG" has red color. This means there is error and I am unable to use m library in android projects.

This is what the script says when I open it:

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

This is my 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'
}

Does anyone know how to fix this?

Kratos
  • 681
  • 1
  • 13
  • 30

1 Answers1

1

What went wrong: Plugin [id: 'com.android.library'] was not found in any of the following sources:

You should use below

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

FYI

Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "testLib":

include ':app', ':testLib'

Then open the app module's build.gradle file and add a new line to the dependencies block as shown in the following snippet:

dependencies {
    implementation project(":testLib")
}
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • You mean add this to my build.gradle? I did it but nothing changed, same errors still remain... – Kratos Apr 02 '21 at 07:04
  • @Kratos Read https://developer.android.com/studio/projects/android-library – IntelliJ Amiya Apr 02 '21 at 07:18
  • I just red it but I really see nothing different than in tutorial which I used to make library. I looke on some different places f.e (https://www.youtube.com/watch?v=zePqM-iL5fU&t=1s&ab_channel=BinaryITSolution) but they all do the same as I did, but for thekm it works. I have deadlineto finish this till tuesday need to find solution till than... – Kratos Apr 02 '21 at 08:52
  • @Kratos Seems like sloppy mistake costs you. Let me inform if solved. – IntelliJ Amiya Apr 02 '21 at 09:29
  • 1
    I fixed it. My mistake was I was pushing only library to github without project. I mistakenly thought I don't need project, but only library to work. Thanks for your asisstance! – Kratos Apr 02 '21 at 17:11
  • I would like to ask you can I use jitpack with bitbucket instead of github for vcs. I tried to find tutorial or something but no body does it with bitbucket. I don't see creating release option with bitbucket... – Kratos Apr 02 '21 at 17:20
  • And is it true that I can not use Jitpack with bitbucket. I am unable to login to jitpack with Bitbucket. It asks me specifically for github account – Kratos Apr 02 '21 at 17:32