React Native android build gradle debuggable false 不会关闭 __DEV__

发布于 2025-01-20 16:46:12 字数 704 浏览 0 评论 0原文

嗨,我找不到任何答案解决方案,

我在\ android \ app \ build.gradle

我尝试过put 可辩论的false

> __ dev __ to false。

每个人都在说debug变体和发行版本,但是没有人告诉什么特定的切换到将__ dev __更改为false。

请帮助谢谢。

buildTypes {

        alpha {
            signingConfig signingConfigs.dev

            debuggable false 
            
            ...
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

            matchingFallbacks = ['release', 'debug']
        }
    }

另外,我尝试从MatchingFallbacks删除“调试” 也无法正常工作。


            matchingFallbacks = ['release']

Hi I cannot found any answer solution for this

I have follwoing custom variant in \android\app\build.gradle

I have tried put debuggable false

But this does not changed __DEV__ to false.

Everyone is telling debug variant and release variant but nobody is telling how exactly a specific toggle to change __DEV__ to false.

Please help thanks.

buildTypes {

        alpha {
            signingConfig signingConfigs.dev

            debuggable false 
            
            ...
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

            matchingFallbacks = ['release', 'debug']
        }
    }

also I have tried removed 'debug' from matchingFallbacks not working as well.


            matchingFallbacks = ['release']

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

油焖大侠 2025-01-27 16:46:12

如果我没有误解,那么您在看错。如下所述。

您可以在JavaScript中使用 dev 全局变量来确定您是否使用React Native Packager。如果您要在iOS模拟器或Android Emulator dev 中运行应用程序。

REECT Native Dev and prod变量

只要您在模拟器上运行应用程序的应用程序, __ dev __变量是正确的。

您可以尝试在使用的模拟器中运行-Configuration Release

If im not mistaking you are looking at it wrong. As the link below mentions.

You can use the DEV global variable in JavaScript to determine if you're using React Native packager or not. If you are running your app in the iOS Simulator or Android emulator DEV will be set to true.

React Native DEV and PROD variables

As long as your running the app on emulators the __DEV__ variable will be true.

You can try to run in a simulator with --configuration Release

只是在用心讲痛 2025-01-27 16:46:12

我也遇到这个问题,就我而言,buildType名称应包含“ repares”关键字。 (不要问我为什么)

alpha更改为alpharelease,一切都很好。

示例:(

我正在使用RN 0.68.2)

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            debuggable true
            applicationIdSuffix ".dev"
        }
        alphaRelease {
            initWith release
            matchingFallbacks = ['release']

            signingConfig signingConfigs.hmg
            debuggable false
            applicationIdSuffix ".hmg"
        }
        release {
            /* Add the firebaseCrashlytics extension (by default, it's disabled to improve build speeds) and set
            * nativeSymbolUploadEnabled to true along with a pointer to native libs. */
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
            }

            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            debuggable false
            applicationIdSuffix ""
        }
    }

I'm experiencing this problem too, in my case the buildType name should contain "release" keyword. (don't ask me why)

Change alpha to alphaRelease and everything should works fine.

Example:

(I'm using RN 0.68.2)

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            debuggable true
            applicationIdSuffix ".dev"
        }
        alphaRelease {
            initWith release
            matchingFallbacks = ['release']

            signingConfig signingConfigs.hmg
            debuggable false
            applicationIdSuffix ".hmg"
        }
        release {
            /* Add the firebaseCrashlytics extension (by default, it's disabled to improve build speeds) and set
            * nativeSymbolUploadEnabled to true along with a pointer to native libs. */
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
            }

            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            debuggable false
            applicationIdSuffix ""
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文