Skip to content

window.__DEV__ is false on debug build on RN version 0.75.4  #823

@sahad00

Description

@sahad00

Introduction

Earlier I used to detect the env based like this

let isProduction = window.__DEV__ ? false : true;

problem is that isProduction is true on debug build I have generated

build command used

"build:android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",

Details

app/build.gradle

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

//Firebase plugins
apply plugin: "com.google.gms.google-services"
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

//React Native Vector Icons
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")

//Sentry AutoGenerated
apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")

import groovy.json.JsonSlurper

react {
   
    /* Autolinking */
    autolinkLibrariesWithApp()
}

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

def enableSeparateBuildPerCPUArchitecture = true

if(System.env.BUILD_TYPE=='aab') {
  enableSeparateBuildPerCPUArchitecture = false
}


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

def getVersionFromPackage() {
    //  Read and parse package.json file from project root
    def inputFile = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)

    // Return the version, you can get any value this way
    return packageJson["version"]
}

def getVersionCodeFromPackage() {
    def inputFile = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)
    return packageJson["androidVersionCode"]
}

android {
    ndkVersion rootProject.ext.ndkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace "com.swific.registerbook"
    defaultConfig {
        applicationId "com.swific.registerbook"
        // applicationId "com.swific.registerbook.internal"
        // applicationId "booleanlabs.reactjs.natv.logbook.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        missingDimensionStrategy 'react-native-camera','general'
        versionCode getVersionCodeFromPackage()
        versionName getVersionFromPackage()
        multiDexEnabled true
        buildConfigField "String", "SENTRY_RELEASE", "\"${System.env.SENTRY_RELEASE}\""
        buildConfigField "String", "SENTRY_DIST", "\"${System.env.SENTRY_DIST}\""
        //FOR NOTIFEE ERROR
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.7.0' }
            resolutionStrategy { force 'androidx.sqlite:sqlite-framework:2.1.0' }
        }
    }

    splits {
        abi {
            enable enableSeparateBuildPerCPUArchitecture
            reset()
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildFeatures {
        viewBinding true
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled false 
            shrinkResources false 
            applicationIdSuffix ".debug"
            debuggable true
            resValue("string", "google_apiKey", "${System.env.MAPS_API_KEY}")
            manifestPlaceholders = [
                    appIcon: "@mipmap/ic_launcher_debug",
                    appIconRound: "@mipmap/ic_launcher_debug_round"
            ]
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            minifyEnabled enableProguardInReleaseBuilds
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            resValue 'string', 'facebook_app_id', '"411177813230527"'
            resValue("string", "CodePushDeploymentKey", "${System.env.CODE_PUSH_DEPLOYMENT_KEY}")
            resValue("string", "fcm_sender_id", "${System.env.FCM_SENDER_ID}")
            resValue("string", "branch_key", "${System.env.BRANCH_KEY}")
            resValue("string", "branch_app_link", "${System.env.BRANCH_APP_LINK}")
            resValue("string", "branch_app_link_alternate", "${System.env.BRANCH_APP_LINK_ALTERNATE}")
            resValue("string", "branch_test_mode", "${System.env.BRANCH_TEST_MODE}")
            resValue("string", "google_apiKey", "${System.env.MAPS_API_KEY}")
            manifestPlaceholders = [
                    appIcon: "@mipmap/ic_launcher",
                    appIconRound: "@mipmap/ic_launcher_round"
            ]
        }
        releaseStaging {
            initWith release
            applicationIdSuffix ".staging"
            // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
            // Add the following line if not already there
            matchingFallbacks = ['release']
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }

    //used in API 34 Android upgrade
    implementation 'org.jetbrains:annotations:16.0.2'  

    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-firestore'
    implementation "com.google.firebase:firebase-analytics"
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-storage'
    implementation 'com.google.firebase:firebase-functions'


    //MultiDex
    implementation 'com.android.support:multidex:2.0.1'
    
    //Carrier Info
    implementation project(':react-native-carrier-info')

    //Fresco Animations
    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.0.0'


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

    // implementation 'com.google.android.exoplayer:exoplayer' //Optional for Audio/Video
    // implementation 'com.google.android.exoplayer:exoplayer-hls' //Optional for Audio/Video
    // implementation 'com.google.android.exoplayer:exoplayer-ui' //Optional for Audio/Video
    implementation 'com.github.bumptech.glide:glide:4.11.0' //Mandatory for App Inbox
    implementation 'androidx.recyclerview:recyclerview:1.1.0' //Mandatory for App Inbox,
    implementation 'androidx.viewpager:viewpager:1.0.0' //Mandatory for App Inbox
    implementation 'com.google.android.material:material:1.2.1' //Mandatory for App Inbox
    implementation 'androidx.appcompat:appcompat:1.2.0' //Mandatory for App Inbox
    implementation 'androidx.core:core:1.3.0'
    implementation 'androidx.fragment:fragment:1.1.0' // InApp
    //Mandatory for React Native SDK v0.3.9 and above add the following -
    implementation 'com.android.installreferrer:installreferrer:2.2'
    implementation 'com.google.android.gms:play-services-appset:16.0.0'
    implementation 'com.airbnb.android:lottie:3.7.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    //Shorcut-Widget-Dependencies-Below
    // implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    // implementation 'com.google.code.gson:gson:2.8.8'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
    // implementation 'com.squareup.okhttp3:okhttp:3.6.0'
    //Shorcut-Widget-Dependencies-Above

    // addUnimodulesDependencies()

    implementation project(':react-native-fs')
    implementation(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }  
    implementation 'com.google.android.gms:play-services-base:10.0.1'
    implementation 'com.google.android.gms:play-services-maps:10.0.1'
    implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }
}

I am unable to figure out the issue please help

gradle.properties

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx4g
#  -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
 
# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
 
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

MYAPP_UPLOAD_STORE_FILE=india-excel-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=india-excel
MYAPP_UPLOAD_STORE_PASSWORD=Indi@excel!sep()
MYAPP_UPLOAD_KEY_PASSWORD=Indi@excel!sep()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions