0

I am developing a map Android app, and trying to implement a Google Sign-up with the following activity:

public class SignClient extends FragmentActivity {

    GoogleSignInClient gsc;
    GoogleSignInOptions gso;
    String tagFailGoogleAuthentication = "Authentication failed";
    SignInButton signInButton;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken("513808725958-mtdpebgv65gic3c905a91q4rc1ncsg8k.apps.googleusercontent.com").build();
        gsc = GoogleSignIn.getClient(this, gso);
        signInButton = findViewById(R.id.google_button);
        signInButton.setSize(SignInButton.SIZE_STANDARD);
        findViewById(R.id.google_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (view.getId()){
                    case R.id.google_button:
                        signIn();
                        break;
                }
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
        if (account != null){
            setContentView(R.layout.activity_maps);
        } else {
            setContentView(R.layout.activity_home);
        }
    }

    private void signIn() {
            Intent signIntent = gsc.getSignInIntent();
            startActivityForResult(signIntent, 10);
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == 10) {
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                task.getResult(ApiException.class);
              handleSignInResult(task);
                navigateToSecondActivity();
            } catch (ApiException e) {
                Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
            }
        }
    }

    private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);
            setContentView(R.layout.activity_maps);
        } catch (ApiException e) {
            Log.w(tagFailGoogleAuthentication, "signInResult:failed code=" + e.getStatusCode());
            Toast.makeText(SignClient.this, "Your Google authentication is failed", Toast.LENGTH_LONG).show();
        }
    }


    private void navigateToSecondActivity() {
        Intent intent = new Intent(SignClient.this, MapsActivity.class);
        startActivity(intent);
        setContentView(R.layout.activity_maps);
    }


}

However, I have got this error while building:

Note: C:\Users\utilisateur\AndroidStudioProjects\ToiletsGo\app\src\main\java\com\example\toiletsgo\SignClient.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

The debug message is:

Executing tasks: [:app:assembleDebug] in project C:\Users\utilisateur\AndroidStudioProjects\ToiletsGo

Starting Gradle Daemon... Gradle Daemon started in 1 s 633 ms

Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app:mergeDebugNativeDebugMetadata NO-SOURCE Task :app:compileDebugAidl NO-SOURCE Task :app:compileDebugRenderscript NO-SOURCE Task :app:dataBindingMergeDependencyArtifactsDebug UP-TO-DATE Task :app:dataBindingMergeGenClassesDebug UP-TO-DATE Task :app:generateDebugResValues UP-TO-DATE Task :app:generateDebugResources UP-TO-DATE Task :app:mergeDebugResources UP-TO-DATE Task :app:packageDebugResources UP-TO-DATE Task :app:parseDebugLocalResources UP-TO-DATE Task :app:dataBindingGenBaseClassesDebug UP-TO-DATE Task :app:generateDebugBuildConfig UP-TO-DATE Task :app:javaPreCompileDebug UP-TO-DATE Task :app:checkDebugAarMetadata UP-TO-DATE Task :app:createDebugCompatibleScreenManifests UP-TO-DATE Task :app:extractDeepLinksDebug UP-TO-DATE Task :app:processDebugMainManifest Task :app:processDebugManifest Task :app:mergeDebugShaders UP-TO-DATE Task :app:compileDebugShaders NO-SOURCE Task :app:generateDebugAssets UP-TO-DATE Task :app:mergeDebugAssets UP-TO-DATE Task :app:compressDebugAssets UP-TO-DATE Task :app:processDebugJavaRes NO-SOURCE Task :app:mergeDebugJavaResource UP-TO-DATE Task :app:checkDebugDuplicateClasses UP-TO-DATE Task :app:desugarDebugFileDependencies Task :app:mergeDebugJniLibFolders UP-TO-DATE Task :app:mergeDebugNativeLibs NO-SOURCE Task :app:stripDebugDebugSymbols NO-SOURCE Task :app:validateSigningDebug UP-TO-DATE Task :app:writeDebugAppMetadata UP-TO-DATE Task :app:mergeLibDexDebug Task :app:writeDebugSigningConfigVersions Task :app:processDebugManifestForPackage Task :app:processDebugResources

Task :app:compileDebugJavaWithJavac Note: C:\Users\utilisateur\AndroidStudioProjects\ToiletsGo\app\src\main\java\com\example\toiletsgo\SignClient.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

Task :app:mergeExtDexDebug Task :app:dexBuilderDebug Task :app:mergeProjectDexDebug Task :app:packageDebug Task :app:createDebugApkListingFileRedirect UP-TO-DATE Task :app:assembleDebug

BUILD SUCCESSFUL in 16s 33 actionable tasks: 12 executed, 21 up-to-date

Build Analyzer results available

The logcat report is the following

2022-05-29 13:46:24.740 635-635/com.example.toiletsgo I/ample.toiletsg: Late-enabling -Xcheck:jni 2022-05-29 13:46:24.785 635-635/com.example.toiletsgo W/ample.toiletsg: Unexpected CPU variant for X86 using defaults: x86_64 2022-05-29 13:46:25.026 635-635/com.example.toiletsgo W/re-initialized>: type=1400 audit(0.0:394): avc: granted { execute } for path="/data/data/com.example.toiletsgo/code_cache/startup_agents/50cdcce7-agent.so" dev="dm-30" ino=139742 scontext=u:r:untrusted_app:s0:c148,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c148,c256,c512,c768 tclass=file app=com.example.toiletsgo 2022-05-29 13:46:25.055 635-635/com.example.toiletsgo W/ample.toiletsg: DexFile /data/data/com.example.toiletsgo/code_cache/.studio/instruments-88564b4d.jar is in boot class path but is not in a known location 2022-05-29 13:46:25.110 635-635/com.example.toiletsgo W/ample.toiletsg: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2022-05-29 13:46:25.110 635-635/com.example.toiletsgo W/ample.toiletsg: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2022-05-29 13:46:26.023 635-693/com.example.toiletsgo W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2022-05-29 13:46:26.024 635-693/com.example.toiletsgo W/OpenGLRenderer: Failed to initialize 101010-2 format, error = EGL_SUCCESS 2022-05-29 13:46:26.075 635-693/com.example.toiletsgo I/Gralloc4: mapper 4.x is not supported 2022-05-29 13:46:26.086 635-693/com.example.toiletsgo W/Gralloc4: allocator 4.x is not supported 2022-05-29 13:46:26.866 635-664/com.example.toiletsgo I/ample.toiletsg: Background young concurrent copying GC freed 7614(636KB) AllocSpace objects, 0(0B) LOS objects, 91% free, 2242KB/26MB, paused 9.002ms,92us total 78.478ms 2022-05-29 13:46:26.874 635-670/com.example.toiletsgo W/System: A resource failed to call close. 2022-05-29 13:46:27.948 635-635/com.example.toiletsgo I/DynamiteModule: Considering local module com.google.android.gms.signinbutton_dynamite:0 and remote module com.google.android.gms.signinbutton_dynamite:2 2022-05-29 13:46:27.948 635-635/com.example.toiletsgo I/DynamiteModule: Selected remote version of com.google.android.gms.signinbutton_dynamite, version >= 2

Any suggestions please?

new name
  • 15,861
  • 19
  • 68
  • 114
yassine
  • 11
  • 3

0 Answers0