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

23.7k views Asked by At

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?

4

There are 4 answers

4
floatingmuseum On BEST ANSWER

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.

1
Mixaz On

Usually I do it from command line, installing via "adb install -r file.apk" (-r to preserve app's data)

Also it can be done via Gradle and project settings, see answers here: Android Studio - Run signed apk on emulator

0
guido On

Maybe this is not an answer to your question about how to sign the app before running it, but have you thought about the option to create a new signature key for the debug key you are using? You could use a separate API key in debug mode.

I found some extra information about using a key in release and debug mode: Android: automatically choose debug/release Maps v2 api key?

0
notyourguru On

When I want to test my APK release I just use ADB-Link. Its free and very easy to setup. Just make sure to delete any previous builds that you installed on your device otherwise the installation will fail.