Upgrade of JDK breaks app installation

PaulDistonPaulDiston USUniversity ✭✭✭✭

I have recently had to rebuilt my development machine and have upgraded to use version 1.8 of the JDK, I was previously using 1.6.

When I come to side load a new APK which has been created using the 1.8 JDK onto a device that has a previous app version installed built using version 1.6 of the JDK, the installation fails. Uninstalling the previous version allows for the new version to be installed.

Is this expected? If so, will versions uploaded to the Play Store be effected, i.e. will users need to uninstall the previous version before then can upgrade to the latest version?

If this isn't expected, could this problem be caused by the change in the version of the JARSigner.exe I now use (1.8 from 1,6)? Again, will this cause problems for the Play Store?

Tagged:

Answers

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    JDK 1.8 has been needed for Android since Android 7.0(Nougat), before that JDK 1.7 was required since Android 5.0(Lollipop).

    Get adb logcat logs when performing the migration, it should reveal the failure with more context as to why and an install failure.

    It is very unlikely that Google Play workflow will be affected.
  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    @JonDouglas Thanks for your reply. I have managed to use the Android Device Monitor to view the LogCat during the failed installation. I have attached the log entries that I have.

    The following might explain the issue https://stackoverflow.com/questions/42292185/cannot-update-the-app-after-updating-sdk-app-not-installed however as I am using a PowerShell script to sign the APK I am not sure how to enable V1 and V2.

    Or the problem could be something else.

  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    I have tried a couple of other things including using the apksigner.bat and the jarsigner.exe from 1.6 however the only way I seem to be able to get the installation to work is to revert back to JDK 1.7 and rebuild/archive a new version, this new version is then signed using jarsigner.exe 1.6. A difference to before is that the new installation does not now prompt for changes to permissions.

    I am still compiling against Android 6.0 so I am not sure whether my jump to JDK 1.8 also required me to compile against a newer Android version.

  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    I think I have resolved my issue. I installed Android 7.0 via the Android SDK Manager. I then set Android 7.0 as the compile version for my two Android projects, I then set the JDK version to 1.8.0.101, I then build/archived a new version. I then used the jarsigner from JDK 1.8.0.101 to sign the application. After these changes the installation succeeded.

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    @PaulDiston

    The logs have no indication of having to do anything with signing, so let's mark that one out. jarsigner is still the default, although we added support for apksigner that you can use.

    I believe you are running into our "regression" of ClassNotFound:

    java.lang.ClassNotFoundException: com.android.packageinstaller.InstallFlowAnalytics

    I've documented this as a known issue:

    https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#Java.lang.ClassNotFoundException

    We have a fix for this available in a service release that is upcoming (15.5.5). We also have a fix for this in our next preview (15.6 Preview 3)

    However please try this workaround in your local environment as these releases are not out yet:

    https://bugzilla.xamarin.com/show_bug.cgi?id=61073#c40

  • PaulDistonPaulDiston USUniversity ✭✭✭✭
    edited March 2018

    @JonDouglas

    I have run into a similar issue after trying to install a newer version of our application when a previous version is installed.

    The previous version was built with VS 2015 targeting Android 7.0. The new version is built with VS 2017 targeting Android 8.0. Both would have different JDK versions.

    I have inspected Logcat and the following entries related to the attempted installation :-

    03-14 09:08:54.028: I/MSTG(2584): uk.co.skillweb.sorbet is installing..
    03-14 09:08:54.029: I/AASAInstall(2584): ship device
    03-14 09:08:54.085: W/PackageManager(2584): Package uk.co.skillweb.sorbet new target SDK 15 doesn't support runtime permissions but the old target SDK 23 does.
    03-14 09:08:54.104: D/PackageManager(2584): result of install: -26{115151459}
    03-14 09:08:54.105: E/(2569): Couldn't opendir /data/app/vmdl842357044.tmp: No such file or directory
    03-14 09:08:54.135: D/InstallAppProgress(14477): Installation error code: 4

    Do you have an idea why the installation may have failed in this scenario?

    When the install fails on the phone I am presented with the following error :-

    App not installed
    The package appears to be corrupt.

    I have tried to reproduce the error with another application so that I can make 100% sure our store upload would not be affected but have not been able to reproduce the exact issue yet.

    As before the uninstall of the previous version allows the new version to be installed however we do not want our live customers to have to go through this process.

    If there was a way to guarantee that the store upload and install process would not be affected by this error then that would help a great deal.

    Update: One thing I have noticed is that in my previous version the AndroidManifest.xml has the android:targetSdkVersion set however in my newer version it is not set. I tried yesterday to set this value on my newer version however this then broke the Acr.DeviceInfo.5.0.5 library I use (https://stackoverflow.com/questions/49273173/setting-androidtargetsdkversion-in-androidmanifest-xml-breaks-acr-deviceinfo-5)

    A side question, as things seemed to work better when targeting Android 7.0, should I change all my Android projects to target that version instead of Android 8.0?

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    Based on your information, please explicitly set the `targetSdkVersion` which will enable runtime permissions if its set to the same API level as your `compileSdkVersion`.

    I'm not sure of this library, so I can't really help unless I can view source code or you have a sample demonstrating the issue.
  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    As a general note, your compileSdkVersion and targetSdkVersion should explicitly be set to the latest version. Your minSdkVersion should be the lowest device level you want to support.
  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    @JonDouglas

    Thank you very much for getting back to me.

    I have now switched to use the Xam.Plugin.DeviceInfo.3.1.0 library rather than the Acr.DeviceInfo.5.0.5 library, as this then allows the targetSdkVersion value to be defined in the AndroidManifest.xml and therefore fixes my installation issue.

Sign In or Register to comment.