How can deploy signed APK when click Run in Android Studio?

fthdgn picture fthdgn · Nov 22, 2014 · Viewed 20.2k times · Source

I am developing an app which uses Google APIs. I have created credentials at "Google Developers Console". If I creates a signed APK, and run it on the phone, there is no problem.

The problem is, while I developing the app, when I click RUN button, it deploys an unsigned version of the app on the phone. Thus the application does not work.

How can I set Android Studio to make it deploy signed APK on the phone when click RUN button?

Answer

floatingmuseum picture floatingmuseum · Jul 28, 2016

Add these values to your .gradle:

signingConfigs{
    debug{
        keyAlias 'your key alias'
        keyPassword 'your keypassword'
        storeFile file('keystore path')
        storePassword 'your storepassword'
    }
}
buildTypes {
    debug{
        signingConfig signingConfigs.debug
    }
}  

The keystore path in the file will be something like E:/xxx/xxx/xx.keystore.