Signin buttons not getting rendered properly in my Android layout.

huangapple go评论70阅读模式
英文:

Signin buttons not getting rendered properly in my Android layout

问题

I created a signin page containing two buttons, one for Google signin and another for passwordless signin:

<com.firebase.ui.auth.ui.phone.CountryListSpinner
    android:id="@+id/signInButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/FirebaseUI.Button.AccountChooser.GoogleButton"
    android:text="@string/fui_sign_in_with_google"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="20dp" />

<com.firebase.ui.auth.ui.phone.CountryListSpinner
    android:id="@+id/emailSignInButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/signInButton"
    android:layout_centerHorizontal="true"
    style="@style/FirebaseUI.Button.AccountChooser.EmailButton"
    android:text="@string/fui_sign_in_with_email"
    tools:ignore="UnusedIds" />

However, when the layout is rendered, the buttons look like this:
Signin buttons not getting rendered properly in my Android layout.
instead of this:
Signin buttons not getting rendered properly in my Android layout.

Also, when I press either button, I get an error:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.IBinder android.view.View.getApplicationWindowToken()' on a null object reference

I confirmed the button views are not null:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    crashlytics = FirebaseCrashlytics.getInstance();

    context = getApplicationContext();

    try {
        setContentView(R.layout.activity_login);
    } catch (RuntimeException ex) {
        Toast.makeText(this, getString(R.string.install_from_google_play), Toast.LENGTH_LONG).show();
        crashlytics.log("Crash on setContentView() in LoginActivity.java: " + ex.getLocalizedMessage());
        return;
    }

    Trace myTrace = FirebasePerformance.getInstance().newTrace("test_trace");
    myTrace.start();

    settings = getSharedPreferences(OPENCOMMENTS_SETTINGS, Context.MODE_PRIVATE);
    editor = settings.edit();

    // Views
    findViewById(R.id.signInButton).setOnClickListener(this);
    findViewById(R.id.emailSignInButton).setOnClickListener(this);
}

Anyone have an idea what's going on here? I'm running Android Studio Electric Eeel (2022.1.1 Canary 7) on a Linux computer and my project gradle file is the following:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.0-alpha07'
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
        classpath 'com.google.firebase:perf-plugin:1.4.2'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
英文:

I created a signin page containing two buttons, one for Google signin and another for passwordless signin:

    &lt;com.firebase.ui.auth.ui.phone.CountryListSpinner
        android:id=&quot;@+id/signInButton&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        style=&quot;@style/FirebaseUI.Button.AccountChooser.GoogleButton&quot;
        android:text=&quot;@string/fui_sign_in_with_google&quot;
        android:layout_centerHorizontal=&quot;true&quot;
        android:layout_marginBottom=&quot;20dp&quot; /&gt;

    &lt;com.firebase.ui.auth.ui.phone.CountryListSpinner
        android:id=&quot;@+id/emailSignInButton&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_below=&quot;@+id/signInButton&quot;
        android:layout_centerHorizontal=&quot;true&quot;
        style=&quot;@style/FirebaseUI.Button.AccountChooser.EmailButton&quot;
        android:text=&quot;@string/fui_sign_in_with_email&quot;
        tools:ignore=&quot;UnusedIds&quot; /&gt;

However, when the layout is rendered, the buttons look like this:
Signin buttons not getting rendered properly in my Android layout.
instead of this:
Signin buttons not getting rendered properly in my Android layout.

Also, when I press either button, I get an error:

java.lang.NullPointerException: Attempt to invoke virtual method &#39;android.os.IBinder android.view.View.getApplicationWindowToken()&#39; on a null object reference

I confirmed the button views are not null:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    crashlytics = FirebaseCrashlytics.getInstance();

    context = getApplicationContext();

    try {
        setContentView(R.layout.activity_login);
    } catch (RuntimeException ex) {
        Toast.makeText(this, getString(R.string.install_from_google_play), Toast.LENGTH_LONG).show();
        crashlytics.log(&quot;Crash on setContentView() in LoginActivity.java: &quot; + ex.getLocalizedMessage());
        return;
    }

    Trace myTrace = FirebasePerformance.getInstance().newTrace(&quot;test_trace&quot;);
    myTrace.start();

    settings = getSharedPreferences(OPENCOMMENTS_SETTINGS, Context.MODE_PRIVATE);
    editor = settings.edit();

    // Views
    findViewById(R.id.signInButton).setOnClickListener(this);
    findViewById(R.id.emailSignInButton).setOnClickListener(this);

Anyone have an idea what's going on here? I'm running Android Studio Electric Eeel (2022.1.1 Canary 7) on a Linux computer and my project gradle file is the following:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath &#39;com.android.tools.build:gradle:7.4.0-alpha07&#39;
        classpath &#39;com.google.gms:google-services:4.3.15&#39;
        classpath &#39;com.google.firebase:firebase-crashlytics-gradle:2.9.5&#39;
        classpath &#39;com.google.firebase:perf-plugin:1.4.2&#39;
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

答案1

得分: 0

这是由com.firebaseui:firebase-ui-auth:8.0.2中的一个错误引起的。一旦我回退到4.3.2版本,问题就解决了。

英文:

This was caused by a bug in com.firebaseui:firebase-ui-auth:8.0.2. Once I reverted to 4.3.2, the problem went away.

huangapple
  • 本文由 发表于 2023年5月10日 16:21:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76216312.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定