简体   繁体   English

如何将 React(非本机)应用程序部署到 Android?

[英]How do you deploy React (non-Native) app to Android?

I've created a React app that looks great on mobile, but rather than a user just visiting my website URL I also want them to be able to install it as an apk through the playstore.我创建了一个在移动设备上看起来很棒的 React 应用程序,但不是用户只是访问我的网站 URL 我还希望他们能够通过 playstore 将其安装为 apk。

Is there any trivial way to port it to Android, that would allow me to continue to develop just one version of the app?有没有什么简单的方法可以将它移植到 Android,这样我就可以继续开发应用程序的一个版本? I looked into porting it to react-native, but much of it would need to be recoded.我考虑将其移植到 react-native,但其中大部分需要重新编码。 I also considered just opening the app URL in a browser popup, but I'm wondering if there's a better way.我还考虑在浏览器弹出窗口中打开应用程序 URL,但我想知道是否有更好的方法。

Thanks -谢谢 -

Edit: Based on Michael's comment, I'm trying out turning my app into PWA compliant , then using Capacitor to deploy on Android & iOS.编辑:根据迈克尔的评论,我正在尝试将我的应用程序变成PWA 兼容,然后使用电容器在 Android 和 iOS 上部署。 I'll see how this goes and write my own answer if this works out (and no one else answers =o)如果可行,我会看看情况如何并写下我自己的答案(并且没有其他人回答=o)

Forgot about this question.忘记了这个问题。 As the OP in 2021, I resolved this by using Capacitor - A Javascript library that converts your app to Android and iOS builds.作为 2021 年的 OP,我通过使用Capacitor解决了这个问题 - 一个 Javascript 库,可将您的应用程序转换为 Android 和 iOS 构建。

Install Capacitor: npm install @capacitor/core @capacitor/cli安装电容: npm install @capacitor/core @capacitor/cli

Initialize it: npx cap init初始化它: npx cap init

Add Android and (optionally) iOS support: npx cap add android npx cap add ios添加 Android 和(可选)iOS 支持: npx cap add android上限添加 android npx npx cap add ios

Create an Android app: npx cap sync创建 Android 应用程序:npx npx cap sync

Open Android Studio with your new app (to build a.APK): npx cap open android使用您的新应用打开 Android Studio(构建 a.APK): npx cap open android

Optional: Open Xcode to build an iOS app: npx cap open ios可选:打开 Xcode 以构建 iOS 应用程序: npx cap open ios


Source: https://capacitorjs.com/docs/getting-started资料来源: https://capacitorjs.com/docs/getting-started

Bracket, I followed the necessary steps to my ReactJs application, the Android folder came and I ran it on smart TV with Android Studio.支架,我按照必要的步骤操作到我的 ReactJs 应用程序,Android 文件夹来了,我用 Android Studio 在智能电视上运行它。 But only a white screen comes up.但只有一个白屏出现。 I can't access my app.我无法访问我的应用程序。 Do you have any ideas on the subject?你对这个问题有什么想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM