【问题标题】:React Native build doesn't embed bundle fileReact Native 构建不嵌入捆绑文件
【发布时间】:2016-06-06 16:39:26
【问题描述】:

我正在使用com.android.library 插件开发一个android 库(打包为.aar)。我已经使用https://facebook.github.io/react-native/docs/embedded-app-android.html 中提供的说明对我的活动做出了本机反应。

但是,当我在我的项目中运行 gradlew.bat build 时,生成的包 ./build/outputs/arr/{projectname-(debug/release)}.aar 不包含捆绑包 index.android.bundle 因此 react native 无法找到它。

是否需要执行任何其他步骤才能使用 gradle 生成和打包捆绑包?

谢谢

【问题讨论】:

  • 你能创建 aar 文件并在原生项目中使用吗?

标签: android gradle react-native aar


【解决方案1】:

您需要在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",
]

【讨论】:

    猜你喜欢
    • 2017-08-14
    • 2017-12-06
    • 2021-05-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    • 2021-09-16
    • 2017-04-22
    • 1970-01-01
    相关资源
    最近更新 更多