Could not get unknown property 'ANDROID_SUPPORT_V4_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

With some automatic updates my app will no longer compile for android, always erroring out with the error:

* 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.

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

BUILD FAILED

I’ve tried upgrading/downgrading cordova and plugins and cordova-android, and adding the cordova-android-support-gradle-release plugin with the variable specified based on various google searches all to no avail. Anyone have any idea what’s going on and how to make it work?

Ionic Info:

cli packages: (/Users/mbeckett/.nvm/versions/node/v6.9.1/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.0.2
    ios-deploy        : 1.9.2
    Node              : v6.9.1
    npm               : 3.10.8
    OS                : macOS High Sierra
    Xcode             : Xcode 9.4 Build version 9F1027a

Environment Variables:

    ANDROID_HOME : /Users/mbeckett/Library/Android/sdk

Misc:

    backend : legacy

I’m still not able to get past this, any insights from anyone?

// upgrade cordova itself
$> npm -g install cordova

// Reinstall the maps plugin
$> cordova plugin rm cordova-plugin-googlemaps

$> cordova plugin add cordova-plugin-googlemaps --variable ...

As I said in the other thread - cordova is up to date (and I have tried various versions), and I’m NOT using the google maps plugin

ionic cordova plugin list
> cordova plugin ls
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-http 1.2.0 "SSL Pinning"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-speechrecognition 1.1.2 "Speech Recognition"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-tts 0.2.3 "TTS"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 2.3.2 "Cordova sqlite storage plugin"
cordova_app_version_plugin 0.2.6 "getAppVersion"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"

I believe there is no plugin that use variable ANDROID_SUPPORT_V4_VERSION than cordova-plugin-googlemaps.

Anyway, you need to modify platform/platforms/build.gradle file by yourself.

I have same problem. did you get any solution?

In my case it was the barcode scanner plugin that needed to be upgraded. A whole bunch of dependencies got upgraded at the time so I don’t remember all the specifics

Could not get unknown property ‘ANDROID_SUPPORT_ANNOTATIONS_VERSION’ for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

That’s happen to me after I am installed google maps geolocation, but before it, I dowgrade the version of cordova because cordova pluging add cordova-plugin-geolocation was not working. After that I installed again the las version of cordova and I tried to do ionic cordova run android and got this error…

What do you mean here, what I need to modify in my build.gradle? I already added again android platform with the last version of cordova.

it’s my package.json
"cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" },

This can be fix by open plaforms/android/project.properties, then change line
cordova.system.library.3=$ANDROID_SUPPORT_V4_VERSION+
to
cordova.system.library.3=com.android.support:support-v4:24.1.1+

Then run re build android
Hope it helps
Best Regards

1 Like

these should be the properties to resolve most such gradle build issue:

target=android-27

android.library.reference.1=CordovaLib

android.library.reference.2=app

cordova.system.library.1=com.google.android.gms:play-services-base:9.2.1

cordova.system.library.2=com.google.android.gms:play-services-ads:9.2.1

cordova.system.library.3=com.android.support:support-v4:24.1.1+

I have a similar problem after updating the cordova-plugin-x-socialsharing plugin.

I now have the following in the config.xml file

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

And now when I try to build Android (haven’t even tried iOS yet) I get

* 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.

Looking at the last two comments above, it is suggested to edit platforms/android/project.properties, but at the top of this file, it says any edits will be overwritten…

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#

My contents of platforms/android/project.properties, are

target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:$ANDROID_SUPPORT_V4_VERSION

I removed, readded Android platform a few time, but not difference

I did try adding the following
cordova.system.library.1=com.android.support:support-v4:24.1.1+

since I only had library.11 and notlibrary.1`, but now I am getting other build errors.

I now get

:compileReleaseSources
[Fatal Error] :3:214: The value of attribute "name" associated with an element type "item" must not contain the '<' character.
Could not read C:\Users\pchapman\AppData\Local\Android\sdk\platform-tools\api\annotations.zip
java.io.IOException: Could not parse XML from android/accounts/annotations.xml

Not sure if this is related! But now can just not build Android, just because I wanted to update a plugin.

Really not sure what this ANDROID_SUPPORT_V4_VERSION is all about?

So, none of the above has worked for me if any other suggestions??

is there not any solutions yet?

I updated my Ionic and everything to the latest, version to 4 at the time, and it was resolved.