Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

min_native_interface problem on Android #45

Closed
andreialecu opened this issue Nov 22, 2015 · 17 comments
Closed

min_native_interface problem on Android #45

andreialecu opened this issue Nov 22, 2015 · 17 comments

Comments

@andreialecu
Copy link
Contributor

I was troubleshooting a weird problem with min_native_interface not seemingly doing anything.

Then I realized that if I had android-versionCode="2", the apk would actually have a version code of 20, 22 or 24 (depending on platform, arm/x86/etc) even though AndroidManifest.xml would show version code as being 2. This can be confirmed by running aapt dump badging package.apk.

The reason for this behavior is here: https://issues.apache.org/jira/browse/CB-8976

So incrementing the version code for android to 3 in cordova's config.xml would require setting min_native_interface to at least 30.

This doesn't happen for iOS, so the version code would still be 3 in this case.

The workaround here is to make sure that ios version codes are incremented by 10 in order to keep the android and ios packages in sync.

So for version code 3, the following needs to be done:

<widget id="..." android-versionCode="3" ios-CFBundleVersion="30"> and min_native_interface has to be set to 30.

This should be added to the readme at the very least. I'm not sure if there are any ways to solve it, perhaps one way would be to separate min_native_interface into min_native_interface_android and min_native_interface_ios

@nikDemyankov
Copy link
Member

That's an interesting thing. Looked into project's gradle file - they are increasing the version code of the app without telling anything to the developer... There should be a workaround, I have one idea, but for now - documentation update is the very least, you are right.

@nikDemyankov nikDemyankov added this to the v1.1.2 milestone Nov 23, 2015
@nikDemyankov nikDemyankov modified the milestones: v1.1.3, v1.1.2 Nov 30, 2015
@nikDemyankov nikDemyankov modified the milestones: v1.1.4, v1.1.3 Dec 10, 2015
@luigi37
Copy link

luigi37 commented Jan 10, 2016

I m unsure about this version code. Is this the same as config.xml version code?
If yes I have it manually and explicitly set and it seems from Google play that it's kept as I set it. Thanks for confirming or correcting

@nikDemyankov
Copy link
Member

If you mean version, that is defined like this:

<widget 
    id="io.cordova.hellocordova"     
    version="1.0.0"  
    xmlns="http://www.w3.org/ns/widgets" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0">

then no. In the version property of the widget tag you define version of your application, that is visible to the user on the store.

min_native_interface is the version of your application code, which is defined like so:

<widget id="io.cordova.hellocordova"
      version="1.0.0"
      android-versionCode="7"
      ios-CFBundleVersion="3"
      xmlns="http://www.w3.org/ns/widgets" 
      xmlns:cdv="http://cordova.apache.org/ns/1.0">

A bit more details about it can be found in the docs.

For android Cordova increases it automatically. For example, if you set it to 7 - Cordova's gradle build will increase it to 70. This has something to do with building multiple apk files for different architectures. Especially when you are using crosswalk plugin in your project.

@luigi37
Copy link

luigi37 commented Jan 11, 2016

Thanks Nik, actually I'm using for example:

<widget xmlns="http://www.w3.org/ns/widgets"
    xmlns:android = "http://schemas.android.com/apk/res/android"
    xmlns:gap="http://phonegap.com/ns/1.0"
    id="com.whatever.what"
    versionCode="80501"
    version="8.5.1">

And this is kept when uploading to Google Play.

Is this the same as android-versionCode="80501" ?

@nikDemyankov
Copy link
Member

Don't see in the documentation anything about versionCode, only android-versionCode. Here is the official docs: https://cordova.apache.org/docs/en/latest/config_ref/index.html#link-2.

Either versionCode is the same as android-versionCode, and this is just not stated in the docs. Or it is actually ignored, and you see on Google Play the same value, because of the default formula, that is used by Cordova to calculate it:

// assuming version = MAJOR.MINOR.PATCH-whatever
versionCode = PATCH + MINOR * 100 + MAJOR * 10000

Either way - yes, 80501 is the value for min_native_interface.

@luigi37
Copy link

luigi37 commented Jan 11, 2016

Interesting... I think I've put this option (version) in 2013 and was in my file since then... Maybe and old one?
Also funny that the calculation works the same way I manually used to keep version and version code in sync :-)
Anyway it seems to keep the version code correct for some reasons...
I'll dig more and report
Thanks
Luigi

@nikDemyankov
Copy link
Member

Probably will make min_native_interface as a separate preference in the config.xml instead of using versionCode. Didn't want to increase the number of preferences, but maybe this will make it simpler and cleaner for the developers. Plus, will solve the issue with Cordova's manipulations with the versionCode.

@luigi37
Copy link

luigi37 commented Jan 12, 2016

Hi Nik, I share your feeling about avoiding adding preferences and at the same time I agree that in this case might be better to add a specific option.
In effect I don't use Crosswalk in my apps so it might be the reason why they work...

@luigi37
Copy link

luigi37 commented Jan 19, 2016

Hi Nik, is the preference option change scheduled yet ? ( min_native_interface as a separate preference in the config.xml)
Thanks
Luigi

@nikDemyankov
Copy link
Member

Hi @luigi37 ,
I'm thinking to add it in v1.3.0. Along with some other changes. But can't give you an exact date at the moment. Most likely in the next month. In January I'll be doing only some bug fixes, and work on other stuff.

@luigi37
Copy link

luigi37 commented Jan 19, 2016

Sounds a great plan. Thanks!

@nikDemyankov nikDemyankov added this to the v1.3.0 milestone Feb 8, 2016
@mukesh1908
Copy link

Hi @nikDemyankov ,
I'm using cordova-hcp build. Where should I define min_native_interface? If I need to increase how would I increase?

@nikDemyankov
Copy link
Member

Hi @mukesh1908 ,

Please, read documentation about that. In short right now this is defined only on server side. Native side uses versionCode value. If you'll decide to increase it - you just need to update chcp.json on the server by adding/changing min_native_interface preference in it.

In v1.3.0 of the plugin it will be a separate preference in config.xml.

@mukesh1908
Copy link

Hi, @nikDemyankov , thanks for your reply. So I have to change min_native_interface in chcp.josn manually in the server if I want my app to be downloaded from store instead of updating from server.

@nikDemyankov
Copy link
Member

@mukesh1908 Yes. Point of this parameter is to prevent plugin from installing something, that native side doesn't support. And if it is higher on the server, then the version code of the application - it is ignored by the plugin.

@mukesh1908
Copy link

@nikDemyankov so currently there is no way to automate it. I have to make it manually.
Thanks!

@nikDemyankov
Copy link
Member

Fixed in v1.3.0. Added native-interface preference into config.xml. Please, read documentation on how to use it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants