Android Studio released aar to Jcenter, plug-in could not be found

Keywords: Gradle Android github Java

Reference resources:

https://www.jianshu.com/p/5be222e98efc?from=jiantop.com / / used by gradle

https://github.com/nuuneoi/JCenter/blob/master/installv1.gradle / / dependent on gradle location

 

Objectives:

Previously, Android Studio released aar to Jcenter. For details, please refer to: https://blog.csdn.net/u014803950/article/details/64124375

However, we often encounter a problem: Android Studio often cannot find the plug-in, and the problem appears in the following two lines

#libaray.gradle
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

The main goal of this paper is to solve this problem.

 

Analysis:

1. The reason for the problem is that the remote database dependent on cannot be downloaded (it may be a network problem, an unstable server, or a wall)

2. Solution: compile remote library into local

 

Solution steps:

1. Locate the remote file: https://github.com/nuuneoi/JCenter/blob/master/installv1.gradle

2. Implement remote files locally

3. The modification of gradle depends on remote, instead, local

 

1, remote file found

Open github directly and search

2. Implement remote files locally

2-1. The contents are shown in the figure below

2-2, file content (actually copying github, there is a field change [because gradle cannot automatically recognize case])

#bintrayv1.gradle

apply plugin: 'com.jfrog.bintray'
version = libraryVersion
if (project.hasProperty("android")) { // Android libraries
    task sourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
    }
    task javadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
} else { // Java libraries
    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }
}
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
artifacts {
    archives javadocJar
    archives sourcesJar
}
// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        desc = libraryDescription
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = allLicenses
        publish = true
        publicDownloadNumbers = true
        version {
            desc = libraryDescription
            gpg {
                sign = true //Determines whether to GPG sign the files. The default is false
                passphrase = properties.getProperty("bintray.gpg.password")
                //Optional. The passphrase for GPG signing'
            }
        }
    }
}

#installv1.gradle

apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId                               // Maven Group ID for the artifact
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                groupId publishedGroupId
                artifactId artifact // Changed case
                // Add your description here
                name libraryName
                description libraryDescription
                url siteUrl
                // Set your license
                licenses {
                    license {
                        name licenseName
                        url licenseUrl
                    }
                }
                developers {
                    developer {
                        id developerId
                        name developerName
                        email developerEmail
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

3. The modification of gradle depends on remote, instead, local

//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
apply from: "installv1.gradle"
apply from: "bintrayv1.gradle"

All of the above is done. Next, compile and upload aar from the command line. Don't worry about finding remote files any more

 

 

 

 

 

 

 

Posted by kruahsohr on Fri, 03 Jan 2020 13:53:29 -0800