【发布时间】:2018-07-24 10:51:45
【问题描述】:
我正在制作一个使用 firebase 数据库的应用。我的应用程序运行时没有崩溃,直到我在 google play 上将它作为测试版发布。当我发布该应用程序时,它不断崩溃并在一行上返回 com.google.firebase.database.DatabaseException。完全相同但未发布的代码不会崩溃。
这是整个堆栈跟踪:
com.google.firebase.database.DatabaseException:
at com.google.android.gms.internal.zzelx.<init> (Unknown Source)
at com.google.android.gms.internal.zzelw.zzf (Unknown Source)
at com.google.android.gms.internal.zzelw.zzbx (Unknown Source)
at com.google.android.gms.internal.zzelw.zzbw (Unknown Source)
at com.google.firebase.database.DatabaseReference.zza (Unknown Source)
at com.google.firebase.database.DatabaseReference.setValue(UnknownSource)
at aheschl.studyup.NewSet$2.onClick (NewSet.java:129)
at android.view.View.performClick (View.java:6308)
at android.widget.TextView.performClick (TextView.java:11202)
at android.view.View$PerformClick.run (View.java:23969)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6816)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1451)
这是堆栈跟踪引用的 onClickListener 中的代码(带有块引用的行是触发错误的原因):
CardSet newSetOfWords = new CardSet(name, words);
String id;
id = user.getUid();
DatabaseReference newReference = database.getReference(id + "/" + name);
newReference.setValue(newSetOfWords);
Intent i = new Intent(NewSet.this, TeacherView.class);
startActivity(i);
finish();
我不知道这是否有帮助,但这是我的数据库访问规则:
{
"rules": {
".read": "true",
".write": "auth != null"
}
}
更新--
这是 proguard-rules.pro
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Add this global rule
-keepattributes Signature
# This rule will properly ProGuard all the model classes in
//This is what I copied off the guide on the firebase website
# the package com.yourcompany.models. Modify to fit the structure
# of your app.
-keepclassmembers class aheschl.studyup.** {
*;
}
这里是 CardSet:
public class CardSet {
private String name;
private ArrayList<String> words;
public CardSet(String name, ArrayList<String> words){
this.name = name;
this.words = words;
}
protected String getName(){
return name;
}
protected ArrayList<String> getWords(){
return words;
}
}
感谢您的帮助!
【问题讨论】:
-
您是否按照Setup Guide 中的说明配置了Proguard?您需要将命令添加到您的
proguard-rules.pro文件以保留模型类。 -
谢谢,我之前没有配置过。我刚刚添加了设置指南中的命令,并将发布一个新版本以查看它是否有效。
-
不幸的是,在我添加了指南中的更改后,它仍然存在同样的问题。
-
您可以发布您的
proguard-rules.pro文件内容吗?我仍然认为问题与您的CardSet类的符号的缩小和删除有关。 -
当然,我会在我的帖子的编辑中添加它。
标签: android firebase firebase-realtime-database google-play