firebase recycleler视图

时间:2017-08-09 04:15:19

标签: android firebase firebase-realtime-database runtime-error

我在片段活动上创建了一个RecyclerView的项目。但是当我执行这个项目时显示这样的错误。

  

java.lang.NoSuchMethodError:android.os.Binder #execTransact(int,int,int,int)#exact                                                                   at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:339)                                                                   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:176)                                                                   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:251)                                                                   在com.phoneinfo.changerpro.hooks.g.a(未知来源)                                                                   在com.phoneinfo.changerpro.hooks.MainHook.handleLoadPackage(未知来源)                                                                   at de.robv.android.xposed.IXposedHookLoadPackage $ Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)                                                                   at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:61)                                                                   at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:106)                                                                   at de.robv.android.xposed.XposedBridge $ 1.beforeHookedMethod(XposedBridge.java:234)                                                                   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:1550)                                                                   在android.app.ActivityThread.handleBindApplication()                                                                   在android.app.ActivityThread.access $ 1600(ActivityThread.java:154)                                                                   在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1378)                                                                   在android.os.Handler.dispatchMessage(Handler.java:102)                                                                   在android.os.Looper.loop(Looper.java:135)                                                                   在android.app.ActivityThread.main(ActivityThread.java:5296)                                                                   at java.lang.reflect.Method.invoke(Native Method)                                                                   在java.lang.reflect.Method.invoke(Method.java:372)                                                                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:912)                                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)                                                                   在de.robv.android.xposed.XposedBridge.main(XposedBridge.java:163)

RecyclerView时来自app本身的值没有任何错误。但是,当我尝试从Firebase检索值到应用时,会出现上述错误并且活动已关闭。

如何解决这个问题?

我的代码: -

public class DocterList extends Fragment {
    private DatabaseReference dataref;
    private RecyclerView recyclerView;
    private List<Doc> result;
    private DocViewHolder adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.activity_docter_list, container, false);
        Firebase.setAndroidContext(getActivity());
        dataref = FirebaseDatabase.getInstance().getReference().child("Docters");
        result = new ArrayList<>();
        recyclerView = (RecyclerView) v.findViewById(R.id.docter_list);
        recyclerView.setHasFixedSize(true);
        LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(llm);
        FirebaseRecyclerAdapter<Doc,DocViewHolder> adapter=new FirebaseRecyclerAdapter<Doc, DocViewHolder>(
                Doc.class,
                R.layout.view_docter,
                DocViewHolder.class,
                dataref
        ) {
            @Override
            protected void populateViewHolder(DocViewHolder viewHolder, Doc model, int position) {
               viewHolder.setName(model.getName());
                viewHolder.setCity(model.getCity());

            }
        };
        recyclerView.setAdapter(adapter);
        return v;
    }
    public static class DocViewHolder extends RecyclerView.ViewHolder{
        TextView textName,textPlace;
        public DocViewHolder(View itemView) {
            super(itemView);
            textName= (TextView) itemView.findViewById(R.id.t1);
            textPlace= (TextView) itemView.findViewById(R.id.t2);
        }

        public void setName(String name) {
            textName.setText(name);
        }

        public void setCity(String city) {
            textPlace.setText(city);
        }
    }
}

模型Doc类: -

public class Doc {
    String Name,City;

    public Doc() {
    }

    public String getCity() {

        return City;
    }

    public void setCity(String city) {
        City = city;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public Doc(String name, String city) {

        Name = name;
        City = city;
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
  exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.github.stfalcon:smsverifycatcher:0.3.1'
compile 'com.github.MdFarhanRaja:SearchableSpinner:1.2'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.google.firebase:firebase-crash:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.android.support:recyclerview-v7:25.3.1'
}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

请检查您是否在build.gradle文件中添加了兼容版本的所有依赖项。有关使用哪个版本的详细信息,请参阅:https://firebase.google.com/docs/android/setup#manually_add_firebase