0

I use my old phone (Redmi 6 running Android 9, MIUI 11, armv7 architecture) for teaching myself mobile programming and my new phone (Redmi 10C running Android 13, MIUI 14, aarch64 architecture) as my daily. I don't like putting my daily use phone into developer mode, and in fact Xiaomi makes it very painful to do so.

I heard that you can copy APKs from device to device so tried sharing an app I'm coding myself from my dev phone to my main phone, using Bluetooth.

When I try to install the APK I get the error App not installed as package appears to be invalid:

The actual error message

Now I know APK files are ZIP archives so I checked it is a ZIP archive and it doesn't look like the file was truncated or corrupted in any way.

I went further and copied it back to my dev phone and it did install there without complaint so that to means it's not "invalid" in the usual sense.

Is this just a misleading error? Is this the standard error message that covers every APK installation problem and not just whether the APK is valid? Does it mean my two phones have different CPU architectures? Does it mean the APK is not signed? Is it some other kind of security issue? Is there a way to get more detailed information about why it failed to install?

I tried installing f-droid from an APK and that went smoothly, so it's not all APKs.

I looked into my APKs and none of them have a lib directory and hence no architecture-specific native code. So that rules out armv7 vs aarch64 being the problem.

My APKs have no CERT.SF files in them, which I think means that are not signed. This is my best guess.

hippietrail
  • 357
  • 1
  • 6
  • 21
  • adb install or logcat should tell more information about why it failed. – Andrew T. Aug 01 '23 at 07:23
  • @AndrewT. I don't know enough yet but I'm assuming that would involve using the new phone in developer mode probably connected to my laptop? – hippietrail Aug 01 '23 at 07:25
  • 1
    I just tried logcat using a terminal emulator Termux on Android 12, and it seems it only outputs logs related to the Termux process, so... yeah, I'm afraid you need to do this from a PC, or I did something wrong. Maybe wait for other inputs... – Andrew T. Aug 01 '23 at 07:40
  • I don't like putting my daily use phone into developer mode. Since Android 4.4 there is no negative impact enabling development mode as only PCs you have accepted on the phone can use it. Furthermore if your screen breaks, development mode and adb can be your life saver as you can use the phone without working screen. – Robert Aug 01 '23 at 13:32
  • @Robert: I seem to recall it being something specific to Xiaomi phones last time I tried it a few years ago, like rendering the notification bar in an ugly way in developer mode then resetting lots of settings when I turned developer mode off. – hippietrail Aug 01 '23 at 14:49
  • It's worse than I remembered. To enable Install via USB you need a Xiaomi account and you also need a SIM card. This is probably some PRC government requirement. – hippietrail Aug 02 '23 at 06:43
  • 1
    I'm still wondering if this is caused by Android 14 blocking old apps, but I don't know how you built the app (though I'm not sure either why you wanted to target the app before Android 6.0) or whether the error reflects this behavior. – Andrew T. Aug 03 '23 at 14:35
  • I think I just kept settings at standard with the latest Android Studio but did specify it had to work on Android 9 and up to be compatible with my old phone. But I did just notice I made a mistake. My new phone is actually on Android 13 and MIUI 14 since an update in the last month or so. I'll fix that in my question. – hippietrail Aug 03 '23 at 18:04
  • 1
    "which I think means that are not signed" now that you mentioned it... did you run the app from Android Studio directly instead of building and signing the APK? I just remembered that Android blocks installation of unsigned APKs. – Andrew T. Aug 07 '23 at 14:21
  • @AndrewT. Yes I ran it directly from Android Studio on the emulator and on my old device. I'm too much of a noob at Android Studio and Android dev generally to know much about signing. It seems that CERT.SF is only used for v1 signing and v2, v3, and v3.1 add a special section to the APK/ZIP binary file format. I don't quite grok the documentation on the signing for v4. – hippietrail Aug 07 '23 at 14:29
  • 1
    Based on my experience, it's quite straightforward following the documentation: create a new keystore from Android Studio (since this is just for personal use, no need to put real info), then use it for building and signing the APK (not App Bundle); I believe you can choose the simplest signature version because it's only to satisfy the installation. – Andrew T. Aug 07 '23 at 15:03
  • @AndrewT. I'll try it as soon as you can. If it works you can write an answer and I'll accept it. – hippietrail Aug 07 '23 at 15:06
  • I think this turned out to be that I was copying the APK that Android Studio put on my old phone as part of building/testing and you can't just copy those onto another phone. I was not able to verify this 100% though. – hippietrail Sep 06 '23 at 02:53

0 Answers0