Obfuscate an EXPO file

4.5k Views Asked by At

First time I use Expo (react native app) to deploy an app into Googgle play store. Expo Generates an aab -file that I can upload to the store. But it seems like it is not obfuscated. Reading through the Expo documents I don't get my head around how to define this in my build process.

If I understand documentation correctly it is in my eas.json file I should define this, or have I misunderstood?

But I don't know how the code should look like. Any suggestions for how?

2

There are 2 best solutions below

3
On BEST ANSWER

Follow this steps

  1. Make sure expo-build-properties is installed, or install it if needed: expo install expo-build-properties
  2. In your app.json / app.config.js change this dependency:
"plugins": [
      "expo-build-properties"
    ]

to

"plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "enableProguardInReleaseBuilds": true
          }
        }
      ]
    ]

After these steps, it should be obfuscated. Source: https://docs.expo.dev/versions/latest/sdk/build-properties/#example-appjson-with-config-plugin

0
On

I found my android app crashed with the recommended change. I eventually found Github issue https://github.com/expo/expo/issues/15761 Paste in the 'plugins' section of app.json as follows:

"plugins": [
  [
    "expo-build-properties",
    {
      "android": {
        "enableProguardInReleaseBuilds": true,
        "extraProguardRules": "-keep public class com.horcrux.svg.** {*;}",
        "allowBackup": false
      }
    }
  ]
],