Friday, 31 August 2018

How to publish artifacts in gradle 4.4 in android studio (Upload APK to nexus)

I am trying to upload my APK to Nexus repository. Below code work fine until I have change gradle version

from

classpath 'com.android.tools.build:gradle:2.3.3' distributionUrl=https://ift.tt/2ndVD4z mCompileSdkVersion=23 mBuildToolsVersion='25.0.0'

To

classpath 'com.android.tools.build:gradle:3.1.0' distributionUrl=https://ift.tt/2vx88RC mCompileSdkVersion=27 mBuildToolsVersion='27.0.0'

After changing versions same code is not work I am not able to understand where I found an error, Terminal not showing any error message but my APK is not uploaded in given location

following is the current configuration of my App build.gradle file

apply plugin: 'com.android.application'
apply plugin: 'maven'


task uploadRelease (type: Upload){
    configuration = project.getConfigurations().getByName('archives');
    repositories {
        mavenDeployer {
            repository(  url: "http://XXXXXXXX:8081/nexus/XXXXXXXX/repositories/releases"  ) {
                authentication(userName: "MyuserName", password: "Mypassword")
            }
            pom.project {
                version "${android.defaultConfig.versionName}"
                artifactId "Collection"
                name "xxxxxxxx"
                groupId "com.xxxxxxxx.mobile.xxxxxxxx.collections"
            }
        }
    }
}

task uploadSnapshot (type: Upload){
    configuration = project.getConfigurations().getByName('archives');

    repositories {
        mavenDeployer {
            repository(  url: "http://XXXXXXXX:8081/nexus/XXXXXXXX/repositories/snapshots"  ) {
                authentication(userName: "MyuserName", password: "Mypassword")
            }
            pom.project {
                version "${android.defaultConfig.versionName}-SNAPSHOT"
                artifactId "Collection"
                name "Collection"
                groupId "com.xxxxxxxx.mobile.xxxxxxxx.collections"
            }
        }
    }
}

I use Command as - gradle assemblerelease uploadsnapshot

to build and upload APK but It does not work for gradle 4.4 Please let me know what went wrong



from How to publish artifacts in gradle 4.4 in android studio (Upload APK to nexus)

No comments:

Post a Comment