android - gradlew assembleRelease 和 gradlew assembleReleaseStaging 生成 APK 无需更改

标签 android react-native gradle

我正在尝试 bundle 我的 APK。当我使用 gradlew assembleReleaseassembleReleaseStaging我的应用程序没有变化。当我使用 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在组装它之前会创建很多新文件,如果我删除所有文件,除了 index.android.bundle并运行 gradlew assembleReleasegradlew assembleReleaseStaging一切正常。我的问题是 - 有没有办法组装发布 没有 手动 bundle ?我已经尝试过 gradlew clean 和 stackoverflow 上的其他方法。任何建议都将受到高度赞赏。

最佳答案

你需要钩react.gradle到您的模块的build.gradle .
转至 app/build.gradle并添加以下内容:

// Configures the bundleJS commands for React-Native
project.ext.react = [

    // whether to bundle JS and assets in debug mode
    bundleInDebug: false,
    // whether to bundle JS and assets in release mode
    bundleInRelease: true, 

    // the root of your RN project, i.e. where "package.json" lives
    root: "path_to_rn_project_directory"
]
apply from: "<path to RN project>/node_modules/react-native/react.gradle"
在此之后,assembleRelease也将开始 bundle 。

关于android - gradlew assembleRelease 和 gradlew assembleReleaseStaging 生成 APK 无需更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63738896/

相关文章:

reactjs - 虚拟化列表 : You have a large list that is slow to update

android - 用cordova构建android

ant - gradle build 中的 ant.junit 失败

android - eclipse 中的 "An existing connection was forcibly closed by the remote host"

android - 改造缓存数据以供离线使用

react-native - 使用 React Native Router Flux 将 Prop 传递到 TabIcon

javascript - react 原生 getElementById

android - Android SDK Canary 4中Gradle构建失败

java正则表达式获取字符串的某些部分

android - 单击后如何更改按钮的颜色?