Install Firebase

There is a collection of apps for quick start

google-services.json file should be copied to app/ folder, but you can use different google services json for different build type


To connect your app with Firebase you can use Gradle or Assistant. For using Gradle, you need to copy SHA and paste to firebase console. To get Debug signing certificate SHA-1 (optional) from the Android Studio, you can go to right toolbox Gradle and double click on root -> Tasks -> android -> signinReport. Another way to get sha is running command

keytool --exportcert -list -v -alias androiddebugkey -keystore $ANDROID_SDK_ROOT/.android/debug.keystore
Enter keystore password:
# type: android

Using assistant, you will grand permission to update your firebase settings, so you do not need to paste.

You can register different firebase project with the same package name, but you need to use different signing key (it is not possible to have same SHA on two different projects for the same package name). So you need to use another key (you can keep same package name

keytool --exportcert -list -v -alias key0 -keystore app/myapp_debug.jks
# type the password: myapp123456
# in output find SHA1: 87:16:52:08:C7:B1:BE:BC:73:BE:9E:37:64:67:CB:9D:76:0C:2B:01

Add dependencies

# build.gradle
buildscript {
  dependencies {
    // Add this line
    classpath ''

# app/build.gradle
dependencies {
  // Add this line
  implementation ''

// Add to the bottom of the file
apply plugin: ''

Signing config keys Instead of default certificate located at $HOME/.android/debug.keystore (which is different for each user ie sdk installation) you can create your own keys. That way new developer do not need to add SHA to firebase project, since he can imediatelly build and run the app in emulator or device. There are signing and upload key.

You can sign in manually from command line or using gradle Generate .jks file from Android studio

# app/build.gradle
android {
+    signingConfigs {
+      debug {
+          // You need to specify either an absolute path or include the
+          // keystore file in the same directory as the build.gradle file.
+          storeFile file("mykey.jks")
+          storePassword "asdf"
+          keyAlias "key0"
+          keyPassword "asdf"
+      }
+    }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
+        debug {
+            signingConfig signingConfigs.debug
+        }

Release to App Store

Keyboard shortcuts

  • Comment with Ctrl + / uncomment with Ctrl + shift + /
  • Alt + Enter when you want to import something that can not be resolved (when you paste some code snipets))
  • fix code indent with Ctrl + Alt + Super + L

Webview Start new app with blank intent. In app/serv/main/AndroidManifest.xml add permission for internet and also for http traffic

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

In java you need to enable javascript in webview, set user agent so you can customize the response.

public class MainActivity extends AppCompatActivity {

    private WebView myWebView;

    protected void onCreate(Bundle savedInstanceState) {
        myWebView = (WebView) findViewById(;
//        setContentView(myWebView);
        WebSettings webSettings = myWebView.getSettings();
        myWebView.setWebViewClient(new MyWebViewClient());
        myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");


    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // Check if the key event was the Back button and if there's history
        if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
            return true;
        // If it wasn't the Back key or there's no web page history, bubble up to the default
        // system behavior (probably exit the activity)
        return super.onKeyDown(keyCode, event);

public class WebAppInterface {
    Context mContext;

    /** Instantiate the interface and set the context */
    WebAppInterface(Context c) {
        mContext = c;

    /** Show a toast from the web page */
    public void showToast(String toast) {
        Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
  • to change launcher icon and other icons you can go to File -> New -> Image Asset and than select “Lanucher icons” and add svg image file. Repeat proccess but select “Notification icons”. You can see git status that existing files will be updated, for example app/src/main/res/mipmap-hdpi/ic_launcher.png insteaad of mipmap-hdpi, there is mipmap-mdpi/xhdmpi/xxhdpi/xxxhdpi density and ic_launcher_foreground.png/ic_launcher_round.png There is app/src/main/res/values/ic_launcher_background.xml which is some vector but do not know how to use it. For notification icon path is app/src/main/res/drawable/ic_notificaiton.png

Const for server Url

When you build release (Build -> Select build variant -> release), by default serverUrl is targeting production server When you want to target local Rails server than choose debug and update app/src/main/java/com/myapp/app/, by default is


import android.content.Context;

public class Const {
   // Use for example
   // String mUrl = Const.getServerUrl(getApplicationContext());
    public static String getServerUrl(Context context) {
        boolean isDebuggable = (0 != (context.getApplicationInfo().flags
                & ApplicationInfo.FLAG_DEBUGGABLE));
        String mUrl;
        if (isDebuggable) {
            mUrl = "";
        } else {
            mUrl = "";


Release new version on Play store

Increment android { defaultConfig { versionCode X }}} in app/build.gradle. (Module: app). Than go to Build -> Generate Signed Bundle or APK -> Apk -> Choose app/myaapp.jks and add passwords from gradle config. Upload app/release/app-release.apk to Google Play console , Release Management -> App preleases -> Production Track -> Manage -> Create Release or Edit Release

Note that Playstore is somehow cached on Emulator, so install from real device when you want to checound latest release.


When I Import existing project the subfolders, I got error

Gradle sync failed: Could not find

so I need to add this line to gradle

maven { url '' }

For error

  emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm)

fix is sudo chown orlovic -R /dev/kvm


  • add loader before page is shown
  • if you have multiple andoird icons