google / cordova-plugin-browsertab

A Cordova plugin that provides an interface to in-app browser tabs that exist on some mobile platforms, such as SFSafariViewController on iOS and CustomTabs on Android.
Apache License 2.0
117 stars 147 forks source link

Plugin Android compilation error. 1: Task failed with an exception. #43

Open oleglatypov opened 2 years ago

oleglatypov commented 2 years ago

After installing cordova-plugin-browsertab plugin. I can not generate an Android build because following issues:


1: Task failed with an exception.
-----------
* Where:
Script '/platforms/android/cordova-plugin-browsertab/app-BrowserTab.gradle' line: 3

* What went wrong:
A problem occurred evaluating script.
> Could not get unknown property 'cdvMinSdkVersion' for project ':app' of type org.gradle.api.Project.

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

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

Here is app-BrowserTab.gradle:


if(cdvMinSdkVersion == null) {
    ext.cdvMinSdkVersion = minSdkVersion;
} else if (cdvMinSdkVersion.toInteger() < minSdkVersion) {
    ext.cdvMinSdkVersion = minSdkVersion;
}

config.xml

    <preference name="AndroidXEnabled" value="false" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="30" />
    <preference name="android-compileSdkVersion " value="30" />

package.json

    "cordova-plugin-browsertab": "^0.2.0",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-inappbrowser": "^5.0.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-music-controls2": "^3.0.6",
    "cordova-plugin-splashscreen": "^6.0.0",
    "cordova-plugin-statusbar": "^3.0.0",

Its successful if target=android-29 when I change to target=android-30 issue spotted.

Can Someone help me?

benoitbzl commented 2 years ago

Hello, I am facing the same issue. Does someone find a fix / workaround for that error?

Cordova 11 cordova-android 10.1.2

benoitbzl commented 2 years ago

A workaround could be to set the variable at the command line or as an environment variable (see https://cordova.apache.org/docs/en/11.x/guide/platforms/android/index.html#setting-gradle-properties)

danieldanielecki commented 11 months ago

Adding cdvMinSdkVersion=21 inside gradle.properties fixed this problem for me.