运行app时出现此错误。我已在下面发布了我的代码。
09-23 15:40:02.995 23658-23677/com.cleanpune.android.cleanpuneproject E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzro.zzg
09-23 15:40:05.985 23658-23694/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5d26e508 cert_verify_callback x509_store_ctx=0x5e497a40 arg=0x0
09-23 15:40:05.986 23658-23696/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5d26e328 cert_verify_callback x509_store_ctx=0x5e597a40 arg=0x0
09-23 15:40:05.987 23658-23694/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5d26e508 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
09-23 15:40:05.988 23658-23696/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5d26e328 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
09-23 15:40:08.181 23658-23742/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5ec91e38 cert_verify_callback x509_store_ctx=0x5e497ab0 arg=0x0
09-23 15:40:08.184 23658-23742/com.cleanpune.android.cleanpuneproject E/NativeCrypto: ssl=0x5ec91e38 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
09-23 15:40:12.161 23658-23658/com.cleanpune.android.cleanpuneproject E/test: Exception
09-23 15:40:12.170 23658-23658/com.cleanpune.android.cleanpuneproject E/AndroidRuntime: FATAL EXCEPTION: main
com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: details
at com.google.android.gms.internal.zzaln$zza.zzst(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzaln.zzj(Unknown Source)
at com.google.android.gms.internal.zzaln.zzd(Unknown Source)
at com.google.android.gms.internal.zzaln.zzb(Unknown Source)
at com.google.android.gms.internal.zzaln.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.firebase.ui.database.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:154)
at com.firebase.ui.database.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:143)
at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:183)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1482)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:294)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:547)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
我不知道我哪里出错了。请帮忙! 我被包括在所有的库中,并且我用它来检索图像。 这是TestActivity.java
public class TestActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private LinearLayoutManager linearLayoutManager;
private DatabaseReference databaseReference;
private FirebaseRecyclerAdapter<Post, PostViewHolder> mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
databaseReference = FirebaseDatabase.getInstance().getReference().child("Posts");
recyclerView = (RecyclerView) findViewById(R.id.posts_list);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
@Override
public void onStart() {
super.onStart();
mAdapter = new FirebaseRecyclerAdapter<Post, PostViewHolder>(
Post.class,
R.layout.posts_row,
PostViewHolder.class,
databaseReference
)
{
@Override
protected void populateViewHolder(PostViewHolder viewHolder, Post model, int position) {
viewHolder.setDetails(model.getDetails());
viewHolder.setLocation(model.getLocation());
viewHolder.setImages(getApplicationContext(),model.getImages());
}
};
recyclerView.setAdapter(mAdapter);
}
public static class PostViewHolder extends RecyclerView.ViewHolder {
View view;
public PostViewHolder(View itemView) {
super(itemView);
view = itemView;
}
public void setLocation(String location) {
TextView textView = (TextView) view.findViewById(R.id.post_location);
textView.setText(location);
}
public void setDetails(String details) {
TextView textView = (TextView) view.findViewById(R.id.post_location);
textView.setText(details);
}
public void setImages(Context context, String images) {
ImageView image = (ImageView) view.findViewById(R.id.post_image);
Picasso.with(context).load(images).into(image);
}
}
}
这是Model Post类
public class Post {
public String Details, Location, Images;
public Post(String details, String location) {
Details = details;
Location = location;
}
public String getDetails() {
return Details;
}
public String getLocation() {
return Location;
}
public Post(){
}
public String getImages() {
return Images;
}
}
答案 0 :(得分:1)
您的代码中存在一些错误,使Firebase客户端感到困惑:
如果您将课程更改为惯用语,则看起来像
public class Post {
private String details, location, images;
public Post(){ }
public Post(String details, String location) {
this.details = details;
this.location = location;
}
public String getDetails() {
return details;
}
public String getLocation() {
return location;
}
public String getImages() {
return images;
}
}
或者,您可以拥有一个只包含公共字段(并且没有getter / setter)的类:
public class Post {
public String Details, Location, Images;
public Post(){ }
public Post(String details, String location) {
Details = details;
Location = location;
}
}
答案 1 :(得分:0)
请尝试使用此模型类
@IgnoreExtraProperties
public class Post {
public String Details, Location, Images;
public Post(){
}
public Post(String details, String location, String images) {
Details = details;
Location = location;
Images = images;
}
@Exclude
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("Details", Details);
result.put("Location", Location);
result.put("Images", Images);
return result;
}
}