Android studio is probably the best IDE for Android.Even with its slow grade tasks and occasional unresponsiveness,Google has added a lot of new features to make life easy

Just a couple of days ago I was working with a team to fix an issue they were facing with their android app.

The issue was very vague, the developer was trying to upload a base64 string to the server.The string was generated from an image.But while testing locally on his machine he faced an issue.

I then asked the dev what he was doing ,he said he was using logcat to copy the base64 string.He would then copy the string from the logcat and run it through the online convertor.

So I sat down with the developer to test the code.I put a breakpoint on the string.The debugger showed the obscure string really easy,I then copied the string and pasted it to a online convertor and voila things worked.Although I had to use http://www.miniwebtool.com/remove-spaces/ to remove extra space set by Android Studio.



A year ago google released android studio.An IDE based on intellij.They also introduced a task runner to build your applications, run test and manage dependencies.

Gradle is the task runner and it supports a Java,Android and C/C++ projects.That what they claim on their website.But for this post I will be dealing with android.

The android gradle project has buildTypes which are equivalent to environments in the backend development world.Android has 2 by default one is debug the other is release.You can specify more buildtypes based on your application.

You can easily create another buildtype

signingConfigs {
        prerelease {
            storeFile file("prerelease.keystore")
            storePassword "<your password>"
            keyAlias "<key.alias>"
            keyPassword "<your password>"
        }
    } 
buildTypes {
        prerelease {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.prerelease
        }
    }

You need to add the signingConfig this way it will build and sign the keys before installing.

By default the Install<Buildtype> doesn’t show and the only way to show it is to have signingConfig specified in the buildtype.

Here are the other options available to each buildtype

If a property is not set through the DSL, some default value will be used. Here’s a table of how this is processed.

 

 Property Name  Default value in DSL object  Default value
 versionCode  -1  value from manifest if present
 versionName  null  value from manifest if present
 minSdkVersion  -1  value from manifest if present
 targetSdkVersion  -1  value from manifest if present
 applicationId  null  value from manifest if present
 testApplicationId  null  applicationId + “.test”
 testInstrumentationRunner  null  android.test.InstrumentationTestRunner
 signingConfig  null  null
 proguardFile  N/A (set only)  N/A (set only)
 proguardFiles  N/A (set only)  N/A (set only)

Source: Google

By default gradle looks for the keystore file in the app/ directory.

You can also run multiple gradle jobs in parallel, by setting the following in the gradle.properties file.

org.gradle.parallel=true

Using buildtype can improve overall code quality especially if you have multiple config data like server urls.

To override a particular file for a particular build all you have to is create a folder in the src/ directory.

tree