Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.13k stars 341 forks source link

A failure occurred while executing com.github.triplet.gradle.play.tasks.PublishApk$ApkUploader #848

Closed siddharthkhindri closed 4 years ago

siddharthkhindri commented 4 years ago

Hii, I am trying to publish my application using your library. I have followed all the steps mentioned in it. But I am facing issue while uploading build from my terminal, Please let me know where I am going wrong in the process. Before posting I tried my best to resolve this but nothing seems to be working for me so now I am here to seek your help.

Here are my Gradles looks like :

App-level Gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'newrelic'
apply plugin: 'com.github.triplet.play'

android {
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileSdkVersion 29
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId 'com.trakopapp.user'
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 15
        multiDexEnabled true
        versionName "2.4"

        vectorDrawables.useSupportLibrary = true
        ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        testInstrumentationRunner "android.support.rounded_green_cremeway.runner.AndroidJUnitRunner"
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
    signingConfigs {
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }
    buildTypes {
        debug {
            manifestPlaceholders = [crashlyticsApiKey: '61c3d9e3910d000e5521cd48b6e0253f5f299278', mapApiKey: 'AIzaSyATYGQbMTt9egyYYD9RIzHhu0SjEy2ODOg']
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            //  minifyEnabled true
            //proguard true
            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            // shrinkResources true

            //  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            buildConfigField "String", "BASE_URL", '"http://www.mastersoftwaretechnologies.com:9051"'
            signingConfig signingConfigs.debug
        }

        release {
            manifestPlaceholders = [crashlyticsApiKey: '1f9dd8f900e1270814924a2bd796d99a41a4ccd1', mapApiKey: 'AIzaSyBfwQm6qQXkKa8JwckqWXAZNu_gSa0paeo']
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            // minifyEnabled false

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            //shrinkResources true

            // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "BASE_URL", '"http://www.mastersoftwaretechnologies.com:9051"'
            signingConfig signingConfigs.release
        }

    }
}
play {
    serviceAccountCredentials = file('api-8995422319430396916-517966-f7e4675a5c25.json')
    track = 'alpha' // Or any of 'alpha' or 'production '
}

Code-Level Gradle :

buildscript {
    ext.kotlin_version = '1.3.72'
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://maven.google.com' }
        maven {
            url "https://artifactory.paytm.in/libs-release-local"
        }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
        classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
        classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'io.fabric.tools:gradle:1.31.2'
        classpath 'com.github.triplet.gradle:play-publisher:2.8.0'
        classpath 'com.google.api-client:google-api-client:1.30.9'
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://maven.google.com' }
        maven { url 'https://jitpack.io' }
        maven {
            url "https://artifactory.paytm.in/libs-release-local"
        }
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The Error I am getting while running ./gradlew publishReleaseApk

Execution failed for task ':app:publishReleaseApk'.

A failure occurred while executing com.github.triplet.gradle.play.tasks.PublishApk$Processor There was a failure while executing work items A failure occurred while executing com.github.triplet.gradle.play.tasks.PublishApk$ApkUploader 403 Forbidden PUT https://www.googleapis.com/upload/androidpublisher/v3/applications/com.trakopapp.user/edits/14693366706448936699/apks?uploadType=resumable&upload_id=ABg5-Uzs0J6sOW04PzbRQzIzBd6__LSs4eNiJN6IoCdnsHZgu2RMtHZX4_ofvwigjkIlvxBmgDzkVZ0w26P { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Cannot update a published APK.", "reason" : "forbidden", "debugInfo" : "detail: \"[ORIGINAL ERROR] generic::permission_denied: com.google.apps.framework.request.ForbiddenException: Cannot update a published APK. [google.rpc.error_details_ext] { message: \\"Cannot update a published APK.\\" }\"\n" } ], "message" : "Cannot update a published APK.", "status" : "PERMISSION_DENIED" }

Please let me know how to upload

SUPERCILEX commented 4 years ago

You probably need to bump your version code?

siddharthkhindri commented 4 years ago

Thank you Very Much for your quick response, I really appreciate it !!!

Second question why I am getting this error. Please guide me on what mistake I made for this, or I need to upload the initial build then only this library will work?

  • What went wrong: Execution failed for task ':generateEditForComDotExampleDotDynamicviews'.

    A failure occurred while executing com.github.triplet.gradle.play.tasks.GenerateEdit$Generator 404 Not Found POST https://www.googleapis.com/androidpublisher/v3/applications/com.example.dynamicviews/edits { "code" : 404, "errors" : [ { "domain" : "global", "message" : "Package not found: com.example.dynamicviews.", "reason" : "notFound" } ], "message" : "Package not found: com.example.dynamicviews.", "status" : "NOT_FOUND" }

SUPERCILEX commented 4 years ago

Yeah, if this is your first upload it has to be done in the Play Console.

siddharthkhindri commented 4 years ago

Means, We have to publish one APK manually then only we can use this library for automation?

SUPERCILEX commented 4 years ago

Yup.