urbanairship / react-native-airship

Airship React Native module
Other
87 stars 62 forks source link

Proguard enabled - "Unsupported Attribute Type: undefined" #351

Closed jameslevine closed 2 years ago

jameslevine commented 3 years ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

"urbanairship-react-native": "11.0.2",

What are the versions of any relevant development tools you are using?


  "dependencies": {
    "@invertase/react-native-apple-authentication": "2.1.2",
    "@react-hook/debounce": "4.0.0",
    "@react-native-async-storage/async-storage": "1.15.5",
    "@react-native-community/blur": "3.6.0",
    "@react-native-community/masked-view": "0.1.11",
    "@react-native-community/netinfo": "6.0.0",
    "@react-native-firebase/analytics": "12.1.0",
    "@react-native-firebase/app": "12.1.0",
    "@react-native-firebase/crashlytics": "12.1.0",
    "@react-native-google-signin/google-signin": "6.0.1",
    "@react-navigation/bottom-tabs": "^6.0.0-next.18",
    "@react-navigation/native": "^6.0.0-next.13",
    "@react-navigation/stack": "^6.0.0-next.25",
    "@reduxjs/toolkit": "1.6.0",
    "@sentry/react-native": "2.6.0",
    "@types/react-native-snap-carousel": "3.8.4",
    "axios": "0.21.1",
    "lottie-ios": "3.1.8",
    "lottie-react-native": "4.0.2",
    "query-string": "7.0.1",
    "react": "17.0.2",
    "react-native": "0.64.2",
    "react-native-circular-progress": "1.3.7",
    "react-native-config": "1.4.2",
    "react-native-device-info": "8.1.3",
    "react-native-fast-image": "8.3.5",
    "react-native-fbsdk": "3.0.0",
    "react-native-flipper": "^0.103.0",
    "react-native-gesture-handler": "1.10.3",
    "react-native-linear-gradient": "2.5.6",
    "react-native-modalize": "2.0.8",
    "react-native-reanimated": "2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "3.4.0",
    "react-native-snap-carousel": "3.9.1",
    "react-native-svg": "12.1.1",
    "react-native-toast-message": "1.4.9",
    "react-native-webview": "11.6.5",
    "react-redux": "7.2.4",
    "redux-flipper": "^2.0.0",
    "redux-logger": "3.0.6",
    "redux-persist": "6.0.0",
    "urbanairship-react-native": "11.0.2",
    "use-debounce": "7.0.0"
  },
  "devDependencies": {
    "@babel/core": "7.14.6",
    "@babel/runtime": "7.14.6",
    "@react-native-community/eslint-config": "3.0.0",
    "@testing-library/react-native": "7.2.0",
    "@types/jest": "26.0.24",
    "@types/react": "17.0.14",
    "@types/react-native": "0.64.11",
    "@types/react-native-fbsdk": "3.0.1",
    "@types/react-redux": "7.1.16",
    "@types/react-test-renderer": "17.0.1",
    "@types/redux-logger": "3.0.9",
    "@typescript-eslint/eslint-plugin": "4.28.2",
    "@typescript-eslint/parser": "4.28.2",
    "axios-mock-adapter": "1.19.0",
    "babel-jest": "27.0.6",
    "babel-loader": "8.2.2",
    "babel-plugin-module-resolver": "4.1.0",
    "eslint": "7.30.0",
    "eslint-config-prettier": "8.3.0",
    "husky": "7.0.1",
    "jest": "26.6.3",
    "lint-staged": "11.0.0",
    "metro-react-native-babel-preset": "0.66.1",
    "prettier": "2.3.2",
    "react-dom": "17.0.2",
    "react-test-renderer": "17.0.2",
    "typescript": "4.3.5"
  },
  "resolutions": {
    "@types/react": "17.0.14"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "setupFiles": [
      "<rootDir>/jest-setup.js"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|@react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
    ],
    "timers": "fake"
  },
  "lint-staged": {
    "*.{ts,tsx}": [
      "bash -c tsc --noEmit",
      "eslint"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "yarn test"
    }
  }

Report

What unexpected behavior are you seeing?

I am getting an error when I set up Proguard. Screen Shot 2021-09-01 at 11 36 38 AM

My proguard-rules.pro file looks like this:

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/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:

# Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces).
-dontobfuscate
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose
-dontpreverify
-allowaccessmodification
-mergeinterfacesaggressively
-overloadaggressively
-keepattributes Signature,Exceptions,*Annotation*,
                InnerClasses,PermittedSubclasses,EnclosingMethod,
                Deprecated,SourceFile,LineNumberTable

# React Native

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

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

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

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

-keep class * implements com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * implements com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }

-dontwarn com.facebook.react.**
-keep,includedescriptorclasses class com.facebook.react.bridge.** { *; }
-keep,includedescriptorclasses class com.facebook.react.turbomodule.core.** { *; }

# hermes
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.hermes.unicode.** { *; }

# UrbanAirship

-keep public class com.urbanairship.unityplugin.UnityPlugin
-keepclassmembers class com.urbanairship.unityplugin.UnityPlugin {
  public <methods>;
  public <fields>;
  static <methods>;
}

## Airship extender
-keep public class com.urbanairship.reactnative.AirshipExtender
-keep public class * extends com.urbanairship.reactnative.AirshipExtender

# okio

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

# Others
-keep public class com.horcrux.svg.** {*;}
-keep class com.example.appname.R$raw { *; }
-dontwarn com.quantcast.**
-keep class com.quantcast.** { *; }
-dontwarn com.google.android.gms.location.LocationCallback
-keep class com.google.android.gms.location.LocationCallback { *; }
-keep class com.google.android.apps.** { *; }
-keep class org.apache.http.**
-keep interface org.apache.http.**
-dontwarn org.apache.**
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-keep class com.facebook.react.devsupport.** { *; }
-dontwarn com.facebook.react.devsupport.**
-dontwarn com.facebook.stetho.dumpapp.DumperPlugin

If I comment out this useEffect here which sets up Airship, the app runs perfectly:

  useEffect(() => {
    UrbanAirship.addListener(EventType.Register, (event) => {
      console.log("Channel registration updated: ", event.channelId);
      console.log("Registration token: ", event.registrationToken);
    });

    UrbanAirship.addListener(EventType.Registration, (event) => {
      console.log("Channel registration updated: ", event.channelId);
      console.log("Registration token: ", event.registrationToken);
    });

    UrbanAirship.addListener(EventType.PushReceived, (notification) => {
      console.log("Received push: ", JSON.stringify(notification));
    });
    UrbanAirship.editChannelAttributes().setAttribute("app_env", APP_ENV.ENV).apply();
    UrbanAirship.setUserNotificationsEnabled(true);
    dispatch(AppActions.User.checkLogin());
  }, [dispatch]);

If you have any light to shed on why this might be happening, it would be much appreciated.

What is the expected behavior?

Expected behaviour should be no error and app loads as expected

What are the steps to reproduce the unexpected behavior?

I am building the app in release mode

Do you have logging for the issue?

 ERROR  Unsupported attribute type: undefined

This error is located at:
    in LandingScreen (at SceneView.tsx:118)
    in StaticContainer
    in EnsureSingleNavigator (at SceneView.tsx:110)
    in SceneView (at useDescriptors.tsx:198)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:279)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:278)
    in RCTView (at View.js:34)
    in View (at CardSheet.tsx:33)
    in CardSheet (at Card.tsx:557)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at Card.tsx:536)
    in PanGestureHandler (at GestureHandlerNative.tsx:14)
    in PanGestureHandler (at Card.tsx:530)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at Card.tsx:526)
    in RCTView (at View.js:34)
    in View (at Card.tsx:520)
    in Card (at CardContainer.tsx:218)
    in CardContainer (at CardStack.tsx:610)
    in RNSScreen (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at src/index.native.tsx:147)
    in Screen (at Screens.tsx:37)
    in MaybeScreen (at CardStack.tsx:603)
    in RNSScreenContainer (at src/index.native.tsx:186)
    in ScreenContainer (at Screens.tsx:20)
    in MaybeScreenContainer (at CardStack.tsx:515)
    in RCTView (at View.js:34)
    in View (at Background.tsx:13)
    in Background (at CardStack.tsx:513)
    in CardStack (at StackView.tsx:434)
    in SafeAreaProviderCompat (at StackView.tsx:429)
    in RCTView (at View.js:34)
    in View (at GestureHandlerRootView.android.tsx:21)
    in GestureHandlerRootView (at StackView.tsx:428)
    in StackView (at createStackNavigator.tsx:108)
    in Unknown (at createStackNavigator.tsx:107)
    in StackNavigator (at RootNavigation.tsx:134)
    in AppNavigation (at SceneView.tsx:118)
    in StaticContainer
    in EnsureSingleNavigator (at SceneView.tsx:110)
    in SceneView (at useDescriptors.tsx:198)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:279)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:278)
    in RCTView (at View.js:34)
    in View (at CardSheet.tsx:33)
    in CardSheet (at Card.tsx:557)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at Card.tsx:536)
    in PanGestureHandler (at GestureHandlerNative.tsx:14)
    in PanGestureHandler (at Card.tsx:530)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at Card.tsx:526)
    in RCTView (at View.js:34)
    in View (at Card.tsx:520)
    in Card (at CardContainer.tsx:218)
    in CardContainer (at CardStack.tsx:610)
    in RNSScreen (at createAnimatedComponent.js:217)
    in AnimatedComponent (at createAnimatedComponent.js:278)
    in AnimatedComponentWrapper (at src/index.native.tsx:147)
    in Screen (at Screens.tsx:37)
    in MaybeScreen (at CardStack.tsx:603)
    in RNSScreenContainer (at src/index.native.tsx:186)
    in ScreenContainer (at Screens.tsx:20)
    in MaybeScreenContainer (at CardStack.tsx:515)
    in RCTView (at View.js:34)
    in View (at Background.tsx:13)
    in Background (at CardStack.tsx:513)
    in CardStack (at StackView.tsx:434)
    in SafeAreaProviderCompat (at StackView.tsx:429)
    in GestureHandlerRootView (at GestureHandlerRootView.android.tsx:26)
    in GestureHandlerRootView (at StackView.tsx:428)
    in StackView (at createStackNavigator.tsx:108)
    in Unknown (at createStackNavigator.tsx:107)
    in StackNavigator (at RootNavigation.tsx:108)
    in EnsureSingleNavigator (at BaseNavigationContainer.tsx:429)
    in BaseNavigationContainer (at NavigationContainer.tsx:132)
    in ThemeProvider (at NavigationContainer.tsx:131)
    in NavigationContainerInner (at RootNavigation.tsx:76)
    in RootNavigation (at App.tsx:37)
    in RNCSafeAreaProvider (at SafeAreaContext.tsx:76)
    in SafeAreaProvider (at App.tsx:35)
    in PersistGate (at App.tsx:34)
    in Provider (at App.tsx:33)
    in App (at renderApplication.js:47)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:107)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:134)
    in AppContainer (at renderApplication.js:40), js engine: hermes
 ERROR  Unsupported attribute type: undefined, js engine: hermes
marc-scig commented 3 years ago

@jameslevine one problem I can see off the bat is that your proguard rules are referencing com.urbanairship.unityplugin.UnityPlugin.

rlepinski commented 3 years ago

Probably want to add:

-keep class com.urbanairship.reactnative.** { *; }

But it should already be working with your other keeps. Try it and let us know.

rlepinski commented 2 years ago

Any update on this? Closing for now.