Skip to content

Commit

Permalink
#50 Fixed gson serialization issue when building release version of t…
Browse files Browse the repository at this point in the history
…he app(prevent R8 from obfuscating serialization too much)
  • Loading branch information
rnyholm committed Mar 30, 2024
1 parent 1ca5547 commit 0b9f20d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
32 changes: 11 additions & 21 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# 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
# Preserve information about line numbers, exception etc. for debugging purposes
-keepattributes SourceFile, LineNumberTable, Exceptions

# 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 *;
#}
# Hide original source file names
-renamesourcefileattribute SourceFile

# 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

# Enumerations must be kept
# Keep enumerations
-keepclassmembers enum ax.stardust.runcalc.** { *; }

# Proguard configuration for Gson
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import androidx.annotation.NonNull;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import ax.stardust.runcalc.function.PredictionDistance;

public class FinishTimePredictions {
@SerializedName("finishTimePredictions")
private final List<FinishTimePrediction> finishTimePredictions = new ArrayList<>();

public void addPrediction(FinishTimePrediction finishTimePrediction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import androidx.annotation.NonNull;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -15,6 +17,7 @@ public class HeartRateZones {
public static final String ZONE_2 = "z2";
public static final String ZONE_1 = "z1";

@SerializedName("heartRateZones")
private final List<HeartRateZone> heartRateZones = new ArrayList<>();

public void addZone(HeartRateZone heartRateZone) {
Expand Down

0 comments on commit 0b9f20d

Please sign in to comment.