我正在制作一个使用 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"
}
}
UPDATE--
这是 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.** {
*;
}
这是卡片集:
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;
}
}
谢谢你的帮助!