J'ai un problème avec cette implémentation. L'exécution sans utiliser firebase-ui, comme on le voit dans le Code , fonctionne parfaitementL'implémentation firebase-ui et appcompat lance "requestFeature() doit être appelée avant d'ajouter du contenu"
Si activer firebase-ui comme indiqué dans Code 2, il génère une erreur dans l'exécution de GetWindow
code 1:
public class MainActivity extends Activity {
//private Firebase mFirebaseRef;
private ImageButton buttonMostrar;
private ImageButton buttonMostrarJirafa;
private ImageButton buttonMostrarPanda;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Firebase.setAndroidContext(this);
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setContentView(R.layout.activity_main);
...
code 2
public class MainActivity extends FirebaseLoginBaseActivity {
private Firebase mFirebaseRef;
private ImageButton buttonMostrar;
private ImageButton buttonMostrarJirafa;
private ImageButton buttonMostrarPanda;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Firebase.setAndroidContext(this);
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setContentView(R.layout.activity_main);
...
Dépendances:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.android.support:cardview-v7:23.1.1'
}
Erreur:
02-12 20:12:05.735 29271-29277/com.desarrollandolatam.nbortolotti.mobileacademialatam
E/art: Failed sending reply to debugger: Broken pipe 02-12 20:12:06.039 29271-29271/com.desarrollandolatam.nbortolotti.mobileacademialatam E/AndroidRuntime: FATAL EXCEPTION: main Process: com.desarrollandolatam.nbortolotti.mobileacademialatam, PID: 29271 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.desarrollandolatam.nbortolotti.mobileacademialatam/com.desarrollandolatam.nbortolotti.mobileacademialatam.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:317) at com.desarrollandolatam.nbortolotti.mobileacademialatam.MainActivity.onCreate(MainActivity.java:35) at android.app.Activity.performCreate(Activity.java:6251) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Note: l'intégration avec firebase-ui fonctionne parfaitement seul.
¿Idées?
modification:
@Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS);
super.onCreate(savedInstanceState);
Firebase.setAndroidContext(this);
//getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setContentView(R.layout.activity_main);
maintenant l'erreur est plus setContentView (R.layout.activity_main);
Mise en page:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollGeneral">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linear_general">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/login" />
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view_tigre"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="300dp"
card_view:cardCornerRadius="4dp">
<ImageView android:contentDescription="@string/descripcionTigre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType = "centerCrop"
android:id="@+id/imagenTigre"
android:layout_marginBottom="16dp"
android:background="@drawable/tigre_10">
</ImageView>
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/valor_accion"
android:id="@+id/buttonMostrar"
android:layout_below="@+id/textNombre"
android:contentDescription="@string/descripcionTigre"
android:src="@drawable/icon40x40">
</ImageButton>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view_jirafa"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="300dp"
card_view:cardCornerRadius="4dp"
>
<ImageView android:contentDescription="@string/descripcionJirafa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType = "centerCrop"
android:id="@+id/imagenJirafa"
android:layout_marginBottom="16dp"
android:background="@drawable/jirafa_10">
</ImageView>
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/valor_accion_jirafa"
android:id="@+id/buttonMostrarJirafa"
android:layout_below="@+id/textNombre"
android:layout_alignParentStart="true"
android:contentDescription="@string/descripcionJirafa"
android:src="@drawable/icon40x40"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view_oso"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="300dp"
card_view:cardCornerRadius="4dp">
<ImageView android:contentDescription="@string/descripcionJirafa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType = "centerCrop"
android:id="@+id/imagenOso"
android:layout_marginBottom="16dp"
android:background="@drawable/panda">
</ImageView>
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/valor_accion_panda"
android:id="@+id/buttonMostrarPanda"
android:layout_below="@+id/textNombrePanda"
android:layout_alignParentStart="true"
android:contentDescription="@string/descripcionPanda"
android:src="@drawable/icon40x40"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view_elefante"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<ImageButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/valor_accion_elefante"
android:id="@+id/buttonMostrarElefante"
android:layout_below="@+id/textNombre"
android:layout_alignParentStart="true"
android:contentDescription="@string/descripcionElefante" />
</android.support.v7.widget.CardView>
</LinearLayout>
erreur:
02-12 21:00:05.780 23785-23785/com.desarrollandolatam.nbortolotti.mobileacademialatam E/AndroidRuntime: FATAL EXCEPTION: main Process: com.desarrollandolatam.nbortolotti.mobileacademialatam, PID: 23785 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.desarrollandolatam.nbortolotti.mobileacademialatam/com.desarrollandolatam.nbortolotti.mobileacademialatam.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:124) at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59) at com.desarrollandolatam.nbortolotti.mobileacademialatam.MainActivity.onCreate(MainActivity.java:32) at android.app.Activity.performCreate(Activity.java:6251) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
fixe dernière erreur:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
reconstruire et ça marche!
Merci ian! ... J'ai changé le code, mais maintenant j'ai une autre erreur dans setContentView (R.layout.activity_main) ;, j'ai laissé la modification et la mise en page dans le message principal. –
Avez-vous essayé de rechercher le nouveau message d'erreur? À ce stade, c'est une question totalement différente (celle qui a déjà été résolue plusieurs fois). – ianhanniballake
Oui vrai, mais j'ai peur que le problème vient de "..extends FirebaseLoginBaseActivity" Peut-on s'en défaire, non? –