尝试使用 jarsigner.exe 手动签署 android 包并使用 adb.exe 安装 [英] Trying to manually sign android package with jarsigner.exe and install with adb.exe

查看:21
本文介绍了尝试使用 jarsigner.exe 手动签署 android 包并使用 adb.exe 安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 jarsigner.exe 和 adb.exe 手动签署一个 android 包并将其安装在 API V8 模拟器上.我创建了一个简单的 HelloAndroid 项目,它将使用位于用户 .android 目录中的 debug.keystore 生成一个签名的 HelloAndroid.apk.从 Eclipse 启动时,它会在模拟器上构建并安装 apk,没有问题.

I've been trying to use the jarsigner.exe and adb.exe to manually sign an android package and install it on a API V8 emulator. I created a simple HelloAndroid project and it would generate a signed HelloAndroid.apk using the debug.keystore located in the user's .android directory. When launching from Eclipse, it builds and installs the apk on the emulator without a problem.

我使用 android 工具将未签名的应用程序包导出到单独的目录.我对包进行签名和 zipAligned 并使用 adb 安装它但收到错误:

I used the android tools to export an unsigned application package to a separate directory. I signed and zipAligned the package and used adb to install it but received the error:

Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

我使用以下命令对其进行签名.

I used the following command to sign it.

jarsigner -verbose -keystore c:\users\jhwong\.android\debug.keystore
     -storepass android -keypass android -digestalg SHA-1 -sigalg SHA1withRSA
     -sigfile CERT -signedjar temp\HelloWorld2.apk
      temp\HelloWorld.unsigned.apk androiddebugkey
   adding: META-INF/MANIFEST.MF
   adding: META-INF/CERT.SF
   adding: META-INF/CERT.RSA
  signing: res/layout/main.xml
  signing: AndroidManifest.xml
  signing: resources.arsc
  signing: res/drawable-hdpi/icon.png
  signing: res/drawable-ldpi/icon.png
  signing: res/drawable-mdpi/icon.png
  signing: classes.dex

这并没有给我任何错误,只是为了确保我跑了:

That did not give me any errors and just to makes sure I ran:

jarsigner -verify -verbose temp\HelloWorld2.apk

它显示 jar 已经过验证,每个文件都已签名,并且是清单的一部分.

It showed the jar was verified and each file signed and part of the manifest.

我运行了 zipalign -v 4 temp\HelloWorld2.apk temp\HelloWorld3.apk,结果没有出现错误.然后使用 adb install -r temp\HelloWorld3.apk.

I ran zipalign -v 4 temp\HelloWorld2.apk temp\HelloWorld3.apk which finished without an error. Then used adb install -r temp\HelloWorld3.apk.

我已经看到一些相关的主题和文章提出了这些方向,但我很困惑为什么它不能手动工作,就像使用 Eclipse 构建签名包一样.我什至使用了从 Eclipse 构建的包,并且能够使用 adb.exe 来安装它,所以我将它缩小到对包进行签名.我尝试过从 keytool 生成的密钥库,但它们效果不佳,这就是我尝试 debug.keystore 的原因.

I've seen several related threads and articles suggesting these directions but I'm perplexed as to why it doesn't work manually verses using Eclipse to build the signed package. I've even taken the package built from Eclipse and was able to use adb.exe to install it so I've narrowed it to signing the package. I've tried keystores that I've generated from the keytool but they didn't work as well which is why I tried the debug.keystore.

如果他们发现我的 jarsigner 代码有任何问题,我将不胜感激.

I'd appreciate any advice if they noticed anything wrong with my jarsigner code.

推荐答案

我们遇到了完全相同的问题.尝试使用以下参数值:

We had this exact same problem. Try using the following parameter values:

jarsigner ... -digestalg SHA1 -sigalg MD5withRSA ...

顺便说一下,JDK 7 似乎必须使用显式 sigalg 和digestalg.

By the way, using explicit sigalg and digestalg seems to be mandatory with JDK 7.

这篇关于尝试使用 jarsigner.exe 手动签署 android 包并使用 adb.exe 安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆