unresolved reference to getSignInResultFromIntent












0














Hi I'm new to Android Studio and I can't find anything thing online to fix this issue of unresolved reference. I follow a tutorial online to create a Google Sign in through firebase on my App using Kotlin. I Feel like this is an easy fix but I haven't found anything in which to fix this error.



The project can still run the app but it doesn't work properly with my indented UI.



Code screenshot and snip of it below.



import android.content.Intent
import android.content.res.Configuration
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.util.Log
import android.widget.Toast
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.GoogleApiClient
import com.google.firebase.auth.FirebaseAuth
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignInResult
import com.google.android.gms.common.ConnectionResult
import com.google.firebase.auth.AuthCredential
import com.google.firebase.auth.GoogleAuthCredential
import com.google.firebase.auth.GoogleAuthProvider
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
override fun onConnectionFailed(p0: ConnectionResult) {
Toast.makeText(this,""+p0.errorMessage,Toast.LENGTH_SHORT).show() //To change body of created functions use File | Settings | File Templates.
}


companion object {
private val PERMISSION_CODE =9999
}

lateinit var mGoogleApiClient:GoogleApiClient
lateinit var firebaseAuth:FirebaseAuth
//lateinit var alertDialog:AlertDialog

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == PERMISSION_CODE) {
val result:GoogleSignInResult = Auth.GOOGLE_SIGN_IN_API.getSignInResultFromIntent(data) //Error here---
if(result.isSuccess) {
val account:GoogleSignInAccount? = result.signInAccount
val idToken:String? = account!!.idToken

val credential = GoogleAuthProvider.getCredential(idToken,null)
firebaseAuthWithGoogle(credential)
}
else{
Log.d("EDMT_ERROR","Login Unsuccessful")
Toast.makeText(this,"Login Unsuccessful",Toast.LENGTH_SHORT).show()
}
}
}

private fun firebaseAuthWithGoogle(credential: AuthCredential) { // changed from AuthCredential?
firebaseAuth!!.signInWithCredential(credential)
.addOnSuccessListener { authResult ->
val logged_email = authResult.user.email
val logged_activity = Intent(this@MainActivity,LoggedActivity::class.java)
logged_activity.putExtra("email",logged_email)
startActivity(logged_activity)
}
.addOnFailureListener{
e-> Toast.makeText(this,""+e.message,Toast.LENGTH_SHORT).show()
}
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

configureGoogleClient()

firebaseAuth = FirebaseAuth.getInstance()

/*alertDialog = SpotsDialog.Builder(0) //Github thing that i may have to fix
.setContext(this)
.setMessage("Please wait")
.setCancelable(false)
.build() */

btn_sign_in.setOnClickListener {
signIn()
}
}

private fun signIn() {
val Intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient) //maybe add Intent:Intent!
startActivityForResult(intent, PERMISSION_CODE)
}

private fun configureGoogleClient() {
val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) // maybe change to options:GoogleSignInOptions! =
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this,this)
.addApi(Auth.GOOGLE_SIGN_IN_API,options)
.build()
mGoogleApiClient.connect() // don't forget it
}


}



`



Problem here



Link to screenshot of Code










share|improve this question




















  • 1




    please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
    – Evusas
    Nov 22 at 20:48
















0














Hi I'm new to Android Studio and I can't find anything thing online to fix this issue of unresolved reference. I follow a tutorial online to create a Google Sign in through firebase on my App using Kotlin. I Feel like this is an easy fix but I haven't found anything in which to fix this error.



The project can still run the app but it doesn't work properly with my indented UI.



Code screenshot and snip of it below.



import android.content.Intent
import android.content.res.Configuration
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.util.Log
import android.widget.Toast
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.GoogleApiClient
import com.google.firebase.auth.FirebaseAuth
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignInResult
import com.google.android.gms.common.ConnectionResult
import com.google.firebase.auth.AuthCredential
import com.google.firebase.auth.GoogleAuthCredential
import com.google.firebase.auth.GoogleAuthProvider
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
override fun onConnectionFailed(p0: ConnectionResult) {
Toast.makeText(this,""+p0.errorMessage,Toast.LENGTH_SHORT).show() //To change body of created functions use File | Settings | File Templates.
}


companion object {
private val PERMISSION_CODE =9999
}

lateinit var mGoogleApiClient:GoogleApiClient
lateinit var firebaseAuth:FirebaseAuth
//lateinit var alertDialog:AlertDialog

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == PERMISSION_CODE) {
val result:GoogleSignInResult = Auth.GOOGLE_SIGN_IN_API.getSignInResultFromIntent(data) //Error here---
if(result.isSuccess) {
val account:GoogleSignInAccount? = result.signInAccount
val idToken:String? = account!!.idToken

val credential = GoogleAuthProvider.getCredential(idToken,null)
firebaseAuthWithGoogle(credential)
}
else{
Log.d("EDMT_ERROR","Login Unsuccessful")
Toast.makeText(this,"Login Unsuccessful",Toast.LENGTH_SHORT).show()
}
}
}

private fun firebaseAuthWithGoogle(credential: AuthCredential) { // changed from AuthCredential?
firebaseAuth!!.signInWithCredential(credential)
.addOnSuccessListener { authResult ->
val logged_email = authResult.user.email
val logged_activity = Intent(this@MainActivity,LoggedActivity::class.java)
logged_activity.putExtra("email",logged_email)
startActivity(logged_activity)
}
.addOnFailureListener{
e-> Toast.makeText(this,""+e.message,Toast.LENGTH_SHORT).show()
}
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

configureGoogleClient()

firebaseAuth = FirebaseAuth.getInstance()

/*alertDialog = SpotsDialog.Builder(0) //Github thing that i may have to fix
.setContext(this)
.setMessage("Please wait")
.setCancelable(false)
.build() */

btn_sign_in.setOnClickListener {
signIn()
}
}

private fun signIn() {
val Intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient) //maybe add Intent:Intent!
startActivityForResult(intent, PERMISSION_CODE)
}

private fun configureGoogleClient() {
val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) // maybe change to options:GoogleSignInOptions! =
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this,this)
.addApi(Auth.GOOGLE_SIGN_IN_API,options)
.build()
mGoogleApiClient.connect() // don't forget it
}


}



`



Problem here



Link to screenshot of Code










share|improve this question




















  • 1




    please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
    – Evusas
    Nov 22 at 20:48














0












0








0







Hi I'm new to Android Studio and I can't find anything thing online to fix this issue of unresolved reference. I follow a tutorial online to create a Google Sign in through firebase on my App using Kotlin. I Feel like this is an easy fix but I haven't found anything in which to fix this error.



The project can still run the app but it doesn't work properly with my indented UI.



Code screenshot and snip of it below.



import android.content.Intent
import android.content.res.Configuration
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.util.Log
import android.widget.Toast
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.GoogleApiClient
import com.google.firebase.auth.FirebaseAuth
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignInResult
import com.google.android.gms.common.ConnectionResult
import com.google.firebase.auth.AuthCredential
import com.google.firebase.auth.GoogleAuthCredential
import com.google.firebase.auth.GoogleAuthProvider
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
override fun onConnectionFailed(p0: ConnectionResult) {
Toast.makeText(this,""+p0.errorMessage,Toast.LENGTH_SHORT).show() //To change body of created functions use File | Settings | File Templates.
}


companion object {
private val PERMISSION_CODE =9999
}

lateinit var mGoogleApiClient:GoogleApiClient
lateinit var firebaseAuth:FirebaseAuth
//lateinit var alertDialog:AlertDialog

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == PERMISSION_CODE) {
val result:GoogleSignInResult = Auth.GOOGLE_SIGN_IN_API.getSignInResultFromIntent(data) //Error here---
if(result.isSuccess) {
val account:GoogleSignInAccount? = result.signInAccount
val idToken:String? = account!!.idToken

val credential = GoogleAuthProvider.getCredential(idToken,null)
firebaseAuthWithGoogle(credential)
}
else{
Log.d("EDMT_ERROR","Login Unsuccessful")
Toast.makeText(this,"Login Unsuccessful",Toast.LENGTH_SHORT).show()
}
}
}

private fun firebaseAuthWithGoogle(credential: AuthCredential) { // changed from AuthCredential?
firebaseAuth!!.signInWithCredential(credential)
.addOnSuccessListener { authResult ->
val logged_email = authResult.user.email
val logged_activity = Intent(this@MainActivity,LoggedActivity::class.java)
logged_activity.putExtra("email",logged_email)
startActivity(logged_activity)
}
.addOnFailureListener{
e-> Toast.makeText(this,""+e.message,Toast.LENGTH_SHORT).show()
}
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

configureGoogleClient()

firebaseAuth = FirebaseAuth.getInstance()

/*alertDialog = SpotsDialog.Builder(0) //Github thing that i may have to fix
.setContext(this)
.setMessage("Please wait")
.setCancelable(false)
.build() */

btn_sign_in.setOnClickListener {
signIn()
}
}

private fun signIn() {
val Intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient) //maybe add Intent:Intent!
startActivityForResult(intent, PERMISSION_CODE)
}

private fun configureGoogleClient() {
val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) // maybe change to options:GoogleSignInOptions! =
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this,this)
.addApi(Auth.GOOGLE_SIGN_IN_API,options)
.build()
mGoogleApiClient.connect() // don't forget it
}


}



`



Problem here



Link to screenshot of Code










share|improve this question















Hi I'm new to Android Studio and I can't find anything thing online to fix this issue of unresolved reference. I follow a tutorial online to create a Google Sign in through firebase on my App using Kotlin. I Feel like this is an easy fix but I haven't found anything in which to fix this error.



The project can still run the app but it doesn't work properly with my indented UI.



Code screenshot and snip of it below.



import android.content.Intent
import android.content.res.Configuration
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.util.Log
import android.widget.Toast
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.GoogleApiClient
import com.google.firebase.auth.FirebaseAuth
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.auth.api.signin.GoogleSignInResult
import com.google.android.gms.common.ConnectionResult
import com.google.firebase.auth.AuthCredential
import com.google.firebase.auth.GoogleAuthCredential
import com.google.firebase.auth.GoogleAuthProvider
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
override fun onConnectionFailed(p0: ConnectionResult) {
Toast.makeText(this,""+p0.errorMessage,Toast.LENGTH_SHORT).show() //To change body of created functions use File | Settings | File Templates.
}


companion object {
private val PERMISSION_CODE =9999
}

lateinit var mGoogleApiClient:GoogleApiClient
lateinit var firebaseAuth:FirebaseAuth
//lateinit var alertDialog:AlertDialog

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == PERMISSION_CODE) {
val result:GoogleSignInResult = Auth.GOOGLE_SIGN_IN_API.getSignInResultFromIntent(data) //Error here---
if(result.isSuccess) {
val account:GoogleSignInAccount? = result.signInAccount
val idToken:String? = account!!.idToken

val credential = GoogleAuthProvider.getCredential(idToken,null)
firebaseAuthWithGoogle(credential)
}
else{
Log.d("EDMT_ERROR","Login Unsuccessful")
Toast.makeText(this,"Login Unsuccessful",Toast.LENGTH_SHORT).show()
}
}
}

private fun firebaseAuthWithGoogle(credential: AuthCredential) { // changed from AuthCredential?
firebaseAuth!!.signInWithCredential(credential)
.addOnSuccessListener { authResult ->
val logged_email = authResult.user.email
val logged_activity = Intent(this@MainActivity,LoggedActivity::class.java)
logged_activity.putExtra("email",logged_email)
startActivity(logged_activity)
}
.addOnFailureListener{
e-> Toast.makeText(this,""+e.message,Toast.LENGTH_SHORT).show()
}
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

configureGoogleClient()

firebaseAuth = FirebaseAuth.getInstance()

/*alertDialog = SpotsDialog.Builder(0) //Github thing that i may have to fix
.setContext(this)
.setMessage("Please wait")
.setCancelable(false)
.build() */

btn_sign_in.setOnClickListener {
signIn()
}
}

private fun signIn() {
val Intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient) //maybe add Intent:Intent!
startActivityForResult(intent, PERMISSION_CODE)
}

private fun configureGoogleClient() {
val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) // maybe change to options:GoogleSignInOptions! =
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this,this)
.addApi(Auth.GOOGLE_SIGN_IN_API,options)
.build()
mGoogleApiClient.connect() // don't forget it
}


}



`



Problem here



Link to screenshot of Code







android android-studio kotlin google-authentication






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 10:24









Alex Riley

76.9k21156161




76.9k21156161










asked Nov 22 at 20:41









SerLanceleot

12




12








  • 1




    please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
    – Evusas
    Nov 22 at 20:48














  • 1




    please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
    – Evusas
    Nov 22 at 20:48








1




1




please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
– Evusas
Nov 22 at 20:48




please add the problem verbally or as a picture here - when the picture link expires your question might become irrelevant for the future readers
– Evusas
Nov 22 at 20:48












1 Answer
1






active

oldest

votes


















0














You should just need to replace GOOGLE_SIGN_IN_API with GoogleSignInApi on the line with the error. Make sure you read the API docs, like these: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInApi






share|improve this answer





















  • Thanks!! That fixed it
    – SerLanceleot
    Nov 22 at 22:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437762%2funresolved-reference-to-getsigninresultfromintent%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You should just need to replace GOOGLE_SIGN_IN_API with GoogleSignInApi on the line with the error. Make sure you read the API docs, like these: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInApi






share|improve this answer





















  • Thanks!! That fixed it
    – SerLanceleot
    Nov 22 at 22:52
















0














You should just need to replace GOOGLE_SIGN_IN_API with GoogleSignInApi on the line with the error. Make sure you read the API docs, like these: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInApi






share|improve this answer





















  • Thanks!! That fixed it
    – SerLanceleot
    Nov 22 at 22:52














0












0








0






You should just need to replace GOOGLE_SIGN_IN_API with GoogleSignInApi on the line with the error. Make sure you read the API docs, like these: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInApi






share|improve this answer












You should just need to replace GOOGLE_SIGN_IN_API with GoogleSignInApi on the line with the error. Make sure you read the API docs, like these: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInApi







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 20:50









Paul Millerd

161




161












  • Thanks!! That fixed it
    – SerLanceleot
    Nov 22 at 22:52


















  • Thanks!! That fixed it
    – SerLanceleot
    Nov 22 at 22:52
















Thanks!! That fixed it
– SerLanceleot
Nov 22 at 22:52




Thanks!! That fixed it
– SerLanceleot
Nov 22 at 22:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437762%2funresolved-reference-to-getsigninresultfromintent%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks