4

I am getting this error in my Android Studio.Previous version of Firebase SDK supported this but the new SDK is not supporting it.Please help to solve this.

02-11 23:38:47.647  14487-14487/com.potenza_pvt_ltd.AAPS E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.potenza_pvt_ltd.AAPS, PID: 14487
        Theme: themes:{default=overlay:com.cyngn.hexo, iconPack:com.cyngn.hexo, fontPkg:com.cyngn.hexo, com.android.systemui=overlay:com.cyngn.hexo, com.android.systemui.navbar=overlay:com.cyngn.hexo}
        com.google.firebase.database.DatabaseException: Converting to Arrays is not supported, please use Listsinstead
                at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
                at com.google.android.gms.internal.zzaix.zza(Unknown Source)
                at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
                at com.google.android.gms.internal.zzaix$zza.zze(Unknown Source)
                at com.google.android.gms.internal.zzaix$zza.zzaC(Unknown Source)
                at com.google.android.gms.internal.zzaix.zzd(Unknown Source)
                at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
                at com.google.android.gms.internal.zzaix.zza(Unknown Source)
                at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
                at com.potenza_pvt_ltd.AAPS.ExitReceipt$7.onChildAdded(ExitReceipt.java:322)
                at com.google.android.gms.internal.zzaer.zza(Unknown Source)
                at com.google.android.gms.internal.zzagp.zzSu(Unknown Source)
                at com.google.android.gms.internal.zzags$1.run(Unknown Source)
                at android.os.Handler.handleCallback(Handler.java:739)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:148)
                at android.app.ActivityThread.main(ActivityThread.java:5461)
                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)

this is my POJO class

@IgnoreExtraProperties
public class TariffDetails {

    private String vehicle_type;
    private String key;
    private String total_slab_hrs;
    private String no_of_slab_hrs;
    private String inc_dur_hrs;
    private String tariff;
    private String code;
    private int[][] arr;

    public TariffDetails() {

            /*Blank default constructor essential for Firebase*/
    }
    public TariffDetails(String a){

    }
    @JsonProperty("Key")
    public String getKey(){
        return key;
    }
    @JsonProperty("Key")
    public void setKey(String key){
        this.key=key;
    }
    @JsonProperty("vtype")
    public String getVehicle_type(){
        return vehicle_type;
    }
    @JsonProperty("vtype")
    public void setVehicle_type(String key){
        this.vehicle_type=key;
    }
    @JsonProperty("total_slab_hrs")
    public String getTotal_slab_hrs(){
        return total_slab_hrs;
    }
    @JsonProperty("total_slab_hrs")
    public void setTotal_slab_hrs(String key){
        this.total_slab_hrs=key;
    }
    @JsonProperty("no_of_slab_hrs")
    public String getNo_of_slab_hrs(){
        return no_of_slab_hrs;
    }
    @JsonProperty("no_of_slab_hrs")
    public void setNo_of_slab_hrs(String key){
        this.no_of_slab_hrs=key;
    }
    @JsonProperty("inc_dur_hrs")
    public String getInc_dur_hrs(){
        return inc_dur_hrs;
    }
    @JsonProperty("inc_dur_hrs")
    public void setInc_dur_hrs(String key){
        this.inc_dur_hrs=key;
    }
    @JsonProperty("inslipp_tariff")
    public String getInslip_tariff(){
        return tariff;
    }
    @JsonProperty("inslipp_tariff")
    public void setInslip_tariff(String key){
        this.tariff=key;
    }
    @JsonProperty("code")
    public String getCode(){
        return code;
    }
    @JsonProperty("code")
    public void setCode(String key){
        this.code=key;
    }
    @JsonProperty("arr")
    public int[][] getArr(){
        return arr;
    }
    @JsonProperty("arr")
    public void setArr(int[][] a){
        this.arr=a;
    }


}

this is my main part where i call it.

Query queryRef1 = reference.child("users").child("Tariff_Details").orderByChild("vtype").equalTo(code_value_1);
            queryRef1.addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                    Log.d("value of get data", dataSnapshot.getKey());
                    TariffDetails post = dataSnapshot.getValue(TariffDetails.class);
                    tar_arr = post.getArr();
                    for (int i = 0; i < tar_arr.length; i++) {
                        for (int j = 0; j < 3; j++) {
                            Log.d("ARR", String.valueOf(tar_arr[i][j]));
                            arr.add(tar_arr[i][j]);
                        }
                    }
                    if(tar_arr!=null){
                        adapter = new CustomGrid(getApplicationContext(), tar_arr,code_value_1);
                        gridView.setAdapter(adapter);
                        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                            @Override
                            public void onItemClick(AdapterView<?> parent, View view,
                                                    int position, long id) {
                                Toast.makeText(parent.getContext(), "You Clicked at " + position, Toast.LENGTH_SHORT).show();
                            }
                        });
                        adapter.notifyDataSetChanged();
                    }
                    f[0] =1;
                    pb1.setVisibility(View.GONE);
                    linear_layout.setVisibility(View.VISIBLE);
                }

                @Override
                public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                    Log.d("value of get data", dataSnapshot.getKey());
                    TariffDetails post = dataSnapshot.getValue(TariffDetails.class);
                    tar_arr = post.getArr();
                    for (int i = 0; i < tar_arr.length; i++) {
                        for (int j = 0; j < 3; j++) {
                            Log.d("ARR", String.valueOf(tar_arr[i][j]));
                            arr.add(tar_arr[i][j]);
                        }
                    }
                    if(tar_arr!=null){
                        adapter = new CustomGrid(getApplicationContext(), tar_arr,code_value_1);
                        gridView.setAdapter(adapter);
                        adapter.notifyDataSetChanged();
                    }
                }

                @Override
                public void onChildRemoved(DataSnapshot dataSnapshot) {
                    tar_arr = null;
                    adapter.notifyDataSetChanged();
                }

                @Override
                public void onChildMoved(DataSnapshot dataSnapshot, String s) {

                }

                @Override
                public void onCancelled(DatabaseError firebaseError) {

                }
            });
3
  • 1
    you should check this too: firebase.googleblog.com/2014/04/… Commented Feb 11, 2017 at 18:26
  • Link is not working @brykneval. Commented Feb 11, 2017 at 18:39
  • @AmitUpadhyay i have uploaded the code please check and let me know the solution. Commented Feb 11, 2017 at 18:39

1 Answer 1

5

Simple use Arrays.asList(yourArray) to have it as list.

Sign up to request clarification or add additional context in comments.

1 Comment

you can also use yourArray.asList()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.