DanBalzeer DanBalzeer - 2 months ago 12
Android Question

Im new to Programming and im trying to implement google signin in my app but ive run into an error and im not sure whats wrong

This is my first time asking a question on stackoverflow so sorry in advance if im doing something wrong.

from previous research it seems the error has to do with a missing curly bracket or something but i cant seem to find the error.

this is my error

Error:(61, 9) error: illegal start of expression
Error:(61, 17) error: illegal start of expression
Error:(61, 28) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.


the error is at

//Start sign in
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}


and my code is

package com.madchallenge2016edwindaniel.upbirdwatchers;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import android.view.View;
import com.google.android.gms.common.ConnectionResult;



public class LoginActivity extends AppCompatActivity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{

private GoogleApiClient mGoogleApiClient;
private SignInButton mSignInButton;
private static final int RC_SIGN_IN = 9001;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);



//Background
getWindow().setBackgroundDrawableResource(R.drawable.login_background);

// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();

// Build a GoogleApiClient with access to the Google Sign-In API and the
// options specified by gso.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();


mSignInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.sign_in_button:
signIn();
break;
// ...
}
}
});

//Start sign in
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}




}

@Override
public void onConnected(Bundle bundle) {

}

@Override
public void onConnectionSuspended(int i) {

}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

}


}

RC. RC.
Answer

A } is missing before private void signIn() { to close the method onCreate.

In order to avoid this kind of typo, always indent your code correctly:

public void foo() {
    // correct
}

public void foo() {
    // incorrect
    }

    public void foo() {
    // incorrect
}
Comments