An error occurred while signing the APK in jdk1.7.

Source: Internet
Author: User
Tags sha1

1.In the past two days, I tried to create an ant APK. When I signed the APK, I found that the signature was successful, but I was prompted that there was no digital certificate during installation.
My colleague's machine can be installed normally after signing, but it cannot be installed on my machine. Finally, I found that my colleague's JDK version 1.6 is 1.7.

Finally, I checked the information on the Internet to solve the problem. When signing, I added two parameters after the jarsigner command:

-Digestalg sha1
-Sigalg md5withrsa

Use ant as follows:

<target name="jarsigner" depends="package" >    <exec executable="${jarsigner}" failonerror="true" >        <arg value="-verbose" />        <arg value="-digestalg" />        <arg value="SHA1" />        <arg value="-sigalg" />        <arg value="MD5withRSA" />        <arg value="-keystore" />        <arg value="${key.store}" />        <arg value="-storepass" />        <arg value="${key.store.password}" />        <arg value="-keypass" />        <arg value="${key.alias.password}" />        <arg value="-signedjar" />        <arg value="${out-signed-package-ospath}" />        <arg value="${out-unsigned-package-ospath}" />        <arg value="${key.alias}" />    </exec></target>

2.After packaging, we found that after manually compiling the class, after hitting the DEX file, we will find that there are fewer class files in this Dex, which is hard to understand,

Eclipse automatically compiled packages are normal. Why can't I execute my own compile? No exception was found during multi-party comparison.

My colleagues printed the log and noticed that there were many "bad class file magic (cafebabe) or version (0033.0000)" prompts in the log. Later on the Internet

This problem is also encountered by colleagues. It is caused by the JDK version. After JDK 1.7 is compiled, it will appear. If you encounter this problem, you can change to JDK 1.6.


3.Note:

I used ant to play APK. After hitting it, it will be due to notfoundclassexception during runtime. After tracking, I found that the package path cannot be directly written as a folder. As follows:

Change <Arg value = "$ {outdir-classes-ospath}"/> to <Arg value = "$ {outdir-classes-ospath }/*"
/>. Otherwise, the class file may not be actually typed into the DEX package.

<! -- Set. class file. dex file --> <target name = "Dex" depends = "proguard"> <echo> converting compiled files and external libraries into. dex file... </echo> <exec executable = "$ {DX}" failonerror = "true"> <Arg value = "-- Dex"/> <Arg value = "-- verbose"/> <! -- Output file --> <Arg value = "-- output =$ {Dex-ospath}"/> <! -- Source classes and libraries of the. Dex file to be generated --> <Arg value = "$ {outdir-classes-ospath}/*"/> <! -- Note: $ {outdir-classes-ospath} ", the notfoundclassexception will be thrown during runtime, the class under the suspected directory cannot enter DEX --> <Arg value = "$ {external-Lib-ospath}"/> </exec> </Target>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.