2017-08-09 71 views
1

我在片段活動上創建了一個包含RecyclerView的項目。但是當我執行這個項目時會顯示這樣的錯誤。關於firebase 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) at com.phoneinfo.changerpro.hooks.g.a(Unknown Source) at com.phoneinfo.changerpro.hooks.MainHook.handleLoadPackage(Unknown Source) 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) at android.app.ActivityThread.handleBindApplication() at android.app.ActivityThread.access$1600(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5296) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:163)

RecyclerView在應用程序本身的值沒有任何錯誤。但是,當我試圖從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); 
     } 
    } 
} 

型號文檔類: -

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' 

回答

0

試試這個代碼

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 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); 
     } 
    } 
} 

你可以通過這個鏈接也可對照 firebase-recycleradapter

相關問題