事情起因:
我在学习 react native,打 android 的 debug 包出来装上发现必须要连一个 metro 服务,就想着让 deepseek 给我看看
Deepseek R1 绕圈圈:
结果这个 deepseek R1 倒好,给我好一顿绕,先是告诉我在 app/build.gradle 里这么写
project.ext.react = [
bundleInDebug: true, // 自动在 Debug 构建时生成 Bundle
devDisabledInDebug: false
]
一绕
然后我觉得还是发给他 app/build.gradle 文件让他看看先,然后他 话锋一转 告诉我应该这么写
react {
// 添加以下配置
bundleInDebug = true // Debug 模式下生成 JS Bundle
devDisabledInDebug = true // 关闭开发模式(禁用红屏警告、开发者菜单)
}
一运行,报错了,这个属性不存在。。。
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not set unknown property 'bundleInDebug' for extension 'react' of type com.facebook.react.ReactExtension.
二绕
发错误信息给 deepseek R1,它来一个 话锋回转 告诉我该回去
project.ext.react = [
bundleInDebug: true, // Debug 模式下生成 JS Bundle
devDisabledInDebug: true // 关闭开发模式
]
一运行,报错了,告诉我这是老式配置方式应该用新的。。。
ERROR: Using old project.ext.react configuration.
We identified that your project is using a old configuration block as:
project.ext.react = [
// ...
]
You should migrate to the new configuration:
react {
// ...
}
三绕
再发给 deepseek R1,它 话锋再转 告诉我这么写。。。
react {
// 核心配置
entryFile = file("../index.js") // 入口文件路径
bundleInDebug.set(true) // Debug 模式下生成 JS Bundle
devDisabledInDebug.set(true) // 关闭开发模式功能
enableHermes.set(true) // 启用 Hermes 引擎(如果已配置)
我也不懂啊,反正我就是个抄
再运行,果然报错了,属性就不存在嘛,再变调用方式也不会让它变出来嘛。。。
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not set unknown property 'bundleInDebug' for extension 'react' of type com.facebook.react.ReactExtension.
亖绕
继续把错误信息发给它,我就是个 辅助 AI 编程
然后来了个新的写法,涨了点记性,不在用那个不存在的属性了哦
react {
// 新版本配置方式(替代 bundleInDebug/devDisabledInDebug)
bundleConfig."debug" { // 针对 Debug 构建类型的配置
bundle = true // 强制生成 JS Bundle
dev = false // 关闭开发模式(等效于 devDisabledInDebug)
}
// 可选:其他构建类型配置(如 release)
bundleConfig."release" {
bundle = true
dev = false
}
拿去运行一下,又又又又报错了
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method bundleConfig() for arguments [build_8fik7m2gxw2dvzjbowzgjtn2a$_run_closure1$_closure4@2ecd0462] on extension 'react' of type com.facebook.react.ReactExtension.
正绕
再把错误信息给他,来了个这。。。
我寻思虽然我是 辅助 AI 编程 ,但我也不傻啊,这不一样的么。。。
react {
// 基础配置
entryFile = file("../index.js")
hermesCommand = "../../node_modules/hermes-engine/%OS-BIN%/hermesc"
codegenDir = file("../../node_modules/@react-native/codegen")
// 构建类型配置
bundleConfig {
"debug" {
bundle = true // 生成 JS Bundle
dev = false // 关闭开发模式
minify = false // 不启用代码压缩(Debug 模式通常不需要)
}
"release" {
bundle = true
dev = false
minify = true // 启用代码压缩(Release 模式推荐)
}
}
直接告诉他换一种,他就给我来了个,我寻思这应该也不对吧?怎么都不区分 debug 和 release 了?
react {
// JS Bundle 控制
jsBundle = "index" // 必须明确指定 Bundle 名称
bundle = true // 全局强制生成 JS Bundle
dev = false // 关闭开发模式(等效 devDisabledInDebug)
}
回绕
不过我还是 辅助 AI 编程 贯彻执行,拿去运行一下,果然报错!
然后告诉 deepseek R1,让它解决
这回倒好,绕回去了
project.ext.react = [
// JS Bundle 控制
bundleInDebug: true, // Debug 模式强制生成 Bundle
bundleInRelease: true, // Release 模式强制生成 Bundle
devDisabledInDebug: true, // 关闭开发模式
]
绕你个头绕 
阿 西 吧,我辅助 AI 编程,你 AI 绕我玩是吧
我笨办法搞了再说
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/