teamdigitale/italia-app

View on GitHub
android/app/build.gradle

Summary

Maintainability
Test Coverage
project.ext.envConfigFiles = [
  debug: ".env",
  release: ".env.production"
]

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */

// usage: ./gradlew assembleDebug -PbundleInDebug=true
def bundleInDebugPropertyName = "bundleInDebug"
def bundleDebug = false
if (project.hasProperty(bundleInDebugPropertyName)) {
    println bundleInDebugPropertyName + ': ' + bundleInDebug
    bundleDebug = project.getProperty(bundleInDebugPropertyName)
}
 
 react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")
 
    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]
 
    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []
 
    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
android {
    ndkVersion rootProject.ext.ndkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion
    
    namespace "it.pagopa.io.app"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libjsc.so'
        pickFirst 'lib/arm64-v8a/libjsc.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "it.pagopa.io.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 100154859
        versionName "2.73.0.3"
        multiDexEnabled true
        // The resConfigs attribute will remove all not required localized resources while building the application,
        // including the localized resources from libraries.

    }
    signingConfigs {
        release {
            if (System.getenv('IO_APP_RELEASE_STORE_FILE')) {
                storeFile file(System.getenv('IO_APP_RELEASE_STORE_FILE'))
                storePassword System.getenv('IO_APP_RELEASE_STORE_PASSWORD')
                keyAlias System.getenv('IO_APP_RELEASE_KEY_ALIAS')
                keyPassword System.getenv('IO_APP_RELEASE_KEY_PASSWORD')
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            // The shrinkResources attribute will remove all the resources that are not used in the project
            shrinkResources enableProguardInReleaseBuilds
            // proguard-android-optimize.txt includes the same ProGuard (proguard-android.txt) rules,
            // but with other optimizations that perform analysis at the bytecode level—inside and
            // across methods to reduce the APK size further and help it run faster.
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

    // The Android App Bundle read this section to create different bundles
    bundle {
        language {
            // Disable split by language
            enableSplit = false
        }

        density {
            // Disable split by density
            enableSplit = false
        }

        abi {
            // Enable split by abi
            enableSplit = true
        }
    }
}

dependencies {
    implementation project(':jail-monkey')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-share')
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
 
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")

    implementation project(':react-native-cie')

    implementation ("com.squareup.okhttp3:okhttp:4.9.2")
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.2'

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
    
    implementation project(':react-native-fingerprint-scanner')
    implementation project(':react-native-art')
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.41"
    implementation('com.google.firebase:firebase-iid:21.1.0') {
        because "Firebase messaging 22.0.0 removes Firebase Instance ID API but out current version of the mixpanel sdk requires it https://github.com/mixpanel/mixpanel-android/issues/744 https://firebase.google.com/support/release-notes/android#messaging_v22-0-0"
    }
    implementation "androidx.constraintlayout:constraintlayout:2.1.4"
    // Specifing this avoid :app:checkDebugDuplicateClasses failure
    implementation "com.google.guava:guava:27.0.1-android"
}

// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)