私のモデルに何が問題なのですか?Firebaseの解析エラー
私はAndroid RecyclerViewAdapterを使用しています。かなり基本的な設定です - 主にGitHubのアンドロイドの例からコピーされています。
エラーイム取得:
07-08 18:37:49.324 24650-24650/com.brueller E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.crash.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/com.brueller-2/base.apk"],nativeLibraryDirectories=[/data/app/com.brueller-2/lib/arm64, /vendor/lib64, /system/lib64]]
07-08 18:37:50.392 24650-24650/com.brueller E/MainActivity: LAT: 51.5879459| LONG: 10.2771444
07-08 18:37:52.097 24650-24650/com.brueller E/UncaughtException: com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.String to type com.brueller.model.PostModel
at com.google.android.gms.internal.zzaix.zzd(Unknown Source)
at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
at com.google.android.gms.internal.zzaix.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.firebase.ui.database.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:147)
at com.firebase.ui.database.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:136)
at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:176)
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$ViewFlinger.run(RecyclerView.java:4037)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886)
at android.view.Choreographer.doCallbacks(Choreographer.java:698)
at android.view.Choreographer.doFrame(Choreographer.java:630)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5639)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
マイ・モデル・クラス(ログを完了するために更新):
Firebaseデータは、ウェブサイトからJSONにエクスポート
public class PostModel {
public String getPostContent() {
return mPostContent;
}
public void setPostContent(String mPostContent) {
this.mPostContent = mPostContent;
}
public Long getTimeStamp() {
return mTimeStamp;
}
public void setTimeStamp(Long mTimeStamp) {
this.mTimeStamp = mTimeStamp;
}
public String getPostalCode() {
return mPostalCode;
}
public void setPostalCode(String mPostalCode) {
this.mPostalCode = mPostalCode;
}
private String mPostContent;
private Long mTimeStamp;
private String mPostalCode;
}:
{
"test" : {
"postContent" : "hallo",
"postalCode" : "054587",
"timeStamp" : 1467915869142
}
}
ViewHo lder:我々は間違って何が起こっているのかの良いアイデアを得ることができるので、
public class PostHolder extends RecyclerView.ViewHolder {
@BindView(R.id.PostContent) TextView postContentView;
@BindView(R.id.TimeString) TextView timeStringView;
View mView;
public PostHolder (View itemView) {
super(itemView);
mView = itemView;
ButterKnife.bind(this, mView);
}
public void applyModel(PostModel _postModel) {
postContentView.setText(_postModel.getPostContent());
// Convert long to nice string
timeStringView.setText(
android.text.format.DateUtils.getRelativeTimeSpanString((Long)
_postModel.getTimeStamp()).toString());
}
}
はPostModel.java' 'で定義されたクラスですか?それとも何か他の内部クラスです?それはまた、コードを見に役立つだろう –
アクティビティとViewHolderのコードを貼り付けてください –