APK fails on certain systems: App not installed


#1

This used to build and install quite happily on all devices. A couple of days ago I tried wrapping it up and signing a release for the play store. Somewhere in the process of cleaning it up and upgrading various libraries I broke it. Now I can’t get back to a working archive.

I build my app with ionic cordova build --debug android. On a Huawei P20 running Android 8.1.0 loading the apk fails. I can’t see anything in an adb logcat console and the message on the screen is just “App not installed”. It will install from the same package on a MotoG5 running Android 7. It had previously worked on both phones.

I’ve updated (and downgraded) cordova-android, updated Gradle, updated Android Studio removed Ionic Pro and Crosswalk since then. I’ve deleted and rebuilt nodes_modules, removed/added the Android platform, built and rebuilt the package. Adding those components back in leads to other issues. Running the install with Crosswalk now works but on launch of the app says it’s the incorrect CPU architecture. That’s with the arm64 image, which previously worked. When I compile a single install image for all platforms the resultant app hangs on the splashscreen.

Creating a new project with this development environment results in an installable archive for all devices. But when I try to port the app over to the new scaffolding I’m presented with myriad trivial seeming issues and I still don’t know if it will ultimately succeed. So I’d like to fix this install in place. I have also tried building a release version and signing it. It fails install on both the MotoG5 and the P20 in the same way; “App not installed”. It won’t build and deploy onto the device from the terminal command. I find that has always happened intermittently. So when it does I copy the apk to the mobile and run it myself.

Ionic:
   ionic (Ionic CLI)  : 4.1.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:
   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.1
   Cordova Plugins       : no whitelisted plugins (8 plugins total)

System:
   Android SDK Tools : 26.1.1 (/home/~/Android/Sdk)
   NodeJS            : v10.4.1 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.15

Android Studio: 3.1.4

------------------------------------------------------------
Gradle 4.10
------------------------------------------------------------

Build time:   2018-08-27 18:35:06 UTC
Revision:     ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL:   1.0-rc-3
Kotlin:       1.2.60
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_171 (Oracle Corporation 25.171-b11)
OS:           Linux 4.15.0-33-generic amd64
Installed plugins
------------------------------------------------------------
cordova-android-support-gradle-release 1.4.4 "cordova-android-support-gradle-release"
cordova-plugin-ble-central 1.2.2 "BLE"
cordova-plugin-brightness 0.1.5 "Brightness"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-sqlite-2 1.0.4 "SQLitePlugin"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
package.json dependencies
------------------------------------------------------------
    "@angular/animations": "^6.1.4",
    "@angular/common": "^6.1.4",
    "@angular/compiler": "^6.1.4",
    "@angular/compiler-cli": "^6.1.4",
    "@angular/core": "^6.1.4",
    "@angular/forms": "^6.1.4",
    "@angular/platform-browser": "^6.1.4",
    "@angular/platform-browser-dynamic": "^6.1.4",
    "@ionic-native/ble": "^4.12.0",
    "@ionic-native/brightness": "^4.12.0",
    "@ionic-native/core": "^4.12.0",
    "@ionic-native/device": "^4.12.0",
    "@ionic-native/keyboard": "^4.12.0",
    "@ionic-native/splash-screen": "^4.12.0",
    "@ionic-native/status-bar": "^4.12.0",
    "@ionic/storage": "^2.1.3",
    "@types/cordova": "0.0.34",
    "@types/core-js": "^2.5.0",
    "@types/node": "^10.9.3",
    "aes-js": "^3.1.1",
    "chart.js": "^2.7.2",
    "cordova-android": "7.1.1",
    "cordova-android-support-gradle-release": "^1.4.4",
    "cordova-plugin-ble-central": "^1.2.2",
    "cordova-plugin-brightness": "^0.2.0",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-sqlite-2": "^1.0.5",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "gsap": "^2.0.2",
    "ionic-angular": "^3.9.2",
    "ionic-tooltips": "^2.0.1",
    "ionicons": "^4.4.3",
    "jsonwebtoken": "^8.3.0",
    "moment": "^2.22.2",
    "ng2-charts": "^1.6.0",
    "rxjs": "^6.2.2",
    "rxjs-compat": "^6.2.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "^0.8.26"

#2

What does this mean?


#4

I create a new project. Then copy the src directory from the existing one over. Then try and patch the bits that break.


#5

Having gone through with creating a new project and moving over all the source. It’s the same. The debug version installs fine on all platforms. But the signed release will only install on the MotoG5; on the P20 it says “App not installed”.


#6

Do you maybe still have a version of the app installed?
Multiple users on the device? Then an app can be in all of them, have to explicitly uninstall.


#7

I have fully uninstalled previous versions. Also, the install will let you know if there’s a conflict. I did get an error stating that the developer who signed the app is not known. But then it gives a choice to continue or abort the install.


#8

So it fails when you choose “continue” here?
(That you get this question and what you chose is very relevant information)


#9

Initially I wasn’t getting that message. I am now that I’ve rebuilt the app under a new project. I do choose to “install anyway”. Then it changes to this screen.

Here is the screen flagging the unknown developer.

I’ve disabled Google Play Protect and the same thing happens. I know how it might seem like this is pertinent but really it’s just a red herring.


#10

I tried the install on a OnePlus6 running Android 8.1.0 and it installed without incident. So it’s not the version of Android. Although having said that, Huawei have a shim installed over the OS. So I tried it on a Huawei Y6 and it installed there also.


#11

I created a signed apk from a blank project and tried installing that. It failed in the same way. So I did a full factory reset on the phone and now the signed install works perfectly. I actually just wanted to clear the cache but got distracted and mistook a reset for a menu button. It’s unfortunate that I still don’t know what was causing the signed rather than debug version of the app not to install. Thanks for taking a look Sujan12.


#12

That success was short lived. The app only installs the first time. After the factory reset, it installed correctly. Then I enabled developer tools. Uninstalled and reinstalled the app. This install fails with no obvious error; “App not installed”. So I disabled dev tools and tried again; same failure mode. I rebooted the phone and cleared the cache partition and tried again; same failure. A factory reset between installs probably isn’t an idea solution. Any idea what might be the cause?

I cleared the Settings cache and data to remove Developer Tools on the off chance that that was an issue. The issue persists. It’s interesting to note that the first time the blank test app is installed on the mobile it failed. So to recap; on a fresh install/factory reset I can successfully install one signed Ionic app once. Subsequent installs of different but similarly signed apps fail at the same point. Clearing the system cache, resetting the Settings cache/data have no effect on this behaviour.


#13

I created a new keystore and signed the app with that instead. It seems to be working for all instances. This is going to be problematic if keys fail on some systems after the app has been published. For now it addresses my immediate problem.


#14

Google changed a few things around keystores some time ago. Maybe that one device requires a new/current one? But usually this should not happen :confused:


#15

Just to muddy the waters a bit more; I got the device working with adb again. And an adb install with the previously failing apk works just fine. So I thought perhaps the install package on the device was corrupt. So I copied it over again and ran it on the phone. It fails to install. But the second key version still installs fine from the same file manager on the phone (I’ve tried a couple of file managers and have set the security to allow them to install from insecure locations).

Before publishing the app I would really like to know the key I use to sign it will continue working well into the future. Otherwise I won’t be able to issue updates. Right now I can get it to work; but the failure modes don’t make any sense. Well, other than there being an obscure bug somewhere. So it’d be nice if I could identify where. The logcat for the install looks like this:

09-03 14:28:53.220  1047  1064 D ActivityManager: Skipping intent:act=android.deviceinfo.chooser.action.LAUNCH flg=0x10800000 hwFlg=0x100 pkg=com.android.settings cmp=com.android.settings/.deviceinfo.UsbConnModeChooserActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping, home or recents stack task: TaskRecord{d0e87f9 #1 A=com.huawei.android.launcher U=0 StackId=0 sz=1}
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:act=android.intent.action.DELETE dat=package:io.ionic.starter flg=0x10800000 cmp=com.google.android.packageinstaller/com.android.packageinstaller.UninstallerActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:flg=0x10804000 cmp=com.android.systemui/.recents.RecentsActivity bnds=[48,345][1032,1902]
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:flg=0x10800000 cmp=com.android.systemui/.usb.HwUsbDebuggingActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:dat=dynact://static/opaonboarding/named-sequence-activity flg=0x18800000 cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.velour.dynamichosts.TransparentVelvetDynamicHostActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:act=SETUP_AND_SAVE flg=0x10800000 cmp=com.google.android.gms/.autofill.ui.AutofillDialogActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping intent:act=android.intent.action.DELETE dat=package:com.coroflo.companion flg=0x10800000 cmp=com.google.android.packageinstaller/com.android.packageinstaller.UninstallerActivity
09-03 14:28:53.221  1047  1064 D ActivityManager: Skipping, user setup not complete: TaskRecord{33f33e #6 A=com.android.hotwordenrollment.okgoogle U=0 StackId=-1 sz=0}
09-03 14:28:53.231  1476  1476 D BarTransitions.HwNavigationBarView: MODE_TRANSPARENT -> MODE_OPAQUE animate=false
09-03 14:28:53.231  1476  1476 D BarTransitions.HwNavigationBarView: applyModeBackground oldMode=MODE_TRANSPARENT newMode=MODE_OPAQUE animate=false
09-03 14:28:53.231   602   841 E BufferQueueProducer: [com.asus.filemanager/com.asus.filemanager.activity.FileManagerActivity#0] disconnect: not connected (req=1)
09-03 14:28:53.232 22718 22763 W libEGL  : EGLNativeWindowType 0x7e48984010 disconnect failed

#16

You’ll probably want to talk to Google about this or at least create an issue on StackOverflow.

(The native apps using Ionic are created by using Cordova, Ionic itself really has nothing to do with the native parts)


#17

I’m not inclined at this point to say Ionic, Cordova or Android are at fault. The install works fine with adb from the command line. So something is going wrong when I try to install an app signed with this particular key, which I just created, via a filesystem app running on EMUI over Android. Not just any version of EMUI though as it works on two other Huawei phones. To be honest, I think it’s far to specific a problem to garner much traction. I’m going to sign it with a new key, test it and hope for the best.


#18

Yep, I think so as well. But writing the StackOverflow question with all this information you already have here still might be worth it, I have gotten useful responses months after the fact.

I just wanted to let you know that ionic cordova ... just proxies everything over to cordova ... on the CLI level, and Ionic itself is not involved any more, so you don’t waste your time thinking about what is going wrong on the Ionic level. It can really just be Cordova or Android itself (my guess) that is somehow going wonky here.

Strange case…


#19

One reason I kept hitting this was the id of the <widget> in config.xml.

Ionic-cli will use the same always:
<widget id="io.ionic.starter" ...

And if one of the test phones has another Ionic app with the same id, the installation will fail with App not installed. Other phones without an existing app with conflicting id will install the app happily.


#20

Hey man… I was pulling my hair out for 10 hours until I see this.
Thanks for sharing!