简体   繁体   中英

Ionic Android build error after updating cordova-plugin-x-socialsharing plugin

I have an Ionic 3 application, where I just updated the cordova-plugin-x-socialsharing plugin.

Ionic info..

    $ ionic info

    Ionic:

       ionic (Ionic CLI)  : 4.5.0 (C:\Users\peter\AppData\Roaming\npm\node_modules\ionic)
       Ionic Framework    : ionic-angular 3.6.1
       @ionic/app-scripts : 3.2.2

    Cordova:

       cordova (Cordova CLI) : 7.0.1
       Cordova Platforms     : android 6.2.3, ios 4.3.1, windows 5.0.0
       Cordova Plugins       : no whitelisted plugins (16 plugins total)

    System:

       Android SDK Tools : 26.1.1 (C:\Users\peter\AppData\Local\Android\sdk)
       NodeJS            : v10.15.0 (C:\Program Files\nodejs\node.exe)
       npm               : 6.4.1
       OS                : Windows 10

I now get the following build error..

    * Where:
    Build file 'D:\dev\myapp\platforms\android\build.gradle' line: 252

    * What went wrong:
    A problem occurred evaluating root project 'android'.
    > Could not get unknown property 'ANDROID_SUPPORT_V4_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

At the line in build.grade, I have the following..

在此处输入图像描述

Also, in my package.json, I notice I now have the following..

"cordova-plugin-x-socialsharing": {
            "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
        },

I have got my port to Ionic 4 planned, where I will probably re-add all my platforms but until then, does anyone know how I can fix this problem?

Thanks in advance

The suggestion here is to downgrade to the version 5.4.0. As of writing this, the current version of the plugin is 5.6.3 though. So it's not really a fix for me, it's a temporary workaround. But I tried it, and it seems to work.

5.4.0 is the last version that has the version hardcoded in plugin.xml:

<framework src="com.android.support:support-v4:24.1.1+" />

Later versions use a variable, which doesn't seem to get resolved when Cordova creates the build.gradle file for Android:

<framework src="com.android.support:support-v4:$ANDROID_SUPPORT_V4_VERSION" />
<preference name="ANDROID_SUPPORT_V4_VERSION" default="24.1.1+"/>

see diff: 5.4.0...5.4.4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM