Android detached app Payments module on signed apk error:

#1

Error appears on loading js bundle.
TypeError: undefined is not an object (evaluating “h.init”)

Expo SDK 31
Detached
Android signed apk only, not on iOS.


Very similar to this, probably related : Issue with Stripe in detachhed expo - Android
Tried this with no success:
https://github.com/expo/expo/issues/2220

Removing this allows android to load app.

 Stripe.setOptionsAsync({
      publishableKey: stripe_public_key // Your key
      // androidPayMode: "test", // [optional] used to set wallet environment (AndroidPay)
      // merchantId: "your_merchant_id" // [optional] used for payments with ApplePay
    });

Edit: After more investigation found out simillar issues with no solutions


#2

Hey, @donlols!

Adding these two lines to proguard-rules.pro should fix this issue, have you tried it?

-keep class * extends expo.core.ExportedModule { *; }
-keep class * extends **.expo.core.ExportedModule { *; }
#3

Yeah I added those above Reacts

-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoMethod *;
}

### Payments
-keep class * extends expo.core.ExportedModule { *; }
-keep class * extends **.expo.core.ExportedModule { *; }

##### React Native #####
-keep,allowobfuscation @interface **.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface **.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface **.facebook.react.bridge.ReadableType

published beta and it didn’t work once you navigate to the setupOptionsAsync App crashes.

#4

How about adding

-keepclassmembers class * {
  @expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @expo.core.interfaces.ExpoMethod *;
}

-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoMethod *;
}

too?

Could you please post your whole proguard-rules.pro file somewhere so I could inspect it? :slightly_smiling_face:

2 Likes
#5

Sure Thanks

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ide/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}


# THIS IS VERY VERY BAD. REMOVE AS SOON AS VERSIONING IS FIXED
-dontwarn **


-dontnote **

-keep class host.exp.exponent.generated.AppConstants { *; }

##### Crashlytics #####
-keepattributes SourceFile,LineNumberTable

##### Expo Universal Modules #####

-keepclassmembers class * {
  @expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @expo.core.interfaces.ExpoMethod *;
}

-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoMethod *;
}

### Payments
-keep class * extends expo.core.ExportedModule { *; }
-keep class * extends **.expo.core.ExportedModule { *; }
-keepclassmembers class * {
  @expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @expo.core.interfaces.ExpoMethod *;
}

-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoProp *;
}
-keepclassmembers class * {
  @**.expo.core.interfaces.ExpoMethod *;
}
##### React Native #####
-keep,allowobfuscation @interface **.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface **.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface **.facebook.react.bridge.ReadableType

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @**.facebook.proguard.annotations.DoNotStrip class *
-keepclassmembers class * {
  @**.facebook.proguard.annotations.DoNotStrip *;
}

-keepclassmembers @**.facebook.proguard.annotations.KeepGettersAndSetters class * {
  void set*(***);
  *** get*();
}

-keep class * extends **.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends **.facebook.react.bridge.NativeModule { *; }
-keepclassmembers class *  { @**.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class *  { @**.facebook.react.uimanager.ReactProp <methods>; }
-keepclassmembers class *  { @**.facebook.react.uimanager.ReactPropGroup <methods>; }

# TODO: shouldn't need these two rules
-keep interface **.facebook.react.bridge.** { *; }
-keep enum **.facebook.react.bridge.** { *; }

##### Versioned React Native #####
-keep class **.facebook.** { *; }
-keep class abi** { *; }
-keep class versioned** { *; }

##### Butterknife #####
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

##### Stetho #####
-keep class **.facebook.stetho.** { *; }
-dontwarn **.facebook.stetho.**

##### fresco #####
# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface **.facebook.common.internal.DoNotStrip

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @**.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
    @**.facebook.common.internal.DoNotStrip *;
}

# Keep native methods
-keepclassmembers class * {
    native <methods>;
}

-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn com.android.volley.toolbox.**

##### okhttp #####
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
# This is also needed by Picasso
-dontwarn com.squareup.okhttp.**

-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
# This is also needed by Picasso
-dontwarn okhttp3.**

##### okio #####
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**

##### EventBus #####
-keepclassmembers class ** {
    public void onEvent*(***);
}

# Only required if you use AsyncExecutor
-keepclassmembers class * extends de.greenrobot.event.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}

##### Amplitude #####
-keep class com.amplitude.api.** {*;}

##### DBFlow #####
-keep class com.raizlabs.android.dbflow.config.GeneratedDatabaseHolder

##### SpongyCastle #####
-keep class org.spongycastle.**
-dontwarn org.spongycastle.jce.provider.X509LDAPCertStoreSpi
-dontwarn org.spongycastle.x509.util.LDAPStoreHelper

#6

Thanks This issue was resolved by adding @sjchmiela addition to proguard-rules.pro file.

1 Like
closed #7

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.