Search code examples
androidandroid-studiosignsigned

How to sign automatically when I click RUN button in Android Studio?


When I'm developing, always use Run(Shif+F10) button. But Run makes unsigned application. So if I want to test my app, i must do Build > Generate Signed APK > install. It's very annoying. So I want to sign automatically when I click Run button.

If it's impossible, please tell me useful function for testing my app


Solution

  • Yes, it's possible use following code add into your Gradle script.

    I managed to solve it adding this code, and building with gradle build:

    android {
    ...
    signingConfigs {
        release {
            storeFile file("release.keystore")
            storePassword "******"
            keyAlias "******"
            keyPassword "******"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    

    }

    This generates a signed release apk file. Also while generate your api please ensure that your buid veriant is Relese like this.

    enter image description here