Search code examples
androidandroid-studiogradleadb

How to install apk without rebuilding whole project in Android Studio


Building apk for large project take much time to process all Gradle task.
I have try this but it clean and build

$ gradle installDebug

How to write separate gradle task and add to project Gradle run configuration.
So that by simply excuting gradle task it install existing build debug apk or release apk or any other build type without rebuidling it.
It will save deployment time of apk in multiple devices


Solution

  • Hope this can help you: I created a new shell file install_apk:

    #!/bin/bash
    
    # Usage
    #   run ./install_apk          # to install debug apk
    #   run ./install_apk release  # to install release apk
    
    if [ $1 == "release" ]; then
        adb install -r ./app/build/outputs/apk/app-release.apk
        echo "install release apk"
    else
        echo "install debug apk"
        adb install -r ./app/build/outputs/apk/app-debug.apk
    fi