I've got a sample app from a website to learn about Google Games Signin. The App crashes on start. Here's the link to the website I'm using. Here is the Java
class of the only Activity. It is supposed to prompt a signin when the application is opened.
import android.os.CountDownTimer;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
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.firebase.analytics.FirebaseAnalytics;
public class MainActivity extends AppCompatActivity{
private FirebaseAnalytics mFirebaseAnalytics;
private Button mainButton;
private TextView scoreView;
private TextView timeView;
private int score = 0;
private boolean playing = false;
GoogleApiClient apiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mainButton = (Button)findViewById(R.id.main_button);
scoreView = (TextView)findViewById(R.id.score_view);
timeView = (TextView)findViewById(R.id.time_view);
apiClient = new GoogleApiClient.Builder(this)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(getApplicationContext(), "Could not Sign in", Toast.LENGTH_SHORT).show();
}
})
.build();
mainButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!playing) {
// The first click
playing = true;
mainButton.setText("Keep Clicking");
// Initialize CountDownTimer to 60 seconds
new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
timeView.setText("Time remaining: " + millisUntilFinished/1000);
}
@Override
public void onFinish() {
playing = false;
timeView.setText("Game over");
mainButton.setVisibility(View.GONE);
}
}.start(); // Start the timer
} else {
// Subsequent clicks
score++;
scoreView.setText("Score: " + score + " points");
}
}
});
}
}
And here's the logs:
07-01 11:20:48.616 31570-31570/carsquared.mylittlegame E/AndroidRuntime: FATAL EXCEPTION: main
Process: carsquared.mylittlegame, PID: 31570
Theme: themes:{com.teslacoilsw.launcher=overlay:system, com.google.android.apps.nexuslauncher=overlay:org.cyanogenmod.hexolibre, default=overlay:org.cyanogenmod.hexolibre, iconPack:system, fontPkg:system, com.android.systemui=overlay:org.cyanogenmod.hexolibre, com.android.systemui.navbar=overlay:system}
java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
at com.google.android.gms.common.internal.zzf$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzf$zza.zzu(Unknown Source)
at com.google.android.gms.common.internal.zzf$zze.zzxa(Unknown Source)
at com.google.android.gms.common.internal.zzf$zzd.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)