Skip to content

Commit 35dde0b

Browse files
authored
refactor: Add keep rules for java types (#949)
We're working to narrow down our consumer rules in RevenueCat/purchases-android#3557. However, this makes it not find our code anymore in Unity when minifying since nothing is directly referencing the Java types from Unity. This adds some Keep annotations that from my tests avoid the issue. This does mean we will need to remember to mark all java types as `@Keep` but it was easier than trying to add proguard rules to be used by our customers when importing our plugins. Note this won't do anything until the purchases-android changes actually get merged
1 parent 525d197 commit 35dde0b

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

RevenueCat/Plugins/Android/PurchasesWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.util.Log;
44

5+
import androidx.annotation.Keep;
56
import androidx.annotation.NonNull;
67
import androidx.annotation.Nullable;
78

@@ -37,6 +38,7 @@
3738

3839
import kotlin.Unit;
3940

41+
@Keep
4042
public class PurchasesWrapper {
4143
private static final String RECEIVE_STOREFRONT = "_receiveStorefront";
4244
private static final String RECEIVE_PRODUCTS = "_receiveProducts";

RevenueCatUI/Plugins/Android/RevenueCatUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/CustomerCenterTrampolineActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import androidx.activity.ComponentActivity;
99
import androidx.activity.result.ActivityResultLauncher;
10+
import androidx.annotation.Keep;
1011
import androidx.annotation.NonNull;
1112
import androidx.annotation.Nullable;
1213

@@ -20,6 +21,7 @@
2021

2122
import kotlin.Unit;
2223

24+
@Keep
2325
public class CustomerCenterTrampolineActivity extends ComponentActivity {
2426
private static final String TAG = "PurchasesUnity";
2527

RevenueCatUI/Plugins/Android/RevenueCatUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/PaywallViewPresenter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import androidx.activity.OnBackPressedDispatcher;
2020
import androidx.activity.OnBackPressedDispatcherOwner;
2121
import androidx.activity.ViewTreeOnBackPressedDispatcherOwner;
22+
import androidx.annotation.Keep;
2223
import androidx.annotation.NonNull;
2324
import androidx.annotation.Nullable;
2425
import androidx.core.graphics.Insets;
@@ -52,6 +53,7 @@
5253

5354
import kotlin.Unit;
5455

56+
@Keep
5557
public class PaywallViewPresenter {
5658

5759
private static final String TAG = "PurchasesUnity";

RevenueCatUI/Plugins/Android/RevenueCatUI.androidlib/src/main/java/com/revenuecat/purchasesunity/ui/RevenueCatUI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
import android.app.Activity;
44
import android.util.Log;
55

6+
import androidx.annotation.Keep;
67
import androidx.annotation.Nullable;
78

89
import com.revenuecat.purchases.hybridcommon.ui.HybridPurchaseLogicBridge;
910

11+
@Keep
1012
public class RevenueCatUI {
13+
@Keep
1114
public interface PaywallCallbacks { void onPaywallResult(String result); }
1215

16+
@Keep
1317
public interface PurchaseLogicCallbacks {
1418
void onPerformPurchase(String requestId, String packageJson);
1519
void onPerformRestore(String requestId);
1620
}
1721

22+
@Keep
1823
public interface CustomerCenterCallbacks {
1924
void onCustomerCenterDismissed();
2025
void onCustomerCenterError();

0 commit comments

Comments
 (0)