xamarin component for Firebase Database Android Missing? RRS feed

  • Question

  • User248153 posted

    Hi i am currently testing out some of the Google Firebase capabilities.

    I created a cross platform app (pcl) and installed nugets for Firebase Auth and Firebase Database (iOS and Android) and currently trying to implement Firebase Database to Android. But Somehow i cannot find any documentation for Android.

    On The Component Store there is the https://components.xamarin.com/view/firebaseiosdatabase component with its documentation for iOS. Shouldn't there be also a Android Component (with documentation)?

    The problem is that i am getting an exceptions when adding an ValueEventListener. Unhandled Exception: Java.Lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference

    DatabaseReference database = FirebaseDatabase.Instance.Reference;
    var stringEndPoint = database.Child("TestString");
    stringEndPoint.AddValueEventListener(new ValueEventListener());

    SetValue works fine and writes "asdf" into the database.

    My ValueEventListener looks like this. (I know its empty)

    public class ValueEventListener : IValueEventListener
        private IntPtr _handle;
        public void Dispose(){}
        public IntPtr Handle
            get { return _handle; }
        public void OnCancelled(DatabaseError error){}
        public void OnDataChange(DataSnapshot snapshot){}
    Wednesday, September 27, 2017 6:41 AM

All replies

  • User292698 posted


    You need to read a bit more in Xamarin documentation.

    To implement a Java-origin interface, you must have a base Java-origin class if it requires to have Handle and Dispose members

    In your case, plz correct as below

    ``` public class ValueEventListener : Java.Lang.Object, IValueEventListener { public void OnCancelled(DatabaseError error){}

    public void OnDataChange(DataSnapshot snapshot){}

    } ```


    Thursday, October 5, 2017 9:51 PM