当前位置:   article > 正文

Android APK系统签名_altserver could not be found

altserver could not be found

一.签名文件的获取

1. platform.pk8 和 platform.x509.pem
这两个文件在源码根目录的build/target/product/security/下

lzb@king:~/rk3288_7.1_mid$ cd build/target/product/security/
lzb@king:~/rk3288_7.1_mid/build/target/product/security$ ls
Android.mk  media.pk8       platform.pem  platform.x509.pem  shared.pem  shared.x509.pem  testkey.pk8       verity_key  verity.x509.pem
media.pem   media.x509.pem  platform.pk8  README             shared.pk8  testkey.pem      testkey.x509.pem  verity.pk8

  • 1
  • 2
  • 3
  • 4
  • 5

2. signapk.jar
这个文件在out/host/linux-x86/framework/下

lzb@king:~/rk3288_7.1_mid$ cd out/host/linux-x86/framework/
lzb@king:~/rk3288_7.1_mid/out/host/linux-x86/framework$ ls
ahat.jar                     cts-java-scanner.jar    dexdeps.jar   hierarchyviewer.jar          jsilver.jar                  org-openide-util.jar
antlr-runtime.jar            cts-native-scanner.jar  doclava.jar   hosttestlib.jar              json-prebuilt.jar            rmtypedefs.jar
bouncycastle-host.jar        cts-tradefed.jar        dumpkey.jar   jarjar-apache-ant.jar        junit.jar                    signapk.jar
compatibility-host-util.jar  cts-xml-generator.jar   dx.jar        jarjar.jar                   munge-host.jar               tradefed-prebuilt.jar
cts-java-scanner-doclet.jar  ddmlib-prebuilt.jar     guavalib.jar  jarjar-maven-plugin-api.jar  org-netbeans-api-visual.jar
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

二.给APK签名

3. 签名证书platform.pk8 和 platform.x509.pem ,签名工具signapk.jar 还有需要签名的APK放置在同一个文件夹并执行下面这条命令

lzb@king:~/rk3288_7.1_mid/certificate$ java -jar signapk.jar platform.x509.pem platform.pk8  old.apk new.apk
  • 1

4. 生成的 new.apk 就是我们签名后的文件了,剩下的就是将Android签名后的APP安装在安卓手机上

ps:

在我执行完这条命令以后报错了 报错信息如下

java -jar signapk.jar platform.x509.pem platform.pk8  old.apk new.apk
  • 1
 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/signapk/SignApk : Unsupported major.minor version 51.0
        	      at java.lang.ClassLoader.defineClass1(Native Method)
     		      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
      		      at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
      		      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      		      at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
       		      at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
     	          at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      		      at java.security.AccessController.doPrivileged(Native Method)
      		      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     		      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     		      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       		      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
		      Could not find the main class: com.android.signapk.SignApk. Program will exit.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

原因:jdk版本太低 笔者的sdk版本是Android 7.1,,jdk版本是jdk6,Android5.1以上的版本需要jdk7以上的版本 ,可通过下面这条命令查看当前jdk版本

echo $PATH
  • 1

解决办法: 笔者jdk路径为 /usr/lib/jvm/java-7-openjdk-amd64,所以 只需要使用如下命令手动添加 JDK7 的路径进 PATH 即可

export PATH= /usr/lib/jvm/java-7-openjdk-amd64
  • 1

设置完JDK路径之后,再重新执行下面命令

java -jar signapk.jar platform.x509.pem platform.pk8  old.apk new.apk
  • 1

三. 大功告成!

第一次写博客 写的不好多见谅!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/321780
推荐阅读
相关标签
  

闽ICP备14008679号