Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova-plugin-browsertab conflict with cordova android@7.1.3 and 7.1.4 #640

Closed
cjohn001 opened this issue Jan 26, 2019 · 7 comments
Closed
Labels
info-needed / awaiting response Further information is requested support

Comments

@cjohn001
Copy link

cjohn001 commented Jan 26, 2019

The title says everything.

Replicate by creating a new project and adding

 <plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
  <plugin name="cordova-plugin-browsertab" spec="^0.2.0" />

I get the following error. Maybe someone has an idea for a workaround. I tried setting the min version to 19 as mentioned in the error message. But without success.


This did not work:

    <platform name="android">
        <preference name="android-minSdkVersion" value="19" />
        <preference name="android-targetSdkVersion" value="27" />
    </platform>


Error message:

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:CordovaLib] /Users/cjohn/Entwicklung/IMS/CordovaLogin/platforms/android/CordovaLib/build/intermediates/manifests/full/debug/AndroidManifest.xml as the library might be using APIs not available in 16
  	Suggestion: use a compatible library with a minSdk of at most 16,
  		or increase this project's minSdk version to at least 19,
  		or use tools:overrideLibrary="org.apache.cordova" to force usage (may lead to runtime failures)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
c

@brody4hire
Copy link

This is basically a manifestation of #508 and I do not expect we will fix it. It looks like cordova-plugin-browsertab ([1], [2]) builds for an old SDK version that we no longer support, and the plugin has not been updated within the past 1-2 years.

[1] https://github.com/google/cordova-plugin-browsertab
[2] https://www.npmjs.com/package/cordova-plugin-browsertab
[3] https://github.com/google/cordova-plugin-browsertab/blob/master/plugin/src/android/BrowserTab.gradle

@cjohn001
Copy link
Author

cjohn001 commented Jan 28, 2019

Hello Brody,
thanks for the analysis. However, the decision not to fix it, is somehow a pitty. Seems like this plugin is required to enable SSO in Cordova, like described here

https://www.youtube.com/watch?v=HKulxXDYJSs&feature=youtu.be

I do not have the java background to maintain the plugin. So you say it is a bug in the plugin? The BrowserTab.gradle file which you reference says in the checkin comment, that it was a workaround regarding a gradle issue with cordova. To me it is not clear what would have to be done to fix the issue here.
As far as I understood the discussion in #508, even though it shows not the resulting decision, the min version should be set via config.xml. In that case, would the fix than be simple as removing the BrowserTab.gradle file from the plugin? I assume, this would require, that the fix the file made in the past was previously in the meantime fixed in Cordova. Would be great if you could give me a hint on that, as I am currently stuck with Cordova 7.1.2 due to the issue.

To my understanding, there seems to be something else wrong than the BrowserTab.gradle. As described previously, I have set the value in config.xml.

    <platform name="android">
        <preference name="android-minSdkVersion" value="19" />
        <preference name="android-targetSdkVersion" value="27" />
    </platform>

If this would have translated to gradle, than the code in BroswerTab.gradle should have had no effect.

Best regards
Christoph

@brody4hire brody4hire added info-needed / awaiting response Further information is requested support and removed wontfix labels Jan 28, 2019
@brody4hire
Copy link

Workaround is given by @ashvinmay in google/cordova-plugin-browsertab#17 (comment), I just tested it myself:

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

I really hope someone will update and fix cordova-plugin-browsertab.

@cjohn001
Copy link
Author

Hello Brody,
thanks, the fix did work.

Best regards,
Christoph

@brody4hire
Copy link

Thanks. As I said before I really hope someone will fix the problem in cordova-plugin-browsertab. It is not so good that any of us Cordova maintainers have to provide support due to this kind of abandoned projects.

@Icety
Copy link

Icety commented Feb 14, 2019

When you need the fix to be applied automatically the following hook will fix it for you:

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!");
    });
} 

@cjohn001
Copy link
Author

Hello Icety,
thanks for your help. The fix from brodybits did the trick for me already, but the solution you described is probably the better one as it does not need changes in the platform folder.

Best regards,
Christoph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed / awaiting response Further information is requested support
Projects
None yet
Development

No branches or pull requests

3 participants