【问题标题】:Ionic android build generate unsigned apk, but donot install in my android 8.1.0Ionic android build 生成未签名的 apk,但不要安装在我的 android 8.1.0 中
【发布时间】:2019-08-22 06:58:02
【问题描述】:

当我提供 ionic 应用程序时,它可以在浏览器中运行,但用于 android 的构建 apk 无法正常工作。 apk 无法安装。

我尝试了 ionic cordova build android --release

带有以下消息的构建过程

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\ruban\AppData\Local\Android\Sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preReleaseBuild UP-TO-DATE
> Task :CordovaLib:checkReleaseManifest UP-TO-DATE
> Task :CordovaLib:processReleaseManifest UP-TO-DATE
> Task :app:preReleaseBuild UP-TO-DATE`
D:\myApp\platforms\android\app\src\main\res\drawable-land-hdpi\screen.png: Error: The drawable "screen" in drawable-land-hdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-land-ldpi\screen.png: Error: The drawable "screen" in drawable-land-ldpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-land-mdpi\screen.png: Error: The drawable "screen" in drawable-land-mdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-land-xhdpi\screen.png: Error: The drawable "screen" in drawable-land-xhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-land-xxhdpi\screen.png: Error: The drawable "screen" in drawable-land-xxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-land-xxxhdpi\screen.png: Error: The drawable "screen" in drawable-land-xxxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-hdpi\screen.png: Error: The drawable "screen" in drawable-port-hdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-ldpi\screen.png: Error: The drawable "screen" in drawable-port-ldpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-mdpi\screen.png: Error: The drawable "screen" in drawable-port-mdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-xhdpi\screen.png: Error: The drawable "screen" in drawable-port-xhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-xxhdpi\screen.png: Error: The drawable "screen" in drawable-port-xxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]
D:\myApp\platforms\android\app\src\main\res\drawable-port-xxxhdpi\screen.png: Error: The drawable "screen" in drawable-port-xxxhdpi has no declaration in the base drawable folder or in a drawable-densitydpi folder; this can lead to crashes when the drawable is queried in a configuration that does not match this qualifier [MissingDefaultResource]

构建会创建未签名的 apk 文件,该文件不会安装在我的 Android 设备上。

Ionic info 命令显示以下消息 离子:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\ruban\AppData\Roaming\nvm\v10.15.3\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.1.2
   @angular-devkit/build-angular : 0.13.7
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.7
   @ionic/angular-toolkit        : 1.4.1

科尔多瓦:

   cordova (Cordova CLI) : 9.0.0
   Cordova Platforms     : android 8.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 4 other plugins)

系统:

   Android SDK Tools : 26.1.1 (C:\Users\ruban\AppData\Local\Android\Sdk)
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

【问题讨论】:

  • 你试过没有 --release 标志
  • 没有--release没有报错,但是apk还是无法安装
  • 每当我尝试安装它时,它都会显示“未安装应用程序”
  • 你能告诉我参数是什么--release for
  • IT 工作构建没有 --release 工作,但你能告诉我 --release 的重要性

标签: cordova ionic-framework


【解决方案1】:

我认为您尚未生成 resources。尝试以下方法:

ionic cordova resources

【讨论】:

  • apk 无法安装,但它在 webview 上运行,当我执行 ionic 服务时
  • 尝试在设备上运行,看看是什么错误。
  • 离子科尔多瓦运行 android
  • 在做 ionic cordova 时运行 android BUILD SUCCESSFUL in 8s 42 actionable tasks: 42 up-to-date Built the following apk(s): D:\myApp\platforms\android\app\build\outputs\apk\debug\app-debug.apk Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=C:\Users\ruban\AppData\Local\Android\Sdk (DEPRECATED) No target specified and no devices found, deploying to emulator Using apk: D:\myApp\platforms\android\app\build\outputs\apk\debug\app-debug.apk Package name: io.ionic.starter INSTALL SUCCESS LAUNCH SUCCESS
  • 好的,那就没问题了。你正在做的是你正在尝试安装一个未签名的发布 apk,它不被接受。
【解决方案2】:

你需要把ANDROID_HOME放到你的PATH

设置 ANDROID_HOME=C:\Users\adt-bundle-windows-x86-20140321\sdk\tools

设置 PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

【讨论】:

  • 我必须设置set ANDROID_HOME=C:\Users\adt-bundle-windows-x86-20140321\sdk\tools or set ANDROID_HOME=C:\Users\adt-bundle-windows-x86-20140321\sdk
【解决方案3】:

在android中简单运行应用程序:

1) 连接设备并确保启用 USB 调试(在设置 - 开发者选项中)

2) 在 cmd 中输入:adb devices

3) 现在运行:ionic cordova run android

(Ionic cli 将完成所有操作并安装在您的设备中。)

【讨论】:

    【解决方案4】:

    您无需修复任何问题,因为这不是错误。 但如果你想修复它...

    如果您不喜欢此提醒, 您应该将下一行添加到 config.xml 文件中

    <splash density="ldpi" src="resources/android/splash/drawable-ldpi-screen.png" />
    <splash density="mdpi" src="resources/android/splash/drawable-mdpi-screen.png" />
    <splash density="hdpi" src="resources/android/splash/drawable-hdpi-screen.png" />
    <splash density="xhdpi" src="resources/android/splash/drawable-xhdpi-screen.png" />
    <splash density="xxhdpi" src="resources/android/splash/drawable-xxhdpi-screen.png" />
    <splash density="xxxhdpi" src="resources/android/splash/drawable-xxxhdpi-screen.png" />
    

    资源可以是drawable-xxxhdpi-screen ...或者你可以使用端口或土地。

    使用下一行,您应该能够生成签名密钥

    keytool -genkey -v -keystore ejemlo.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

    下一行您将能够签署您的应用程序

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ejemlo.keystore app-release-unsigned.apk alias_name

    这样您就可以对 apk 进行签名,然后您就可以在 Android 中安装该应用了。

    这对我有用。

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 1970-01-01
      • 2015-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-29
      相关资源
      最近更新 更多