简体   繁体   English

Ionic 应用程序未安装在 Android 设备中

[英]Ionic App not installing in android device

I am a newbie in Ionic.我是 Ionic 的新手。 I just made a simple app in Ionic that ran well on browser.我刚刚在 Ionic 中做了一个简单的应用程序,在浏览器上运行良好。 So, I converted it into an .apk file using Android studios that generated an android-release-unsigned.apk file.因此,我使用生成 android-release-unsigned.apk 文件的 Android 工作室将其转换为 .apk 文件。 I transfered it to my device and on trying to install it I encountered that it was not being installed.我将它转移到我的设备上,并在尝试安装它时遇到它没有被安装。 I am not able to figure out the cause.我无法弄清楚原因。 Need some assistance.需要一些帮助。

You can follow the steps which are mentioned in the official doc below.您可以按照下面官方文档中提到的步骤进行操作。

Deploying to a Device 部署到设备

But for me, it didn't work.So I just manually did that as shown below.但对我来说,它没有用。所以我只是手动做了,如下所示。

  1. ionic cordova run android --device

  2. Plugged device to the PC using USB使用 USB 将设备插入 PC

  3. Copy the android-debug.apk file to the device (apk path:.. \\platforms\\android\\build\\outputs\\apk)复制android-debug.apk文件到设备(apk路径:..\\platforms\\android\\build\\outputs\\apk)

  4. After that, You have to enable below setting on your Android device之后,您必须在 Android 设备上启用以下设置

settings --> general tab --> security --> unknown sources (enabled this)设置 --> 常规选项卡 --> 安全 --> 未知来源(启用此)

  1. After that just double-clicked the android-debug.apk from the location which you have copied.Then your app will be installed on your device.That is it.You can use your app on real device now.之后只需从您android-debug.apk的位置双击android-debug.apk 。然后您的应用程序将安装在您的设备上。就是这样。您现在可以在真实设备上使用您的应用程序。

The most probable reason I can think of is that your application is not signed.我能想到的最可能的原因是你的申请没有签名。 As Sampath mentioned try to build a debug version and not release version of your application and then install it on your device.正如 Sampath 提到的,尝试构建调试版本而不是发布应用程序的版本,然后将其安装在您的设备上。 You can can use 'ionic run android' and copy/paste manually the output android-debug.apk file to your device.您可以使用“ionic run android”并将输出的 android-debug.apk 文件手动复制/粘贴到您的设备。

In the config.xml, in the 2nd line, there is a tag called widget.在 config.xml 的第 2 行,有一个名为 widget 的标签。 You have to give a unique id for that.您必须为此提供一个唯一的 ID。 If there is another ionic app installed with same widget id, your device will not allow you to install another app with the same id.如果安装了另一个具有相同小部件 ID 的 ionic 应用程序,您的设备将不允许您安装另一个具有相同 ID 的应用程序。

在此处输入图片说明

Try building a signed apk. 尝试构建签名的apk。

First of all build a release apk using this. 首先,使用此构建一个发布apk。

ionic cordova build android --prod --release

Then run these commands in a command prompt. 然后在命令提示符下运行这些命令。 (Navigate to the folder where your apk is located) (导航至您的APK所在的文件夹)

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias

then, 然后,

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks your_apk_name.apk my-alias
  1. $ adb devices $ adb 设备
  2. native-run android --app platform/your-app-debug-link.apk --device本机运行的 android --app 平台/your-app-debug-link.apk --device

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

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