Firebase Recycler Adapter无法在签名的apk中使用

时间:2018-03-16 12:22:58

标签: android firebase firebase-realtime-database recycler-adapter firebaseui

首先是Debug APK Result&第二个是签名APK结果:

Img 1 Img 2

嗯,下面是代码: 我搜索了类似问题的堆栈,但没有任何帮助我。

        FirebaseRecyclerAdapter<EventDisplayModel,PostViewHolder> fireImageAdapter = new FirebaseRecyclerAdapter<EventDisplayModel, PostViewHolder>
            (EventDisplayModel.class,R.layout.parent_event_display_style,PostViewHolder.class,dbRef)
    {
        @Override
        protected void populateViewHolder(PostViewHolder viewHolder, EventDisplayModel model, int position) {
            viewHolder.setTitle(model.getTitle());
            viewHolder.setDescription(model.getDescription());
            viewHolder.setDownload_URL(getApplicationContext(), model.getDownload_URL());
            viewHolder.setDateTime(model.getDate_Time());
            if(model.getLat_Lng()==null)
            {
                viewHolder.setVenue(model.getVenue());
            }
            else
            {
                viewHolder.setLat_Lng(model.getLat_Lng());
            }
        }
    };

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(fireImageAdapter);

这是postviewholder类

public static class PostViewHolder extends RecyclerView.ViewHolder{

    View mView;

    public PostViewHolder(View itemView) {
        super(itemView);
        mView = itemView;
    }

    public void setTitle(String title){
        TextView post_title = mView.findViewById(R.id.tvPostTitle);
        post_title.setText(title);
    }

    void setDescription(String description){
        TextView post_desc = mView.findViewById(R.id.tvPostDesc);
        post_desc.setText("Description : " + description);
    }

    //Set Download_URL
    //Set Date_time
    //Set Venue
    //Set Lat_Lng      
}

最后:

public class EventDisplayModel {

private String Title;
private String Description;
private String Download_URL;
private String Date_Time;
private String Venue;
private String Lat_Lng;

public EventDisplayModel(){}

public EventDisplayModel(String title, String description, String download_URL, String date_Time, String venue, String lat_Lng) {
    Title = title;
    Description = description;
    Download_URL = download_URL;
    Date_Time = date_Time;
    Venue = venue;
    Lat_Lng = lat_Lng;
}
   //Getter and setter methods here
}

那么,我哪里错了?我想知道将它从生产版本中删除。

3 个答案:

答案 0 :(得分:0)

嘿,你需要检查一下proguard规则。

如果您忘记在proguard中包含依赖项,则会出现此问题。

答案 1 :(得分:0)

首先将fireImageAdapter变量设为全局。

FirebaseRecyclerAdapter<EventDisplayModel,PostViewHolder> fireImageAdapter;

然后只需删除适配器初始化的FirebaseRecyclerAdapter<EventDisplayModel,PostViewHolder>

因此,为了解决这个问题,您需要覆盖onStart()方法并添加以下代码行:

@Override
protected void onStart() {
    super.onStart();
    fireImageAdapter.startListening();
}

答案 2 :(得分:0)

嗨,我知道它来晚了,但为了未来

检查gradle文件,其发布应如下所示

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

}

按照文档中的说明保存Proguard文件

更多->确保您已在Firebase控制台中同时添加了SHA版本和调试,并且项目中提供了可用的新googleservices文件

谢谢