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

Android build failed for cordova-plugin-file-opener2 giving Error - A plugin you are using requires a preference: ANDROID_SUPPORT_V4_VERSION #238

Closed
umeshShindepatil opened this issue Dec 13, 2018 · 16 comments

Comments

@umeshShindepatil
Copy link

Android build failed for cordova-plugin-file-opener2 giving Error - A plugin you are using requires a preference: ANDROID_SUPPORT_V4_VERSION

Hi
Getting error for android build - Error - A plugin you are using requires a preference: ANDROID_SUPPORT_V4_VERSION.

below code is in my config -
<gap:plugin name="cordova-plugin-file-opener2" source="npm">

plz help.
Thanks!

@fer1994
Copy link

fer1994 commented Dec 13, 2018

i have the same problem, any have a solution ?

@shnist
Copy link
Collaborator

shnist commented Dec 13, 2018

hi @umeshShindepatil, thanks for raising this issue. Looks like you're using Phonegap Build?

My first recommendation would be to make sure you specify a particular version of the plugin so any future changes (to any of your plugins) don't cause you any problems in your project. e.g.
<gap:plugin name="cordova-plugin-file-opener2" source="npm" spec="2.1.0">

Interesting that phonegap is requiring you to specify a value for ANDROID_SUPPORT_V4_VERSION. I thought this should be optional, but I don't know enough about phonegap build to understand why this is not the case. Try this fix in your config:

<gap:plugin name="cordova-plugin-file-opener2" source="npm" spec="2.1.0">
    <param name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</gap:plugin>

You might find this documentation useful. http://docs.phonegap.com/phonegap-build/configuring/plugins/#plugin-params

If that fixes your issue I'll update the README to help other users who see the same issue.

@fer1994
Copy link

fer1994 commented Dec 13, 2018

I have this line in config.xml and dont work.

<plugin name="cordova-plugin-file-opener2" spec="^2.1.0">
     <variablename="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>

@shnist
Copy link
Collaborator

shnist commented Dec 13, 2018

hi @fer1994 , how are you building your project? With phonegap build? Or just on the command line?

@fer1994
Copy link

fer1994 commented Dec 14, 2018

I build in command line, thats is the problem. I cant change manually the build.gradle

@shnist
Copy link
Collaborator

shnist commented Dec 14, 2018

Hi @fer1994, if you could send me some more information about your project that would help me understand the issue you are having. Firstly can you show me the output of running this command in your project:

cordova info

and if you can also tell me what cordova command you are using when trying to build the app and the exact error that is being outputted that would be great.

@fer1994
Copy link

fer1994 commented Dec 14, 2018

Yes y put here the cordova info.

Node Version: 6.9.2
Cordova version 6.5.0
Android SDK: 26 - 27

CONFIG.XML (I delete the headers)

<?xml version='1.0' encoding='utf-8'?>
<widget
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="orientation" value="portrait" />
    <preference name="AutoHideSplashScreen" value="true" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenSpinnerColor" value="white" />
    <platform name="android">
        <allow-intent href="market:*" />
        <resource-file src="google-services.json" target="app/google-services.js                                                                                                    on" />
        <icon src="res/icon/android/icon-192.png" />
        <splash src="res/splash/android/splash.png" />
        <preference name="loadUrlTimeoutValue" value="700000" />
        <preference name="disallowOverscroll" value="true" />
        <preference name="webviewbounce" value="false" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <resource-file src="GoogleService-Info.plist" />
        <icon src="res/icon/ios/icon-180.png" />
        <splash height="480" src="res/splash/ios/splash-iphone.png" width="320"                                                                                                     />
        <splash height="960" src="res/splash/ios/splash-iphone2x.png" width="640                                                                                                    " />
        <splash height="1136" src="res/splash/ios/splash-568h2x.png" width="640"                                                                                                     />
        <splash height="1334" src="res/splash/ios/splash-667h.png" width="752" /                                                                                                    >
        <splash height="1334" src="res/splash/ios/splash-667h.png" width="750" /                                                                                                    >
        <splash height="2208" src="res/splash/ios/splash-736h.png" width="1242"                                                                                                     />
        <splash height="1920" src="res/splash/ios/splash-736h.png" width="1080"                                                                                                     />
        <splash height="2048" src="res/splash/ios/splash-ipad2x.png" width="1536                                                                                                    " />
        <splash height="1024" src="res/splash/ios/splash-ipad.png" width="768" /                                                                                                    >
        <preference name="DisallowOverscroll" value="true" />
        <preference name="WebViewBounce" value="false" />
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="StatusBarBackgroundColor" value="#ffffff" />
        <preference name="StatusBarStyle" value="default" />
        <preference name="KeyboardShrinksView " value="true" />
        <preference name="deployment-target" value="8.1" />
        <icon src="res/icon/ios/icon-57.png" />
    </platform>
    <engine name="ios" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-keyboard" spec="^1.2.0" />
    <plugin name="cordova-plugin-camera-preview" spec="^0.10.0" />
    <plugin name="cordova-plugin-advanced-http" spec="^2.0.2" />
    <plugin name="cordova-android-support-gradle-release" spec="^2.0.1">
        <variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
    </plugin>
    <plugin name="cordova-plugin-firebase" spec="^2.0.5" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-device" spec="^2.0.2" />
    <plugin name="cordova-plugin-appversion" spec="^1.0.0" />
    <plugin name="cordova-sqlcipher-adapter" spec="^0.1.12-rc2" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />
    <plugin name="cordova-plugin-file" spec="^6.0.1" />
    <plugin name="cordova-plugin-file-opener2" spec="^2.1.0" />
    <engine name="android" spec="^7.0.0" />
</widget>

@umeshShindepatil
Copy link
Author

umeshShindepatil commented Dec 14, 2018

Hi All,
Thanks for the reply,
It's worked for me remove and add plugin in config xml.

removed - <gap:plugin name="cordova-plugin-file-opener2" source="npm" />
add - "<plugin spec="https://github.com/neptsoft/cordova-plugin-file-opener2" source="git" />"

thanks!

@shnist
Copy link
Collaborator

shnist commented Dec 14, 2018

@umeshShindepatil glad you solved your issue. @fer1994 can you send me a copy of the exact error you are getting.

@shnist
Copy link
Collaborator

shnist commented Dec 14, 2018

@fer1994 i believe I have found the root cause of the issue phonegap/phonegap-plugin-barcodescanner#616 (comment).

Looks like Cordova 6 does not support the fix for the android support version build issue (#234).

If you can, try upgrading your Cordova CLI to at least version 7 npm i cordova@latest -g. That should hopefully resolve your issue. I'll also update the README

@fer1994
Copy link

fer1994 commented Dec 17, 2018

Hi, the exactly problem is this.
image

@fer1994 i believe I have found the root cause of the issue phonegap/phonegap-plugin-barcodescanner#616 (comment).

Looks like Cordova 6 does not support the fix for the android support version build issue (#234).

If you can, try upgrading your Cordova CLI to at least version 7 npm i cordova@latest -g. That should hopefully resolve your issue. I'll also update the README

I dont use this plugin and i try update the cordova cli and the problem prevails

@shnist
Copy link
Collaborator

shnist commented Dec 17, 2018

hi @fer1994, the link to the issue was just a reference to what I believed the issue to be. Can you run cordova info again and show me the output.

@fer1994
Copy link

fer1994 commented Dec 17, 2018

Node version: v6.9.2

Cordova version: 8.1.1

Config.xml file: 

<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="24"  ios-CFBundleVersion="24" version="1.0.15" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name></name>
    <description></description>
    <author></author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="orientation" value="portrait" />
    <preference name="AutoHideSplashScreen" value="true" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenSpinnerColor" value="white" />
    <preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
    <platform name="android">
        <allow-intent href="market:*" />
        <resource-file src="google-services.json" target="app/google-services.json" />
        <icon src="res/icon/android/icon-192.png" />
        <splash src="res/splash/android/splash.png" />
        <preference name="loadUrlTimeoutValue" value="700000" />
        <preference name="disallowOverscroll" value="true" />
        <preference name="webviewbounce" value="false" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon src="res/icon/ios/icon-180.png" />
        <splash height="480" src="res/splash/ios/splash-iphone.png" width="320" />
        <splash height="960" src="res/splash/ios/splash-iphone2x.png" width="640" />
        <splash height="1136" src="res/splash/ios/splash-568h2x.png" width="640" />
        <splash height="1334" src="res/splash/ios/splash-667h.png" width="752" />
        <splash height="1334" src="res/splash/ios/splash-667h.png" width="750" />
        <splash height="2208" src="res/splash/ios/splash-736h.png" width="1242" />
        <splash height="1920" src="res/splash/ios/splash-736h.png" width="1080" />
        <splash height="2048" src="res/splash/ios/splash-ipad2x.png" width="1536" />
        <splash height="1024" src="res/splash/ios/splash-ipad.png" width="768" />
        <preference name="DisallowOverscroll" value="true" />
        <preference name="WebViewBounce" value="false" />
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="StatusBarBackgroundColor" value="#ffffff" />
        <preference name="StatusBarStyle" value="default" />
        <preference name="KeyboardShrinksView " value="true" />
        <preference name="deployment-target" value="8.1" />
        <icon src="res/icon/ios/icon-57.png" />
    </platform>
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>
    <plugin name="cordova-plugin-firebase" spec="^2.0.5" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-keyboard" spec="^1.2.0" />
    <plugin name="cordova-plugin-camera-preview" spec="^0.10.0" />
    <plugin name="cordova-plugin-advanced-http" spec="^2.0.1" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-device" spec="^2.0.2" />
    <plugin name="cordova-plugin-appversion" spec="^1.0.0" />
    <plugin name="cordova-sqlcipher-adapter" spec="^0.1.12-rc2" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />
    <plugin name="cordova-plugin-file" spec="^6.0.1" />
    <plugin name="cordova-android-support-gradle-release" spec="^2.0.1">
        <variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
    </plugin>
    <plugin name="cordova-plugin-file-opener2" spec="~2.1.0">
        <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
    </plugin>
    <engine name="android" spec="^7.1.4" />
    <engine name="ios" spec="^4.5.5" />
</widget>

@shnist
Copy link
Collaborator

shnist commented Dec 17, 2018

@fer1994 try removing the platforms and plugins folders and try building it again.

If that doesn't work, downgrade to 2.0.19:
cordova plugin rm cordova-plugin-file-opener2 and cordova plugin add cordova-plugin-file-opener2@2.0.19

@fer1994
Copy link

fer1994 commented Dec 17, 2018

I update the GRADLE and it work!

@shnist
Copy link
Collaborator

shnist commented Dec 17, 2018

great! glad it's working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants