Я не знаю, что не так, но я создавал это приложение при отладке, и ничего плохого в этом нет, но когда я попытался протестировать сборку релиза, я получаю приложение cra sh в каждом фрагменте, который имеет адаптер запроса с RecyclerView! я действительно не знаю, было ли что-то не так с моим кодом, почему он не взломал sh в отладочной сборке? в любом случае вот фрагмент
public class light_home_fragment extends Fragment implements v1.m.a.t.Adapters.FavAdapter.OnFavSelectedListener {
private Query mQuery;
private static final int LIMIT = 50;
private FavAdapter FavAdapter;
private FirebaseFirestore mFireStore;
private RecyclerView recyclerView;
public light_home_fragment() {
}
private String[] values = {
"Chef","Grocery"
};
private int[] images = {
R.drawable.chef,R.drawable.market_small
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_light_home_fragment, container, false);
GridView homeGridView = view.findViewById(R.id.HomeGridView);
HomeGrideAdapter homeGridAdapter = new HomeGrideAdapter(getActivity(),values,images);
homeGridView.setAdapter(homeGridAdapter);
homeGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if(position==0) {
Intent intent = new Intent(getContext(), DashBoardActivity.class);
String GetExtra = "rClicked";
intent.putExtra("STRING_I_NEED", GetExtra);
startActivity(intent);
}
else if(position==1)
{
Intent intent = new Intent(getContext(), DashBoardActivity.class);
String GetExtra = "mClicked";
intent.putExtra("STRING_I_NEED", GetExtra);
startActivity(intent);
}
}
});
super.onCreate(savedInstanceState);
recyclerView = view.findViewById(R.id.recyclerFav);
mFireStore = FirebaseFirestore.getInstance();
startFav();
return view;
}
private void startFav(){
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
assert currentUser != null;
final String UserPhone = currentUser.getPhoneNumber();
assert UserPhone != null;
mQuery = mFireStore.collection("Users").
document(UserPhone).collection("favList")
.limit(LIMIT);
FavAdapter = new FavAdapter(mQuery,this) {
@Override
protected void onDataChanged() {
if (getItemCount() == 0) {
recyclerView.setVisibility(View.GONE);
}else {
recyclerView.setVisibility(View.VISIBLE);
}
}
};
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(FavAdapter);
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
if (FavAdapter != null) {
FavAdapter.stopListening();
}
}
@Override
public void onResume(){
super.onResume();
}
@Override
public void onFavSelected(DocumentSnapshot fav) {
Intent intent = new Intent(getActivity(), RDetailActivity.class);
intent.putExtra(RDetailActivity.KEY_BID, fav.getId());
startActivity(intent);
}
}
и это мой адаптер
public class FavAdapter extends FirestoreAdapter<FavAdapter.FavViewHolder> {
public interface OnFavSelectedListener {
void onFavSelected(DocumentSnapshot business);
}
private FavAdapter.OnFavSelectedListener mListener;
protected FavAdapter(Query query, FavAdapter.OnFavSelectedListener listener) {
super(query);
mListener = listener;
}
@NonNull
@Override
public FavAdapter.FavViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
return new FavAdapter.FavViewHolder(inflater.inflate(R.layout.fav_item, parent, false));
}
@Override
public void onBindViewHolder(FavAdapter.FavViewHolder holder, int position) {
holder.bind(getSnapshot(position), mListener);
}
public interface OnFavAdapterSelectedListener {
void onFavSelected(DocumentSnapshot Fav);
}
static class FavViewHolder extends RecyclerView.ViewHolder {
ImageView FavImage;
TextView FavText;
FavViewHolder(@NonNull View itemView) {
super(itemView);
FavImage = itemView.findViewById(R.id.FavImg);
FavText = itemView.findViewById(R.id.FavText);
}
void bind(final DocumentSnapshot snapshot,
final FavAdapter.OnFavSelectedListener listener ) {
FavJava fav = snapshot.toObject(FavJava.class);
assert fav != null;
FavText.setText(fav.getName());
if(FavImage != null) {
Glide.with(FavImage.getContext())
.load(fav.getImage_Url())
.apply(RequestOptions.centerCropTransform()
.placeholder(R.drawable.t_logo_new)
.error(R.drawable.pizza_monster)
)
.into(FavImage);
}
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onFavSelected(snapshot);
}
}
});
}
}
}
и это модальное представление
package v1.m.a.t.Java;
import com.google.firebase.firestore.IgnoreExtraProperties;
@IgnoreExtraProperties
public class FavJava {
private String id;
private String name;
private String image_Url;
public FavJava(){}
public FavJava(String id,String name, String image_Url){
this.id = id;
this.name = name;
this.image_Url = image_Url;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImage_Url() {
return image_Url;
}
public void setImage_Url(String image_Url) {
this.image_Url = image_Url;
}
}
журнал ошибок
Process: v1.m.a.t, PID: 7420
java.lang.RuntimeException: No properties to serialize found on class v1.m.a.t.b.d
at com.google.firebase.firestore.u0.n$a.<init>()
at com.google.firebase.firestore.u0.n.a()
at com.google.firebase.firestore.u0.n.a()
at com.google.firebase.firestore.u0.n.b()
at com.google.firebase.firestore.u0.n.a()
at com.google.firebase.firestore.i.a()
at com.google.firebase.firestore.d0.a()
at com.google.firebase.firestore.i.a()
at com.google.firebase.firestore.d0.a()
at v1.m.a.t.a.h$a.a()
at v1.m.a.t.a.h.a()
at v1.m.a.t.a.h.b()
at androidx.recyclerview.widget.RecyclerView$g.a()
at androidx.recyclerview.widget.RecyclerView$g.a()
at androidx.recyclerview.widget.RecyclerView$v.a()
at androidx.recyclerview.widget.RecyclerView$v.a()
at androidx.recyclerview.widget.RecyclerView$v.b()
at androidx.recyclerview.widget.RecyclerView$v.d()
at androidx.recyclerview.widget.LinearLayoutManager$c.a()
at androidx.recyclerview.widget.LinearLayoutManager.a()
at androidx.recyclerview.widget.LinearLayoutManager.a()
at androidx.recyclerview.widget.LinearLayoutManager.e()
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2()
at androidx.recyclerview.widget.RecyclerView.onMeasure()
at android.view.View.measure(View.java:20151)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
at android.view.View.measure(View.java:20151)
at androidx.constraintlayout.widget.ConstraintLayout.a()
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure()
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:20151)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:900)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure()
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure()
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:20151)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3158)
at android.view.View.measure(View.java:20151)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2594)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1549)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1841)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7397)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at andro
04-28 19:55:44.118 3973-8141/? E/android.os.Debug: ro.product_ship = true
04-28 19:55:44.118 3973-8141/? E/android.os.Debug: ro.debug_level = 0x4f4c
04-28 19:55:44.118 3973-8141/? E/android.os.Debug: sys.mobilecare.preload = false
04-28 19:55:44.193 8143-8143/? E/Zygote: v2
04-28 19:55:44.198 8143-8143/? E/Zygote: accessInfo : 0
04-28 19:55:44.498 8165-8165/? E/Zygote: v2
04-28 19:55:44.503 8165-8165/? E/Zygote: accessInfo : 0
04-28 19:55:44.593 6099-10195/? E/art: invalid stream - problem with parameter iterator in /data/app/com.google.android.gms-1/base.apk:classes3.dex for method void com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(int)
04-28 19:55:44.833 6099-10195/? E/art: invalid stream - problem with parameter iterator in /data/app/com.google.android.gms-1/base.apk:classes3.dex for method void com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(int)
04-28 19:55:44.873 8210-8210/? E/Zygote: v2
04-28 19:55:44.878 8210-8210/? E/Zygote: accessInfo : 0
04-28 19:55:44.968 8228-8228/? E/Zygote: v2
04-28 19:55:44.973 8228-8228/? E/Zygote: accessInfo : 0
04-28 19:55:45.113 8250-8250/? E/Zygote: v2
04-28 19:55:45.118 8250-8250/? E/Zygote: accessInfo : 0
04-28 19:55:45.968 8288-8288/? E/Zygote: v2
04-28 19:55:45.973 8288-8288/? E/Zygote: accessInfo : 0
04-28 19:55:46.248 8288-8288/? E/HealthDataStore: disconnectService: Context instance is invalid
04-28 19:55:46.393 8309-8309/? E/Zygote: v2
04-28 19:55:46.393 8309-8309/? E/Zygote: accessInfo : 0
04-28 19:55:47.518 8331-8331/? E/Zygote: v2
04-28 19:55:47.518 8331-8331/? E/Zygote: accessInfo : 0
04-28 19:55:47.608 8331-8343/? E/SPPClientService: ShipBuild Binary : True