Phonegap-plugin-barcodescanner: Cordova build fails since Android released support library 28.0.0-alpha1

Created on 8 Mar 2018  路  15Comments  路  Source: phonegap/phonegap-plugin-barcodescanner

Expected Behaviour

Successful compile

Actual Behaviour

failed compile with the following error:
ERROR: In FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In FontFamilyFont, unable to find attribute android:ttcIndex

Reproduce Scenario (including but not limited to)

Steps to Reproduce

cordova plugin add phonegap-plugin-barcodescanner
cordova build android

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

N/A - Build problem

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

N/A - Build problem

Cordova CLI version and cordova platform version

Cordova 7.1.0
cordova-android-6.3.0

Plugin version

7.0.2

Problem is caused by the following file: src/android/barcodescanner.gradle
Line:

compile 'com.android.support:support-v4:+'

During the build process, this overrides all other dependencies and grabs the latest library. Unfortunately, at the moment, that means it pulls an pre-release alpha version - 28.0.0 alpha 1. This version does not work. If I change the above line to:

compile 'com.android.support:support-v4:24.1.1+'

build work again. I used 24.1.1+ as that's the same version used by recent versions of cordova-plugin-camera, and the version supported by the platform I'm using. Ultimately, choosing just 'v4:+' breaks builds right now.

bug

Most helpful comment

I fixed with cordova-android-support-gradle-release just like @ippeiukai said!

cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=24.+

All 15 comments

This problem also broke my build.
It works with the fix @bozzaj proposed.

I added the lines

sed -i.bak s/com.android.support:support-v4:+/com.android.support:support-v4:24.1.1+/g plugins/phonegap-plugin-barcodescanner/src/android/barcodescanner.gradle
sed -i.bak s/com.android.support:support-v4:+/com.android.support:support-v4:24.1.1+/g platforms/android/phonegap-plugin-barcodescanner/myshipments-barcodescanner.gradle

to my custom build script to apply that fix automatically.

Just to let everyone know: we have ended up using cordova-android-support-gradle-release plugin to specify the android support lib version in config.xml. Hope this helps.

Somedays I really hate how Google pulls in dependencies using Gradle. There is no way it should grab an alpha unless you specify it.

still same ... ;(

Thanks @bozzaj !! Not to forget:

ionic cordova platform rm android
ionic cordova platform add android

Sill same I tired https://github.com/dpa99c/cordova-android-support-gradle-release too but got Unable to merge dex error. Changing to compile 'com.android.support:support-v4:24.1.1+' from compile 'com.android.support:support-v4:+' in plugin also didn't help.

I fixed with cordova-android-support-gradle-release just like @ippeiukai said!

cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=24.+

before build
Change in project.property

cordova.system.library.4=com.android.support:support-v4:+
to
cordova.system.library.4=com.android.support:support-v4:25.3.1
Also try to edit plugin barcode /plugins/phonegap-plugin-barcodescanner/src/android/barcodescanner.gradle

com.android.support:support-v4:25.3.1

Fixed in https://github.com/phonegap/phonegap-plugin-barcodescanner/pull/621, now you can configure the version to use with a config.xml preference and will use 27.+ as default

published a 7.0.3 with the fix

I've updated to 7.0.3 to try and fix this issue, but now I'm getting this error:

2018-03-13T11:55:30.1659800Z Build file '/Users/xxx/agent/_work/r3/a/xxx/xxx/cordova/xxx/platforms/android/build.gradle' line: 261
2018-03-13T11:55:30.1667550Z
2018-03-13T11:55:30.1679170Z * What went wrong:
2018-03-13T11:55:30.1695600Z A problem occurred evaluating root project 'android'.
2018-03-13T11:55:30.1711390Z > Could not get unknown property 'ANDROID_SUPPORT_V4_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
2018-03-13T11:55:30.1720830Z

I have this in my config.xml:

 <plugin name="phonegap-plugin-barcodescanner" spec="~7.0.3">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="To scan QR Codes" />
        <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
    </plugin>

And this in my package.json "plugins"::
"phonegap-plugin-barcodescanner": { "ANDROID_SUPPORT_V4_VERSION": "27.+" }

Cordova version: 6.5.0
Cordova-android version: 6.4.0.

Any ideas what could be preventing this from working?

In reply to my own question, it appears that it was failing because cordova-cli 6.5.0 does not support parameters in the plugin.xml framework tag (such as $ANDROID_SUPPORT_V4_VERSION used in the fix above).

Upgrading to cordova-cli 7.1.0 has fixed it for me.

Just released a new version of the plugin (7.1.0) that requires CLI 7.1.0 to work

My god, every time I look away for a few weeks, cordova-android builds break in a million different ways. I hate gradle with a burning passion.

This thread has been automatically locked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JackRo picture JackRo  路  6Comments

ishanjain2801 picture ishanjain2801  路  3Comments

brunovinny picture brunovinny  路  6Comments

justinhenricks picture justinhenricks  路  5Comments

HallmediaDigital picture HallmediaDigital  路  4Comments