logo
down
shadow

How to run a Gradle task after apks are produced in Android Studio?


How to run a Gradle task after apks are produced in Android Studio?

By : ZenDamien
Date : November 22 2020, 10:40 AM
will help you The following task (in build.gradle of an app's module) seems to run always before the apk is produced: , try add this in you app/build.gradle
code :
assembleDebug.doLast {
    android.applicationVariants.all { variant ->
        if (variant.buildType.name == 'release') {
            def releaseBuildTask = tasks.create(name: "debug") {
                println("....................  test   ..............................")
            }
            releaseBuildTask.mustRunAfter variant.assemble
        }
    }
    println "build finished"
}


Share : facebook icon twitter icon
Run 'uninstallAll' gradle task before running application in Android Studio from build.gradle

Run 'uninstallAll' gradle task before running application in Android Studio from build.gradle


By : user3600058
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , What you may need is to set defaultTasks:
code :
defaultTasks uninstallAll
runTaskName.dependsOn(uninstallAll)
Android Studio: How to generate multiple APKs or signed APKs for all productFlavors at once for a selected buildType?

Android Studio: How to generate multiple APKs or signed APKs for all productFlavors at once for a selected buildType?


By : yoyoyo
Date : March 29 2020, 07:55 AM
will help you You can always select multiple flavors from the list when generating signed apk after selecting build type. It will generate apks for all selected flavors for the given build type. I've done this several times.
How, you ask? Select one flavor and press Ctrl + A to select all flavors or Press Ctrl and select multiple flavors as you want.
Android studio / Gradle javadoc task

Android studio / Gradle javadoc task


By : JJJ SSS
Date : March 29 2020, 07:55 AM
may help you . Maybe you have got the solution to this. Just in case not, below is how I generate API doc for my Jenkins CI.
code :
task generateApiDoc() {
    group "reporting"
    description "Generates Javadoc."
}

android.libraryVariants.all { variant ->
    // Only consider release 
    if (variant.buildType.name == "release") {
        def task = project.tasks.create("generate${variant.name.capitalize()}Javadoc", Javadoc) {
            group "ApiDoc"
            description "Generates Javadoc for $variant.name."

            // Source files from the variant
            source = variant.javaCompiler.source
            // Classpath from the variant + android.jar
            classpath = variant.javaCompiler.classpath + files(prj.android.getBootClasspath()) + files("$buildDir/intermediates/classes/release")

            /* add the excluded packages */
            exclude "**/R**"
            exclude "**/BuildConfig*"

            options.windowTitle = "My Library"
            options.memberLevel = JavadocMemberLevel.PROTECTED
            options.linkSource false
            options.author = true
            //options.links("http://docs.oracle.com/javase/7/docs/api/", "http://d.android.com/reference");

            failOnError false
        }

        task.dependsOn assemble

        generateApiDoc.dependsOn task
    }
}
./gradlew assembleRelease
./gradlew generateApiDoc
android.libraryVariants.all { variant ->

    def task = project.tasks.create("generate${variant.name.capitalize()}Javadoc", Javadoc) {
        title "API Documentation (${project.android.defaultConfig.versionName})"
        group "ApiDoc"
        description "Generates Javadoc for $variant.name."

        // Source files from the variant
        source = variant.sourceSets.collect { it.java.sourceFiles }.inject { m, i -> m + i }

        // To fix issue: Error: Can not create variant 'android-lint' after configuration ': library: debugRuntimeElements' has been resolved
        doFirst {
            classpath = project.files(variant.javaCompileProvider.get().classpath.files,
                    project.android.getBootClasspath())
        }

        if (JavaVersion.current().isJava8Compatible()) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }

        exclude "**/R"
        exclude "**/R.**"
        exclude "**/R\$**"
        exclude "**/BuildConfig*"

        if (JavaVersion.current().isJava8Compatible()) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }

        options.windowTitle = "API Documentation (${project.android.defaultConfig.versionName})"
        options.memberLevel = JavadocMemberLevel.PROTECTED
        options.linkSource false
        options.author = false

        failOnError true
    }

    task.dependsOn "assemble${variant.name.capitalize()}"
    generateApiDoc.dependsOn task
}

Different Apks for android using gradle buildTypes

Different Apks for android using gradle buildTypes


By : Avinash A
Date : March 29 2020, 07:55 AM
I hope this helps you . It looks like your are using Google Services although you have omitted that from your gradle.
your google configuration file (google-services.json file I think) does not contain any configuration information for com.edu.gcfapp.debug
How to stop Android Studio from running my gradle task when syncing project with Gradle files?

How to stop Android Studio from running my gradle task when syncing project with Gradle files?


By : user1626401
Date : March 29 2020, 07:55 AM
With these it helps Your task does not run at all, it is just configured.
Gradle distinguishes between the configuration phase and the execution phase. On each invocation, every task is configured, but only the tasks passed to Gradle and their task dependencies are executed. As IntelliJ / AndroidStudio invokes Gradle on sync, every task is configured on sync. When you define a task in Gradle, the closure you pass is used for configuration. Only task actions (internal functionality), doFirst and doLast closures are executed during execution phase. For your custom task, you should put your functionality into such a closure:
code :
task example {
    println 'Configuration' 
    doLast {
        println 'Execution' 
    } 
} 
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org