如何在android上使用离线捆绑?
我没有在androID上看到关于使用offline bundle的文档.
我试图取消注释build.gradle中的代码.
project.ext.react = [ // the name of the generated asset file containing your Js bundle bundleAssetname: "index.androID.bundle", // the entry file for bundle generation entryfile: "index.androID.Js", // whether to bundle Js and assets in deBUG mode bundleInDeBUG: false, // whether to bundle Js and assets in release mode bundleInRelease: true, // the root of your project, i.e. where "package.Json" lives root: "../../", // where to put the Js bundle asset in deBUG mode JsBundleDirDeBUG: "$buildDir/intermediates/assets/deBUG", // where to put the Js bundle asset in release mode JsBundleDirRelease: "$buildDir/intermediates/assets/release", // where to put drawable resources / React Native assets, e.g. the ones you use via // require('./image.png')), in deBUG mode resourcesDirDeBUG: "$buildDir/intermediates/res/merged/deBUG", // where to put drawable resources / React Native assets, e.g. the ones you use via // require('./image.png')), in release mode resourcesDirRelease: "$buildDir/intermediates/res/merged/release", // by default the gradle tasks are skipped if none of the Js files or assets change; this means // that we don't look at files in androID/ or ios/ to determine whether the tasks are up to // date; if you have any other folders that you want to ignore for performance reasons (gradle // indexes the entire tree), add them here. Alternatively, if you have Js files in androID/ // for example, you might want to remove it from here. inputExcludes: ["androID/**", "ios/**"]]
但它没有用.它仍然从服务器获取Js包.
我错过了什么吗?
解决方法:
要将Js脱机捆绑到androID中,首先在各自的项目路径中启动服务器:
>当服务器启动时,打开与项目路径相同路径的下一个终端
>复制并粘贴此命令:
在命令propmt中复制和粘贴命令之前,请在项目各自的路径中创建assets文件夹
如:
AndroID设备/应用/ src目录/主/资产
在命令提示符下粘贴此命令并运行:
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/
>然后在assets文件夹中将出现文件index.androID.bundle
>最后,运行命令:react-native run-androID(同时构建新的离线apk,你不需要启动服务器,你的离线Js文件将帮助你构建apk文件.)
>最后,apk现在构建已准备好在不同的设备上运行(从app / src / build / deBUG.apk运行apk).
>有时新制作的apk将在没有显示图像的情况下运行,如果应用程序运行时没有图像,则将特定图像资源文件夹复制并粘贴到androID / app / src / main / assets /(图像源文件夹)
>再次重新运行应用程序,因此构建apk已准备好运行.
以上是内存溢出为你收集整理的如何在android上使用离线包来反应原生项目?全部内容,希望文章能够帮你解决如何在android上使用离线包来反应原生项目?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)