1

I exported an apk by ADT in eclipse, and I attempted to install this apk into a avd, but it raised "Application not installed".

I checked the logcat, and found this:

W/PackageParser(59): java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for res/drawable-mdpi/ic_launcher.png in /data/app/vmdl25264.tmp
E/PackageParser(59): Package com.ep.android has no certificates at entry res/drawable-mdpi/ic_launcher.png; ignoring!

In the file "META-INF/MANIFEST.MF" of the apk, I found this:

Name: res/drawable-mdpi/ic_launcher.png
SHA1-Digest: 4ss2KZ3FzkmfE6HAAsVu0aJKx1U=

So I tried to use my own Java Programming generate a SHA1-Digest for the png file, and the result is "sjmKOs4BYDXg7COdeTc8tIfPBR0=" which is totally different. My Java code for generate a SHA1-Digest is:

public static void main(String[] filename) throws NoSuchAlgorithmException,
        Exception {

    MessageDigest md = MessageDigest.getInstance("SHA1");
    FileInputStream in =  new FileInputStream("./ic_launcher.png");
    int bytes = 0;
    while ((bytes = in.read()) != -1) {
        md.update((byte)bytes);
    }

    in.close();
    byte[] thedigest = md.digest();
    System.out.println(Base64Encoder.encode(thedigest));
}

It seems both the avd and my code consider that the SHA1-Digest in MANIFEST.MF of apk is invalid. So, I guess the SHA1-Digest generator in ADT did something wrong here. Is it a bug? Or I missed something?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
hardPass
  • 19,033
  • 19
  • 40
  • 42
  • check whether application is already installed on emulator or not – Akram May 17 '12 at 05:30
  • No, it is not. The problem is about the SHA1-Digest in MANIFEST.MF generated by ADT, I guess it has a bug. Both the avd and my code consider the digest is invalid. – hardPass May 17 '12 at 06:01
  • The digest generated by my own Java Programming is `sjmKOs4BYDXg7COdeTc8tIfPBR0=`. It doesn't equal `4ss2KZ3FzkmfE6HAAsVu0aJKx1U=` which is in the MANIFEST.MF file of the apk generated by ADT. – hardPass May 17 '12 at 06:04
  • And I found this exception in logcat:`java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for res/drawable-mdpi/ic_launcher.png`. – hardPass May 17 '12 at 06:06
  • And not all the digest in the MANIFEST.MF is wrong. I have tested the other png files and got the same digests as ones in the MANIFEST.MF. Like :`Name: res/drawable-mdpi/ic_tab_news_s.png SHA1-Digest: ikGDamqvj1SvxM4deMMO7u0YN0Y=` Name: res/drawable-mdpi/ic_tab_profile.png SHA1-Digest: bJJ1aomZ9WpFnBIkogwxVriOPQs= – hardPass May 17 '12 at 06:10
  • Only the "ic_launcher.png" file's digest is invalid. How to upload a file to here? I want to show this png file, so you guys can test it. – hardPass May 17 '12 at 06:15
  • Ok, the png is here :[ic_launcher.png](http://212137.gov.cn/apk/ic_launcher.png).You can build a simple android project including this png file in the res/drawable-mdpi/ directory. And exported the apk by ADT. When you install it in an AVD or a real phone, it will turn up the problem. – hardPass May 17 '12 at 06:34
  • tested your file working fine with me – Akram May 17 '12 at 09:03
  • Really? Could you please show me your apk? I wanna check the differeces from mine. Or you could show me the SHA1-Digest in `MANIFEST.MF`. – hardPass May 17 '12 at 09:38
  • My email: hardPass@126.com, many thanks! – hardPass May 17 '12 at 09:47
  • Akki: your apk doesn't work in my machine : Application not installed! `05-18 01:54:50.095: W/PackageParser(59): Exception reading res/drawable-mdpi/ic_launcher.png in /data/app/vmdl55069.tmp 05-18 01:54:50.095: W/PackageParser(59): java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for res/drawable-mdpi/ic_launcher.png in /data/app/vmdl55069.tmp 05-18 01:54:50.095: E/PackageParser(59): Package com.Afdaf has no certificates at entry res/drawable-mdpi/ic_launcher.png; ignoring!` – hardPass May 18 '12 at 02:15
  • Akki: I also checked MANIFEST.MF in your apk, and found the SHA1-Digest was `4ss2KZ3FzkmfE6HAAsVu0aJKx1U=`. My avd version is android 2.2. You said it works with you. I wonder how , I wonder why. And the apk is here :[apk_by_Akki.apk](http://212137.gov.cn/apk/Test.apk). Could anybody else test it for me ? – hardPass May 18 '12 at 02:22

0 Answers0