我需要将 Entry 文件路径更改为 src/XXXApp.android.js 而不是指向默认的 index.android.js 文件。我想将 JS 文件保存在单独的 ./src 文件夹中。
所以我在 ./android/app/build.gradle 中做了更改,比如
project.ext.react = [
bundleAssetName: "src/XXXApp.android.bundle",
entryFile: file("../../src/XXXApp.android.js"),
root: "../../../../",
inputExcludes: ["android/**", "./**"]
]
并且在.\node_modules\react-native\react.gradle 文件中
def bundleAssetName = config.bundleAssetName ?:"src/XXXApp.android.bundle"
def entryFile = config.entryFile ?: "src/XXXApp.android.js"
但是开发包服务器总是指向 localhost:8081/index.android/bundle. 。我手动尝试了 URL:localhost:8081/src/XXXApp.android.bundle 并检索了数据。 但是在设备调试 loadJs 总是尝试 localhost:8081/index.android/bundle.
请分享解决方案,适当的地方更新android的入口文件配置。提前感谢您提供宝贵的解决方案。
最佳答案
在您的 MainActivity 中,您可以覆盖 ReactActivity 的 getJSBundleFile() 方法。在这里您可以指定您的包文件名和路径。代码推送使用相同的方法覆盖 reactjs 包路径。
关于android - 将 native : Change the Entry file path index. android.js react 到指定的自定义文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39291982/