Search code examples
androidreact-nativesdk

Problem integrating native android library in react native


I’m integrating a sdk called CI360 inside of a react native application and I’m facing some problems when I build an apk in release mode.

When I run the app locally or I build an apk in debug mode everything works fine, all sdk’s dependencies are included, but when I build an apk in release mode there are sdk’s dependencies that are not included, I’m not sure why, specifically a class called SASCollector that allows initialize the sdk.

Basically the SDK integration in android consists in add two files inside of the project. One of them is a file called SASCollector.jar inside of the path: android/app/libs and the other file is called SASCollector.properties that goes inside of the following path: android/app/src/main/assets:

Folder structure

After that you have to create a native module in order to call native java functions from javascript.

Below I’ll show you two screenshots of the content of my two apks.

Apk in debug mode:

Debug Apk

Apk in release mode:

Release Apk

As you can see in the release apk there are a lot of files and folders that are missed compared with the debug apk (the most important is SASCollector). I think that there is some configuration in the project that makes things go wrong when I build the release apk, I’m not sure.

My two build.gradle files are:

android/build.gradle:

buildscript {
apply from: "../node_modules/@dynatrace/react-native-plugin/files/plugin.gradle", to: buildscript
    ext {
        minSdkVersion = 21
        buildToolsVersion = "30.0.0"
        compileSdkVersion = 32
        targetSdkVersion = 31
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
    dependencies {
        classpath('com.android.tools.build:gradle:4.2.2')
        classpath 'com.google.gms:google-services:4.3.14'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url 'https://maven.google.com' }
        maven { url 'https://www.jitpack.io' }
        maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs"}
        google()
        jcenter()
    }
}
apply from: "../node_modules/@dynatrace/react-native-plugin/files/dynatrace.gradle"

android/app/build.gradle:

apply plugin: "com.android.application"

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
import com.android.build.OutputFile

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"


def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = true

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


def keysPropertiesFile = rootProject.file("keys.properties")
def keysProperties = new Properties()
keysProperties.load(new FileInputStream(keysPropertiesFile))

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
       javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "com.services.crunch.ar"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        multiDexEnabled true
        versionCode 412110699
        versionName "12.0.18"
        vectorDrawables.useSupportLibrary = true
        resValue "string", "build_config_package", "com.services.crunch.ar"
        setProperty("archivesBaseName", "MiCrunch-$versionName")
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if(keystorePropertiesFile.exists()){
                storeFile file(keystoreProperties['MYAPP_UPLOAD_STORE_FILE'])
                storePassword keystoreProperties['MYAPP_UPLOAD_STORE_PASSWORD']
                keyAlias keystoreProperties['MYAPP_UPLOAD_KEY_ALIAS']
                keyPassword keystoreProperties['MYAPP_UPLOAD_KEY_PASSWORD']
                enableV3Signing = true
                // v1SigningEnabled false
            }
        }
    }
    
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            debuggable true
            matchingFallbacks = ['debug', 'release']
        }
       
        release {
            debuggable false
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            shrinkResources enableProguardInReleaseBuilds
            zipAlignEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    
    }
    flavorDimensions "default"
    productFlavors {
        production {
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "false"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID'])        
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        f5 {
            applicationIdSuffix '.f5'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "false"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        certification {
            applicationIdSuffix '.certification'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"            
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY_CERT'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID_CERT'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "false"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID_CERT'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY_CERT'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID_CERT'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET_CERT'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID_CERT'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        hotfix {
            applicationIdSuffix '.hotfix'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY_CERT'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID_CERT'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "true"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID_CERT'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY_CERT'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID_CERT'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET_CERT'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID_CERT'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        bugfix {
            applicationIdSuffix '.bugfix'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY_CERT'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID_CERT'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "true"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID_CERT'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY_CERT'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID_CERT'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET_CERT'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID_CERT'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        integration {
            applicationIdSuffix '.integration'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY_CERT'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID_CERT'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "true"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID_CERT'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY_CERT'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID_CERT'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET_CERT'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID_CERT'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
        local {
            applicationIdSuffix '.local'
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.services.crunch.ar"
            buildConfigField("String", "SWRVE_API_KEY", keysProperties['SWRVE_API_KEY_CERT'])
            buildConfigField("int", "SWRVE_APP_ID", keysProperties['SWRVE_APP_ID_CERT'])
            buildConfigField "boolean", "IS_DEBUGGABLE", "false"
            buildConfigField("String", "FIREBASE_APP_ID", keysProperties['FIREBASE_APP_ID_CERT'])
            buildConfigField("String", "FIREBASE_API_KEY", keysProperties['FIREBASE_API_KEY_CERT'])
            buildConfigField("String", "FIREBASE_SENDER_ID", keysProperties['FIREBASE_SENDER_ID_CERT'])
            buildConfigField("String", "FIREBASE_STORAGE_BUCKET", keysProperties['FIREBASE_STORAGE_BUCKET_CERT'])
            buildConfigField("String", "FIREBASE_PROJECT_ID", keysProperties['FIREBASE_PROJECT_ID_CERT'])
            buildConfigField("String", "AES_SECRET_KEY", keysProperties['AES_SECRET_KEY'])
            buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", keysProperties['IS_NEW_ARCHITECTURE_ENABLED'])
        }
  }


    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {

    implementation 'com.swrve.sdk.android:swrve-firebase:10.8.0'
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    implementation("com.google.firebase:firebase-iid")
    
    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    
    implementation project(':react-native-splash-screen')

    implementation 'com.google.android.gms:play-services-tagmanager:17.0.0'

    implementation 'com.android.installreferrer:installreferrer:2.2'
    
    // Add the following if you are using the Adjust SDK inside web views on your app
    implementation 'com.adjust.sdk:adjust-android-webbridge:4.28.2'

    implementation 'com.android.volley:volley:1.2.1'

    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'

    // Libreria para IVR
    //implementation(name: 'DialMyAppLib-release', ext: 'aar')
    implementation files('libs/DialMyAppLib-release.aar')
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.10.6' 
    implementation 'org.apache.cordova:framework:8.1.0'
    implementation 'com.google.guava:guava:27.0.1-android' 
    implementation 'commons-io:commons-io:2.6'
    implementation 'com.google.android.gms:play-services-maps:17.0.0' 
    implementation 'com.google.android.gms:play-services-location:17.0.0' 
    implementation 'androidx.legacy:legacy-support-v4:1.0.0' 
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'androidx.work:work-runtime:2.5.0'
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
    implementation 'com.android.installreferrer:installreferrer:2.2'
    implementation 'com.google.android.gms:play-services-auth-api-phone:17.4.0'

    //CI360
    implementation files('libs/SASCollector.jar')
    implementation 'com.google.firebase:firebase-analytics:21.2.2'
    implementation 'com.google.firebase:firebase-core:21.1.1' 
    implementation 'com.google.firebase:firebase-messaging:23.1.2'
    implementation 'com.google.code.gson:gson:2.10.1'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

My package.json is:

{
    "name": "CrunchApp",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "run-android": "react-native run-android",
        "config-debug": "rm src/redux/store.ts && cat src/redux/store-debug.ts >> src/redux/store.ts",
        "config-release": "rm src/redux/store.ts && cat src/redux/store-release.ts >> src/redux/store.ts",
        "config-dynatrace": "cp android/dynatrace.gradle node_modules/@dynatrace/react-native-plugin/files",
        "android": "yarn config-debug && node scripts/set-environment.js integration && yarn run-android --variant=integrationDebug --appIdSuffix=integration",
        "android:cert": "yarn config-debug && node scripts/set-environment.js certification && yarn run-android --variant=certificationDebug --appIdSuffix=certification",
        "android:bugfix": "yarn config-debug && node scripts/set-environment.js bugfix && yarn run-android --variant=bugfixDebug --appIdSuffix=bugfix",
        "android:hotfix": "yarn config-debug && node scripts/set-environment.js hotfix && yarn run-android --variant=hotfixDebug --appIdSuffix=hotfix",
        "android:f5": "yarn config-debug && node scripts/set-environment.js f5 && yarn run-android --variant=f5Debug --appIdSuffix=f5",
        "android:prod": "yarn config-debug && node scripts/set-environment.js production && yarn run-android --variant=productionDebug",
        "android:local": "yarn config-debug && node scripts/set-environment.js local && yarn run-android --variant=localDebug --appIdSuffix=local",
        "pre-create-apk": "rm -rf node_modules && npm install && yarn config-dynatrace && yarn android:clean",
        "create-apk": "yarn config-release && node scripts/set-environment.js integration && cd android && ./gradlew assembleIntegrationRelease",
        "create-apk:cert": "yarn config-release && node scripts/set-environment.js certification && cd android && ./gradlew assembleCertificationRelease",
        "create-apk:bugfix": "yarn config-release && node scripts/set-environment.js bugfix && cd android && ./gradlew assembleBugfixRelease",
        "create-apk:hotfix": "yarn config-release && node scripts/set-environment.js hotfix && cd android && ./gradlew assembleHotfixRelease",
        "create-apk:f5": "yarn config-release && node scripts/set-environment.js f5 && cd android && ./gradlew assembleF5Release",
        "create-apk:prod": "yarn config-release && yarn pre-create-apk && node scripts/set-environment.js production && cd android && ./gradlew assembleProductionRelease",
        "create-apk:local": "yarn config-release && node scripts/set-environment.js local && cd android && ./gradlew assembleLocalRelease",
        "run-ios": "react-native run-ios",
        "ios": "yarn config-debug && node scripts/set-environment.js integration && yarn run-ios CrunchAppIntegration --configuration Integration.Debug",
        "ios:cert": "yarn config-debug && node scripts/set-environment.js certification && yarn run-ios CrunchAppCertification --configuration Beta.Debug",
        "ios:f5": "yarn config-debug && node scripts/set-environment.js f5 && yarn run-ios CrunchApp --configuration Production.Debug",
        "ios:prod": "yarn config-debug && node scripts/set-environment.js production && yarn run-ios CrunchApp --configuration Production.Debug",
        "ios:local": "yarn config-debug && node scripts/set-environment.js local && yarn run-ios CrunchAppIntegration --configuration Integration.Debug",
        "pre-create-ipa": "rm -rf node_modules && npm install",
        "create-ipa": "yarn config-release && node scripts/set-environment.js integration && npm install && cd ios && pod install && node ../scripts/instructions-build-ipa.js && open CrunchApp.xcworkspace && cd ..",
        "create-ipa:cert": "yarn config-release && node scripts/set-environment.js certification && npm install && cd ios && pod install && node ../scripts/instructions-build-ipa.js && open CrunchApp.xcworkspace && cd ..",
        "create-ipa:bugfix": "yarn config-release && node scripts/set-environment.js bugfix && npm install && cd ios && pod install && node ../scripts/instructions-build-ipa.js && open CrunchApp.xcworkspace && cd ..",
        "create-ipa:hotfix": "yarn config-release && node scripts/set-environment.js hotfix && npm install && cd ios && pod install && node ../scripts/instructions-build-ipa.js && open CrunchApp.xcworkspace && cd ..",
        "create-ipa:prod": "yarn config-release && yarn pre-create-ipa && node scripts/set-environment.js production && cd ios && pod install && node ../scripts/instructions-build-ipa.js && open CrunchApp.xcworkspace && cd ..",
        "start": "react-native start",
        "test": "jest --passWithNoTests --coverage",
        "lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
        "docs": "jsdoc -c jsdoc.config.json",
        "android:clean": "cd android && ./gradlew clean && cd ..",
        "clean:android": "cd android && ./gradlew cleanBuildCache && ./gradlew clean && cd ..",
        "clean:ios": "rm -rf ios/build",
        "clean": "run-p clean:*",
        "build:ios_": "react-native bundle --platform ios ...",
        "build:ios": "yarn env:dev && yarn build:ios_",
        "build:ios:cert": "yarn env:cert && yarn build:ios_",
        "build:ios:prod": "yarn env:prod && yarn _build:ios",
        "instrumentDynatrace": "node node_modules/@dynatrace/react-native-plugin/scripts/instrument.js"
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "*.{ts, tsx}": [
            "eslint --fix --max-warnings=10",
            "npm run test"
        ]
    },
    "dependencies": {
        "@dynatrace/react-native-plugin": "^2.243.0",
        "@notifee/react-native": "^4.1.0",
        "@react-native-community/async-storage": "^1.12.0",
        "@react-native-community/geolocation": "^2.0.2",
        "@react-native-community/masked-view": "^0.1.10",
        "@react-native-community/netinfo": "^6.2.1",
        "@react-native-community/react-native-cookies": "^1.1.1",
        "@react-native-firebase/analytics": "^7.6.7",
        "@react-native-firebase/app": "^8.4.5",
        "@react-native-firebase/messaging": "^7.8.9",
        "@react-native-firebase/remote-config": "^9.0.10",
        "@react-navigation/bottom-tabs": "^5.9.0",
        "@react-navigation/material-bottom-tabs": "^5.2.17",
        "@react-navigation/material-top-tabs": "^5.2.17",
        "@react-navigation/native": "^5.7.4",
        "@react-navigation/stack": "^5.9.1",
        "@shopify/restyle": "^1.3.0",
        "@types/clone": "^2.1.1",
        "@types/react-redux": "^7.1.9",
        "axios": "^0.20.0",
        "better-docs": "^2.3.2",
        "clone": "^2.1.2",
        "compare-versions": "^3.6.0",
        "husky": "^4.3.8",
        "identity-obj-proxy": "^3.0.0",
        "lint-staged": "^10.5.3",
        "moment": "^2.29.1",
        "react": "17.0.1",
        "react-dom": "^17.0.2",
        "react-native": "0.64.4",
        "react-native-adjust": "^4.29.6",
        "react-native-android-open-settings": "^1.3.0",
        "react-native-base64": "^0.2.1",
        "react-native-bootsplash": "^2.2.7",
        "react-native-cache": "^2.0.2",
        "react-native-contacts": "^7.0.4",
        "react-native-crypto-js": "^1.0.0",
        "react-native-device-info": "^8.1.4",
        "react-native-dialog": "^9.2.0",
        "react-native-elements": "^2.3.2",
        "react-native-exit-app": "^1.1.0",
        "react-native-fast-image": "^8.3.2",
        "react-native-geolocation-service": "^5.3.0-beta.4",
        "react-native-gesture-bottom-sheet": "^1.0.9",
        "react-native-gesture-handler": "^1.8.0",
        "react-native-image-crop-picker": "^0.35.0",
        "react-native-image-helper": "0.0.3",
        "react-native-navigation-bar-color": "^2.0.1",
        "react-native-offline": "^5.8.0",
        "react-native-reanimated": "^1.13.1",
        "react-native-redash": "^15.4.0",
        "react-native-safe-area-context": "^3.1.8",
        "react-native-screens": "^2.11.0",
        "react-native-share": "^7.6.2",
        "react-native-size-matters": "^0.4.0",
        "react-native-splash-screen": "^3.2.0",
        "react-native-store-review": "0.2.1",
        "react-native-svg": "^12.4.1",
        "react-native-swrve-plugin": "^4.0.0",
        "react-native-system-setting": "^1.7.6",
        "react-native-tab-view": "^2.15.1",
        "react-native-vector-icons": "^7.1.0",
        "react-native-webview": "^11.4.3",
        "react-redux": "^7.2.1",
        "redux": "^4.0.5",
        "redux-saga": "^1.1.3",
        "rn-fetch-blob": "^0.12.0",
        "rn-open-especifics-settings": "^2.3.2"
    },
    "devDependencies": {
        "@babel/core": "^7.8.4",
        "@babel/runtime": "^7.8.4",
        "@react-native-community/eslint-config": "^1.1.0",
        "@redux-saga/types": "^1.1.0",
        "@testing-library/react-native": "^7.1.0",
        "@types/enzyme": "3.10.7",
        "@types/enzyme-adapter-react-16": "1.0.6",
        "@types/jest": "^25.2.3",
        "@types/react": "^18.0.20",
        "@types/react-dom": "^18.0.6",
        "@types/react-native": "^0.63.64",
        "@types/react-test-renderer": "^16.9.2",
        "@typescript-eslint/eslint-plugin": "^2.27.0",
        "@typescript-eslint/parser": "^2.27.0",
        "babel-jest": "^25.1.0",
        "enzyme": "^3.11.0",
        "enzyme-adapter-react-16": "^1.15.6",
        "enzyme-to-json": "^3.6.1",
        "eslint": "^6.5.1",
        "jest": "^25.1.0",
        "jest-environment-enzyme": "^7.1.2",
        "jest-enzyme": "^7.1.2",
        "jsdoc": "^3.6.6",
        "metro-react-native-babel-preset": "^0.59.0",
        "react-native-svg-transformer": "^1.0.0",
        "react-test-renderer": "16.13.1",
        "reactotron-react-native": "^5.0.0",
        "reactotron-redux": "^3.1.3",
        "reactotron-redux-saga": "^4.2.3",
        "redux-devtools-extension": "^2.13.8",
        "typescript": "^3.8.3"
    },
    "resolutions": {
        "@types/react": "17.0.2",
        "@types/react-dom": "17.0.2"
    },
    "jest": {
        "preset": "react-native",
        "moduleFileExtensions": [
            "ts",
            "tsx",
            "js",
            "jsx",
            "json",
            "node"
        ]
    }
}

In the app I also have another native library called DialMyApp, and the configuration is so similar to SASCollector, and I have no problem with DialMyApp when I build a release apk, all of its files are included without problem. I hope you can help me with this issue.

Thank you in advance.

I tried to change the folder of the sdk in diferent places an it seems not change this behavior. I also changed the gradle version and it didn't work, maybe I'm doing it in a incorrect way.


Solution

  • I did some test with my project and I finally solved the problem.

    This behavior happens because sometimes when the android compiler creates a release apk, it makes some optimizations in order to reduce the apk’s size, deleting unused code and renaming classes and methods.

    You can avoid this default behavior of the compiler setting up a rule in the proguard-rules.pro file in the path android/app with the files we want to keep in our apk.

    In my case the rule is:

    -keep class com.sas.mkt.mobile.sdk.** { *; }
    

    And that’s all! Everything works as I expected.