Posts

Showing posts from April, 2016

Android Error: Found com.google.android.gms:play-services:8.4.0, but version 8.3.0 is needed for the google-services plugin

Make sure that the following line is  at the end of the app build.gradle  file: apply plugin : 'com.google.gms.google-services'

Android: *.jks file view

use the following command to view the jks file, which will ask for password. keytool -v -list -keystore *.jks 

Android: Gradle Tasks

following commands can be used for build, run and test on device.. Echo Clean Project call gradle clean Echo Build Project call gradle assembleRelease Echo Install APK and Run Android Tests call gradle connectedAndroidTest

Android: Events from JavaScript to Android

//Add interface to webview webView.addJavascriptInterface( new WebAppInterface(getApplicationContext()), "Android" ); class WebAppInterface { Context mContext ; /** * Instantiate the interface and set the context */   WebAppInterface(Context c) { mContext = c; } /** * Show a toast from the web page */   @JavascriptInterface   public void showToast(String toast) { Toast. makeText ( mContext , toast, Toast. LENGTH_SHORT ).show(); } //Create a toast / event in JavaScript <input type="button" value="Say hello" onClick="showAndroidToast('Hello Android!')" /> <script type="text/javascript"> function showAndroidToast(toast) { Android.showToast(toast); } </script>

Android Build Error: UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0"

Change the build tool version buildToolsVersion "24.0.0 rc2" to buildToolsVersion " 23.0.2 "

Android: ProGuard source code

Enable ProGuard in Android gradle build, make sure that the build variant is same. minifyEnabled true Add following snippet to App ' proguard-rules.pro' file -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -dontpreverify -dontnote -ignorewarnings -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # not to proguard dependent library packages -keep class com.squareup.** -keep class com.android.volley.** # not to proguard android components -keep public class * extends android.app.Activity -keep public class * extends android.app.Fragment -keep public class * extends android.support.v4.app.Fragment -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -dontwarn ** -dontnote ** # to generate the mapping.txt file -printmapping mapping.txt