android - React Native 构建不嵌入包文件

标签 android gradle react-native aar

我正在开发一个 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/

相关文章:

android - FFmpeg提取图像二进制命令的命令是什么

android - Adobe AIR 3 native 扩展 - Android res 文件夹未包含在 .ane 文件中

android - 我应该如何验证电子邮件地址?

ssl - 用gradle分析ssl报错(-Djavax.net.debug=ssl好像不尊重)

java - 进行 whatsapp 视频通话

android - 添加 “cloud_firestore”时出现Flutter错误

android - Gradle 3.0 构建错误 : Execution failed for task ':app:transformClassesWithDesugarForDebug'

javascript - 如何从 ref 获取 ref key 然后按该键搜索并从该 ref 获取数据

react-native - ReactNative textcontenttype iOS 13 问题

javascript - Grid 内的列在 react-native-base 中占一半宽度