question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin overrides android minSdkVersion to 16

See original GitHub issue

This plugin causes cordova to disregard the minSdk version set in config.xml.

For example, if i have the following line in my config.xml: <preference name="android-minSdkVersion" value="21" />

This plugin causes cordova to build my android app with version 16 as the target (and not 21 as i asked).

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:6

github_iconTop GitHub Comments

7reactions
ashvinmaycommented, Nov 14, 2017

For quick fix, create build-extras.gradle with following def minSdkVersion = 21 cdvMinSdkVersion = minSdkVersion ext.cdvMinSdkVersion = minSdkVersion

Copy this file to /platforms/android/ folder. You can either do it manually or can write a hook

2reactions
Icetycommented, Feb 14, 2019

Here is a hook that fixes the problem:

Add to config.xml:

<platform name="android">
<hook src="scripts/afterAddBrowserTabPlugin.js" type="after_plugin_add" />
</platform> 

create file: cordova/scripts/afterAddBrowserTabPlugin.js

const fs = require('fs');

module.exports = function(ctx) {
    var Q = ctx.requireCordovaModule('q');
    var deferral = new Q.defer();

    if (ctx.opts.plugins.includes('cordova-plugin-browsertab')) {

        let file = ctx.opts.projectRoot + '/plugins/cordova-plugin-browsertab/src/android/BrowserTab.gradle';
        console.log(file);

        checkForFix(file);
    }

    return deferral.promise;
};

function checkForFix(file) {
    fs.readFile(file, function read(err, data) {
        if (err) {
            throw err;
        }

        if (!data.includes('minSdkFix')) {
            writeFix(file);
        }
    });
}

function writeFix(file) {
    fs.appendFile(file, '\n\n// minSdkFix\nminSdkVersion = 21;\ncdvMinSdkVersion = minSdkVersion;\n' +
        'ext.cdvMinSdkVersion = minSdkVersion;', function(err) {
        if (err) {
            console.log('Adding minSdkFix failed: ' + err);
        }
        console.log("Writing success!");
    });
} 
Read more comments on GitHub >

github_iconTop Results From Across the Web

uses-sdk:minSdkVersion 15 cannot be smaller than version ...
1) Go to Build.gradle(Module:app) . · 2) Change minSDKVersion 15 to minSDKVersion 16 . or 17 // 19(for projectfolder/platforms/android/CordovaLib/AndroidManifest ...
Read more >
<uses-sdk> | Android Developers
Lets you express an application's compatibility with one or more versions of the Android platform, by means of an API Level integer.
Read more >
Support Library Setup - Android Developers
If you are using Gradle build files, the minSdkVersion setting in the build file overrides the manifest settings. plugins { id 'com.android.application' }...
Read more >
Manage manifest files - Android Developers
For example, the minSdkVersion from the build.gradle file overrides the matching attribute in the <uses-sdk> manifest element.
Read more >
Past releases - Android Developers
The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found