apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.64k stars 1.53k forks source link

Ionic 4 output apk is not 64bit compliant #974

Closed JuanLHDarien closed 4 years ago

JuanLHDarien commented 4 years ago

Bug Report

Problem

Ionic 4 app when compiled for deploy in Playstore is not 64bit compliant, this only happens with the android version on the app using cordova , the iOS version is 64bit compliant for the respective platform.

What is expected to happen?

The compilation of a 64bit universal apk.

What does actually happen?

A 32bit universal apk.

Information

Command or Code

npx ionic cordova build android --prod --release jarsigner for signing apk zipalign for compressing assets in apk

Environment, Platform, Device

Windows 10 Pro Android 7 Phone (tested positive for app functionality and install) Android 9 Phone (tested positive for app functionality and install) Android 10 Phone (tested positive for app functionality and install) Playstore (Current problem)

Version information


   Ionic CLI                     : 5.4.16
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.0.0
Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 13 other plugins)

Utility:

   cordova-res (update available: 0.11.0) : 0.10.0
   native-run                             : not installed

System:

   NodeJS : v10.15.1 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Cordova Plugins installed and used in the project

cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-fcm-with-dependecy-updated 3.2.0 "Cordova FCM Push Plugin"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-queries-schemes 0.1.1 "App Queries Strings"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-wkwebview-engine 1.2.1 "Cordova WKWebView Engine"
cordova-plugin-x-socialsharing 5.6.5 "SocialSharing"
es6-promise-plugin 4.2.2 "Promise"
uk.co.workingedge.phonegap.plugin.launchnavigator 5.0.4 "Launch Navigator"

Checklist

breautek commented 4 years ago

You only need a 64bit apk if you include native libaries in your app.

If you do, then you must use a multi apk setup. This is not very common, so the documentation is kind of lacking unfortunately, but some information can be found at https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#setting-gradle-properties

Cordova will generate an APK for each ABI. You have to upload each APK variant to the Google Play store when you make your releases.

Alternatively, you can try the bundle format, but this only works if plugins supply a native so file for each ABI. So it depends on how the plugin has their native dependencies configured.

If you're using the latest version of cordova-android (version 8.1.0 at the time of writing), then you can build bundles by passing the --packageType=bundle flag e.g.:

cordova build android --release -- --packageType=bundle

Do note, bundles are only supported for release builds. This will build an .aab file, which you can also upload to the google play store.

JuanLHDarien commented 4 years ago

Hi @breautek I have tried the second option you already stated , still the error persists for some reason unknown. What I did try was to upload all apk variants of the app. And still got the 64bit not compliant issue. The first one the X86_64 variant gave the bits error and the other 4 gave me the "fully shadowed apk" . errorstill

I really have tried everything and anything I have read online and read on the docs without any definitive answer on what is going on

Edit: Tried instead of simultaneously uploading all variants, uploading one by one , all gave the error of 64bit compliant , how is this possible?

breautek commented 4 years ago

Your APKs don't appear to be targeting to any native platforms. They look like they are being built as universal APKs, which does not work native libraries.

The first APK states it's not compliant because it likely has native code bundled in it, and so you need a 32bit and a 64bit variant. The other remaining APKs are "shadow apks" because they have no difference to the first APK, therefore it will never ever be installed.

It's also possible that the third-party plugin that is including a native library is not even providing a 64bit version of the native library, in which case you'll need to contact the maintainer of that library/plugin.

breautek commented 4 years ago

I'm not sure how to do this in ionic, but if the bundles didn't work, you can try going the out-school route, which is the multiple apk setup. The cordova command to enable multiple apks is:

cordova build android -- --gradleArg=-PcdvBuildMultipleApks=true

Inside platforms/android/app/build/outputs/apk, you'll see several directories, an APK for each native platform.

JuanLHDarien commented 4 years ago

@breautek Yeah the thing is there's not native code because when I analyze the apk there's no libs\ folder , and no .so files, so no native code at all , anyways will try with your option and come back to you if it fails.

edit the only .so file found inside the project is the libnative.so in the org.test.plugins.dummyplugin

breautek commented 4 years ago

Yeah the thing is there's not native code because when I analyze the apk there's no libs\ folder , and no .so files, so no native code at all , anyways will try with your option and come back to you if it fails.

Google Play appears to believe there is. Is your android sdk installation are all up to date? I' found this which suggest you may see 64bit compliance issues if you're using an old enough version of build tools.

JuanLHDarien commented 4 years ago

It did indeed fail once again @breautek I really don't understand what is going on , the thing is that the iOS version has no problem at all producing 64bit compliant code but the android one is, I have all my version build tools updated. I don't know what else to try

JuanLHDarien commented 4 years ago

I'm happy to notify you @breautek that the problem was that the previous incompatible 32bit release of the app, once deactivated (hadn't done that all) immediately stopped showing the 64bit compliant error. It's all fixed , sorry for the inconveniance

breautek commented 4 years ago

Ah, I don't recall ever having to do that, but at least you found the solution!