PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Firebase Authentication WINDEV Mobile 25
Firebase Authentication WINDEV Mobile 25
Iniciado por Charlie Finale, jun., 14 2022 6:44 PM - 1 resposta
Publicado em junho, 14 2022 - 6:44 PM
Hi, I am trying to configure Firebase Authentication as described here.

https://firebase.google.com/docs/auth/android/firebaseui…

N0 matter what I do I cannot get a single line of Java to compile!

To get the right version of Google Play services into Gradle  I have used:-
maven{
url "https://maven.google.com"
}


which seems to work as I can now add the remote dependencies like this and compile without error:-


com.google.firebase firebase-bom 30.1.0
com.google.firebase firebase-analytics +
com.google.firebase firebase-messaging +
com.firebaseui firebase-ui-auth +
com.google.android.gms play-services-base 15.01
com.google.firebase firebase-auth +


Then taking just the first code example by Google  I have tried this as a java code in the Global Procedures:-

import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.IdpResponse;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;

import android.widget.Toast;
import android.view.View;
import android.content.Intent;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import android.widget.TextView;
import android.widget.ImageView;
import android.widget.ArrayAdapter;
import android.view.ViewGroup;
import android.view.View;
import android.content.Context;
import android.app.Activity;
import android.app.ActivityManager;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.firebase.auth.AuthResult;
import com.google.android.gms.tasks.Task;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public static void Firebase()
{

private final ActivityResultLauncher signInLauncher = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(),
new ActivityResultCallback() {
@Override
public void onActivityResult(FirebaseAuthUIAuthenticationResult result) {
onSignInResult(result);
}
}
);

}

Error returned:
:compileReleaseJavaWithJavac FAILED
F:\My Mobile Projects\firetemp\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:103: error: illegal start of expression
private final ActivityResultLauncher<Intent> signInLauncher = registerForActivityResult(
^
1 error

FAILURE: Build failed with an exception.

The first of many errors is that it will not compile private final. If I try with a different code example that does not use it, I often get "cannot find the symbol and the refers to a Firebase command that I had assumed was part of the firebase libraries. "
So for instance this one (in the format above) errors too.

List<AuthUI.IdpConfig> providers = arrays.asList(
        new AuthUI.IdpConfig.EmailBuilder().build(),
        new AuthUI.IdpConfig.PhoneBuilder().build(),
        new AuthUI.IdpConfig.GoogleBuilder().build(),
        new AuthUI.IdpConfig.FacebookBuilder().build(),
        new AuthUI.IdpConfig.TwitterBuilder().build());

// Create and launch sign-in intent
Intent signInIntent = AuthUI.getInstance()
        .createSignInIntentBuilder()
        .setAvailableProviders(providers)
        .build();
signInLauncher.launch(signInIntent);


:compileReleaseJavaWithJavac FAILED
F:\My Mobile Projects\firetemp\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:136: error: cannot find symbol
signInLauncher.launch(signInIntent);
^
  symbol:   variable signInLauncher

So I have two issues at least, probably because my knowledge of Java is very limited. One is the private final (private void too) , or any other similar code, and the other is the cannot find symbols.
Publicado em junho, 15 2022 - 7:58 AM
I may have made some progress. I have learned that I do get fewer errors if the java is not set as several global procedures, but as one. Makes sense as each. My errors are now these:-

Failure creating the Android application named .


Command line: "C:\Program Files\Java\jdk1.8.0_331\bin\java.exe" -Duser.dir="F:\My Mobile Projects\fire2\Android\gen" "-Dorg.gradle.appname=F:\My Mobile Projects\fire2\Android\gen" -classpath "F:\Program Files (x86)\PC SOFT\WINDEV Mobile 25\Personal\Android\Gradle\lib\gradle-launcher-5.4.1.jar" org.gradle.launcher.GradleMain assembleRelease -b "F:\My Mobile Projects\fire2\Android\gen\build.gradle"


Error returned:
:compileReleaseJavaWithJavac FAILED
F:\My Mobile Projects\fire2\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:122: error: cannot find symbol
ActivityResultLauncher signInLauncher = registerForActivityResult(
^
  symbol:   class ActivityResultLauncher
  location: class GWDCPCOL_GlobalProcedures
F:\My Mobile Projects\fire2\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:123: error: cannot find symbol
new FirebaseAuthUIActivityResultContract(),
    ^
  symbol:   class FirebaseAuthUIActivityResultContract
  location: class GWDCPCOL_GlobalProcedures
F:\My Mobile Projects\fire2\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:124: error: cannot find symbol
new ActivityResultCallback() {
    ^
  symbol:   class ActivityResultCallback
  location: class GWDCPCOL_GlobalProcedures
F:\My Mobile Projects\fire2\Android\gen\src\com\when23\when23\wdgen\GWDCPCOL_GlobalProcedures.java:124: error: cannot find symbol
new ActivityResultCallback() {
                           ^
  symbol:   class FirebaseAuthUIAuthenticationResult
  location: class GWDCPCOL_GlobalProcedures
Note: F:\My Mobile Projects\fire2\Android\gen\src\com\when23\when23\wdgen\GWDFWIN_Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
10 actionable tasks: 6 executed, 4 up-to-date