Phonegap-plugin-barcodescanner: Min Android SDK

Created on 15 May 2016  路  25Comments  路  Source: phonegap/phonegap-plugin-barcodescanner

Do we need the min android SDK of 15 there?
Not that it's a huge issue, just that when I want to compile my non-crosswalk apk for android versions 19+, I need to remove this line.

Thanks.

question android

Most helpful comment

@EddyVerbruggen I can confirm that this plugin overrides any preference that we put in our config.xml, which seems to me as an obviously bad behaviour

can you remove the line, as suggested here? #275

thanks a lot!

All 25 comments

Yes. Don't modify default behavior. I cannot set minskd in all the ways with this plugin
You must not try to fix core parameters

Have you guys tried setting the minsdk in config.xml to override it? Not entirely sure that'll work but it usually does. If it doesn't help please comment back here and I'll smarten up the gradle script.

config.xml does not correspond to my build system. But in this case I cannot modify this value through all other 3 methods

Yea setting minsdk in the config.xml does not work. Even manually setting the minsdk in AndroidManifest doesn't work either, so the plugin is definitely overriding it.

I got the same problem, because I need to compile for android 10 (2.3.3/2.3.7 Gingerbread Devices) - I know, very old but.. Can't help it.

It is very easy to do that. You just need to change:

config.xml

and in plattforms/Android/CordovaLib/AndroidManifest.xml

HOWEVER, that does not work for this plugin, because of the fact that the aar plugin / packing type of the barcode scanner needs android4+ support, which is included here:

https://github.com/phonegap/phonegap-plugin-barcodescanner/blob/master/src/android/barcodescanner.gradle

and as far as I know, does not work without that... And that is what is stopping you, I think...

Gosh...... I've been struggling to build my non-crosswalk version for days and now I found out that this plugin is bringing min sdk down to 15+
I would stay on 4.x if the camera was not upside down on Nexus 5X

@EddyVerbruggen I can confirm that this plugin overrides any preference that we put in our config.xml, which seems to me as an obviously bad behaviour

can you remove the line, as suggested here? #275

thanks a lot!

@cvaliere done!

@EddyVerbruggen thanks a lot
I looked at the commit, it's even better

@EddyVerbruggen Yea I think this still isn't working unfortunately. My AndroidManifest is still getting overwritten. Not sure if it's just my project though, can anyone else confirm? Thank you.

nope, I can confirm it works
(I have in my config.xml, and it's not overriden)
maybe try to set up a minimal project?

I'm having this issue as well. Another plugin requires 16+ and this plugin is overwriting the minSdkVersion in the AndroidManifest.xml to 15. Build fails

@AlDrag @koga73
After removing the line in in config.xml you need to clear the build cache sometimes.
For me (I'm using Ionic) the most simple method is to remove and readd the Android platform (beware to backup pour r茅al茅s茅 apk before if needed)

Hope It helps

@mafzst I removed the platforms and plugins directories, re-prepared the platform with the latest version of barcodescanner and it still drops my minSdkVersion from 16 to 15 during build. Since another plugin requires at least 16 the build fails.

The only way I was able to get around it was to modify the barcodescanner.gradle file and update it from 15 to 16. Definitely not a good solution though because if I ever wipe the platform it'll get lost.

I have the same problem.
I need minSdkVersion 21 and in the AndroidManifest.xml I have
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="23" />
But when uploading the apk to the Play Store the version is downgraded to 15 :-(
Without the plugin the minSdkVersion in the Play Store is correct.

I have exactly the same problem like @koga73, I'm using ionic too and one of the plugins require minSdkVersion 16. Does some one have a solution ?

I writed own cordova hook to remove this at build step

code part

ctx.requireCordovaModule("glob")("phonegap-plugin-barcodescanner/*.gradle",
                                         {
                                             cwd:      path.join(ctx.opts.projectRoot, "platforms/android"),
                                             realpath: true
                                         },
                                         function(errGlob, files) {
                                             if (errGlob) {
                                                 return deferred.reject(errGlob);
                                             }
                                             return q.all(files.map(function(file) {
                                                         var fileDeferred = q.defer();
                                                         fs.readFile(file, "utf8", function(errRead, fileContent) {
                                                             if (errRead) {
                                                                 return fileDeferred.reject(errRead);
                                                             }
                                                             var matchRegexp = /^ext\.cdvMinSdkVersion\s+=.*/mg;
                                                             if (!matchRegexp.test(fileContent)) {
                                                                 return fileDeferred.resolve();
                                                             }
                                                             return fs.writeFile(file, fileContent.replace(matchRegexp, ""), "utf8", function(errWrite) {
                                                                 if (errWrite) {
                                                                     return fileDeferred.reject(errWrite);
                                                                 }
                                                                 return fileDeferred.resolve();
                                                             });
                                                         });
                                                         return fileDeferred.promise;
                                                     }))
                                                     .then(function() {
                                                         return deferred.resolve();
                                                     }, function(err) {
                                                         return deferred.reject(err);
                                                     });
                                         });

Any news on this since few months ago? The override is still in place, ignoring android:minSdkVersion setting in the project.

I have the same Problem with this Plugin and the PayPal Plugin. Is there a fix?

there are dozens of PayPal plugins, can you link the one you are using?

use this hook https://gist.github.com/Delagen/c1264df9176666f25ee8d745f6a2cbc2 cause it https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/413 solve only one way of overriding minSDK
config.xml part

    <platform name="android">
        <hook type="before_compile" src="scripts/android/hook.js"/>
        <hook type="before_prepare" src="scripts/android/hook.js"/>
        <hook type="before_build" src="scripts/android/hook.js"/>

Yeah, I forgot to consider other plugins setting the minSDK.
I think this PR should cover it, can you test it?
https://github.com/phonegap/phonegap-plugin-barcodescanner/pull/420

@jcesarmobile It only depends on config.xml preference.
But it could be set via

  • gradle param with the way
1.  export ORG_GRADLE_PROJECT_cdvMinSdkVersion=20
2. -- --gradleArg=-PcdvMinSdkVersion=20 via CLI
3.  cdvMinSdkVersion=20 in <your-project>/platforms/android/gradle.properties
4.  ext.cdvMinSdkVersion = 20 in <your-project>/build-extras.gradle
5. android-minSdkVersion in config.xml

I think it must be totally removed as devices lower that 15 api covers only 2% of market https://developer.android.com/about/dashboards/index.html

Developing cost via webview on such devices grows incredibly, so developers usually set minSDK much higher than 15.

This thread has been automatically locked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vespino picture vespino  路  9Comments

thomas-tran picture thomas-tran  路  9Comments

mlaponder picture mlaponder  路  5Comments

front-stream picture front-stream  路  7Comments

camilonos77 picture camilonos77  路  7Comments