2

Firebaseデータベースに値を格納するためのモデルクラスがありますが、リリースモードで実行したり、release .apkを生成するとFirebaseデータベースに間違った値が実際のjsonは投稿されません)。AndroidベースのアプリケーションでFirebaseデータベースに間違った値が挿入されています

-KWqzFGEvUyCLx6obroBaddclose 
    a: "hLjOMC64NRdjqR0nfaUKhR3qz0l2" 
    b: "[email protected]" 

マイProGuardのエントリの

-keep @com.google.gson.annotations.Expose public class * 
    -dontwarn sun.misc.Unsafe 
    -dontwarn android.databinding.** 
    -keep class android.databinding.** { *; } 



    # Facebook library 
    -dontwarn javax.annotation.** 
    -dontwarn okio.** 
    -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 
    -keep @com.facebook.common.internal.DoNotStrip class * 
    -keepclassmembers class * { 
     @com.facebook.common.internal.DoNotStrip *; 
    } 

    ####################Retrofit############## 

    # Platform calls Class.forName on types which do not exist on Android to determine platform. 
    -dontnote retrofit2.Platform 
    # Platform used when running on RoboVM on iOS. Will not be used at runtime. 
    -dontnote retrofit2.Platform$IOS$MainThreadExecutor 
    # Platform used when running on Java 8 VMs. Will not be used at runtime. 
    -dontwarn retrofit2.Platform$Java8 
    # Retain generic type information for use by reflection by converters and adapters. 
    -keepattributes Signature 
    # Retain declared checked exceptions for use by a Proxy instance. 
    -keepattributes Exceptions 

    ########################################## 


    -keep class com.firebase.** { *; } 
    -keep class org.apache.** { *; } 
    -keepnames class com.fasterxml.jackson.** { *; } 
    -keepnames class javax.servlet.** { *; } 
    -keepnames class org.ietf.jgss.** { *; } 
    -dontwarn org.w3c.dom.** 
    -dontwarn org.joda.time.** 
    -dontwarn org.shaded.apache.** 
    -dontwarn org.ietf.jgss.** 

あなたがコードを示していないので、非常に正確な答えを与えるために警告

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(c.a.a.g.b) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 

答えて

2

困難をビルドします。その後、

public class MyData {  
    private String id ; 
    private String email ;  
} 

そして:

MyData myData = ... ; 
databaseReference.push().setValue(myData); 

問題はMyDataには難読化されることをである

は、私はあなたがどこかに、このようなコードを持っていることを前提としています。 2つの可能な解決策は、あります

のMyDataの難読化を防ぐため次のいずれか

-keepnames class com.example.MyData 
-keepclassmembers class com.example.MyData {*;} 

またはをfirebaseするために送られているものの上により細かい制御を持っている:

public class MyData { 

    private String id ; 
    private String email ; 

    public Map<String, Object> toMap() { 
     Map<String, Object> map = new HashMap<>(); 
     map.put("id", id); 
     map.put("email", email); 
     return map ; 
    } 
} 

をそして:

MyData myData = ... ; 
databaseReference.push().setValue(myData.toMap()); 

MyDataが難読化されている場合、このソリューションはイベントを処理する必要があります。

希望すると、これが役に立ちます。

+0

通常のケースではうまくいくはずですが、残念ながらStack-Overflowに質問を投稿する前に、私は他のスレッドから得た両方のソリューションを実装しました。まだエラーは解決されていませんでした。そこで、私はリリースモードでデバッグを有効にし、モデルクラス自体に例外が生成されたことを確認しました。デバッグモードでは発生していなかった例外が生成された "equals"メソッドをオーバーライドしました。私は一時的にエラーにパッチを当てましたが、なぜ例外がリリースモードでのみ生成されるのか不思議です。 – user2837615

+0

@ user2837615リリースでのみ問題が発生した場合は、難読化問題のように見えます。しかし、上記の最初の解決策(MyDataの難読化を防ぐ)は、問題を解決したはずです。たぶんequals()メソッドと例外スタックの両方を投稿することができますか? – Benoit

関連する問題