我正在开发一个 android 库(打包为 .aar),使用 com.android.library
插件。我已使用 https://facebook.github.io/react-native/docs/embedded-app-android.html 中提供的说明对我的 Activity 做出 native react 。 .
但是,当我在我的项目中运行 gradlew.bat build
时,生成的包 ./build/outputs/arr/{projectname-(debug/release)}.aar
不包含包 index.android.bundle
因此 react native 找不到它。
我是否需要执行任何其他步骤来使用 gradle 生成和打包 bundle ?
谢谢
最佳答案
您需要在 app/build.gradle
中覆盖 jsBundleDir
,因为 android 库项目的 assets
目录是 $ {buildDir}/intermediates/bundles/${targetPath}/assets
而不是 ${buildDir}/intermediates/assets/${targetPath}
例如,在您的app/build.gradle
中,添加以下行
project.ext.react = [
jsBundleDirDebug: "$buildDir/intermediates/bundles/debug/assets",
jsBundleDirRelease: "$buildDir/intermediates/bundles/release/assets",
]
关于android - React Native 构建不嵌入包文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37662681/