Incorrect APKs versionCode order when building multiple APKs for both 32bit and 64 bit platforms with crosswalk

白昼怎懂夜的黑 提交于 2019-12-30 04:57:07

问题


I need to build the ionic/cordova application for both 32bit (armeabi-v7a and x86) and 64bit (arm64-v8a and x86_64) platforms. I build four separate APKs using commands ionic build android --release and ionic build android --release --xwalk64bit All goes well except that the versionCode (for version set to 0.0.11) is a little off - see below

The problem is that x86 and x86_64 must have higher versionCode then ARM apks. This is required because x86 devices are able to handle ARM libs but there is no ARM device able to handle x86 libs. So we must keep the version code of x86 APK higher than the one of ARM apk, and the right APK will go to the right device.

Here is what I'm looking for (and what I finally managed to create) - see below

The problem is that the versionCode is set by both build.gradle and modified by crosswalk mobile-xwalk.gradle which gives the wrong versions using my build approach described above. I tried to set the versionCode using android-versionCode param in config.xml and using cdvVersionCode for build.gradle (see http://cordova.apache.org/docs/en/6.x/guide/platforms/android/index.html#configuring-gradle) but no luck.

I end up to fix the problem by manually changing mobile-xwalk.gradle to set the correct versionCodes for 64bit apks (as shown on my second screenshot). This does not look like the optimal solution for me

Question - are there any better way to approach this problem?


回答1:


It seems there is a bug in cordova-plugin-crosswalk-webview. This code part from platforms/android/build.gradle (used to build 32-bit):

productFlavors {
        armv7 {
            versionCode defaultConfig.versionCode*10 + 2
            ndk {
                abiFilters "armeabi-v7a", ""
            }
        }
        x86 {
            versionCode defaultConfig.versionCode*10 + 4
            ndk {
                abiFilters "x86", ""
            }
        }
        all {
            ndk {
                abiFilters "all", ""
            }
        }
    }

here is versionCode*10 as seen... And this code part from platforms/android/cordova-plugin-crosswalk-webview/YOUR_APP_SUFFIX-xwalk.gradle (used to build 64-bit):

productFlavors {
            x86_64 {
                versionCode defaultConfig.versionCode + 6
                ndk {
                   abiFilters "x86_64", ""
                }
            }
            arm64 {
                versionCode defaultConfig.versionCode + 9
                ndk {
                    abiFilters "arm64-v8a", ""
                }
            }
        }

and here is just versionCode. So I usually change second file to versionCode*10 to solve PlayMarket issues



来源:https://stackoverflow.com/questions/39389330/incorrect-apks-versioncode-order-when-building-multiple-apks-for-both-32bit-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!