Skip to main content

How To Generate Signed APK using Gradle in Android Studio

So Android Studio doesn't encourage you to sign your APK the UI way using Android Studio, instead they're directing you to use Gradle to generate it (or in complex cases, there'll be a lot of APKs generated according to different build types and flavors)

1. Declare these inside the android bracket within the gradle file within your main Android project as shown below (while putting your keystore files in your project root directory):

signingConfigs{
        debug {
            storeFile file("example.keystore")
            storePassword "example"
            keyAlias "example"
            keyPassword "example"
        }

        release {
            storeFile file("example-release.keystore")
            storePassword "example"
            keyAlias "example"
            keyPassword "example"
        }
}

buildTypes {
        debug {
           signingConfig signingConfigs.debug
        }
        release {
           signingConfig signingConfigs.release
        }
}

2. Internally or externally run 
./gradlew clean build assembleDebug
./gradlew clean build assembleRelease

The APK files for debug or release will be stored in the main Android project's /build/apk/ directory. 


Comments

Popular posts from this blog

Setting Up Android CheckStyle in Android Studio

So we all want to abide by the Android Code Style Guidelines shown in the official Android developer website here . How do we get started by helping ourselves by abiding by the Java and Android code style rules? Simple. Set it in Android Studio with the instructions below:  1. Copy the file in  https://github.com/android/platform_development/blob/master/ide/intellij/codestyles/AndroidStyle.xml 2. Paste the file into ~/.AndroidStudioPreview/config/codestyles/ (in Ubuntu) or ~/Library/Preferences/AndroidStudioPreview/codestyles (in Mac OS X) 3. Go to Settings (or Preferences in Mac OS X) > Code Style > Java, select AndroidStyle, as well as Code Style > XML and select AndroidStyle. 4. Start code inspection and see the results by selecting Analyze > Inspect Code. You will see the results of inspection on the Inspection pane at the bottom and and you will notice things that you can improve in your Java code such as Code Style Issues, Android, D

How To Reset Android Studio on Mac

Just in case you guys have trouble starting Android Studio for some unknown reason such as clearing the Mac OS cache using a third party tool, these are the steps to troubleshoot the problem. Step 1: Close Android Studio. Step 2: Remove all the directories that are related to Android Studio ~/Library/Application Support/AndroidStudioBeta ~/Library/Caches/ AndroidStudioBeta ~/Library/Logs/ AndroidStudioBeta ~/Library/Preferences/ AndroidStudioBeta Step 3: Start Android Studio Simple as that...

Install Git Bash Completion on Mac OS X

Bash completion for Git isn't available by default on the Mac's Terminal. So you have to assign it yourself in the environment path setup. By default your git directory should be at /usr/local/git in Mac. Assuming you're at your user directory: Step 1: sudo nano .bash_profile Step 2: add the line  source /usr/local/git/contrib/completion/git-completion.bash Ctrl+X to save, Ctrl+Y to save file name. Step 3: source .bash_profile Logout and Login again.