AndroidRuntime: Shutting down VM
<p>I'm building an android game. It's a Unity3D project exported to Android Studio. I'm trying to manage all the Google Play Services (GPS) interaction in Android Studio. This is the class responsible to interact with GPS (I know I'm not following standard programming patterns):</p>

<pre><code>package com.lemondo.eyescube;

import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;

public class GPSBinding implements ConnectionCallbacks, OnConnectionFailedListener {

    public GoogleApiClient googleApiClient;

    private static GPSBinding _gpsBindingInstance;
    public static GPSBinding instance(){
        if(_gpsBindingInstance == null){
            _gpsBindingInstance = new GPSBinding();
        }
        return _gpsBindingInstance;
    }

    public static void Initialize(){
        if(instance().googleApiClient == null) {
            instance().googleApiClient = new GoogleApiClient.Builder(UnityPlayer.currentActivity)
                    .addConnectionCallbacks(instance())
                    .addOnConnectionFailedListener(instance())
                    .addApi(Games.API)
                    .addScope(Games.SCOPE_GAMES)
                    .build();
        }
    }

    public static void AuthenticatePlayer() {
        Log.d("GPSBinding", "AuthenticatePlayer");
        try {
            if (instance().googleApiClient != null)
                instance().googleApiClient.connect();
            else
                Log.d("GPSBinding", "AuthenticatePlayer: googleApiClient is null");
        } catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void onConnected(Bundle bundle) {
    }

    @Override
    public void onConnectionSuspended(int i) {
    }

    @Override
    public void onConnectionFailed(ConnectionResult result) {
    }

}
</code></pre>

<p>This is what happens: the app starts, Unity calls <strong>Initialize()</strong> method upon startup, it waits for 1 second and calls for <strong>AuthenticatePlayer()</strong> method.</p>

<p>The app crashes on this line in <strong>Authenticatelayer()</strong>:</p>

<pre><code>instance().googleApiClient.connect();
</code></pre>

<p>I do not get the cause though, this is the stack trace:</p>

<pre><code>01-12 12:46:02.602 30609-30609/com.lemondo.eyescube D/AndroidRuntime: Shutting down VM
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: FATAL EXCEPTION: main
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: Process: com.lemondo.eyescube, PID: 30609
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: java.lang.Error: FATAL EXCEPTION [main]
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: Unity version     : 5.2.1f1
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: Device model      : samsung GT-I9500
01-12 12:46:02.605 30609-30609/com.lemondo.eyescube E/AndroidRuntime: Device fingerprint: ...
01-12 12:46:25.139 30609-30609/com.lemondo.eyescube I/Process: Sending signal. PID: 30609 SIG: 9
</code></pre>

<p>Similar questions on SO just say to tweak Google Analytics, which I don't use at all. Weird thing is it does not even catch an exception - just Boom! Crash! Does anyone have an idea what could be wrong? Thanks in advance!</p>