I am having problems to edit config.xml

  • 1
  • Problem
  • Updated 5 years ago
  • Not a Problem
Hello!

I am trying to make things work in CLI 5.2, but I am having problems.
People said my config.xml is a mess, but I have no idea how to fix it:

-----


<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foryounetwork.foryougran" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<gap:config-file parent="/manifest" platform="android">
<application android:debuggable="true" />
</gap:config-file>
<name> sdsdsds </name>
<description> dsds </description>

<content src="index.html" />
<preference name="permissions" value="none" />
<feature name="http://api.phonegap.com/1.0/battery" />
<feature name="http://api.phonegap.com/1.0/camera" />
<feature name="http://api.phonegap.com/1.0/contacts" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/geolocation" />
<feature name="http://api.phonegap.com/1.0/media" />
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/notification" />
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
</feature>
<plugin name="Storage" value="org.apache.cordova.Storage" />

<preference name="android-minSdkVersion" value="10" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="SplashScreenDelay" value="30000" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="org.apache.cordova.battery-status" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.console" />
<gap:plugin name="org.apache.cordova.contacts" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.device-motion" />
<gap:plugin name="org.apache.cordova.device-orientation" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.globalization" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.network-information" />
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
<param name="ios-package" value="CDVConnection" />
</feature>
<gap:plugin name="org.apache.cordova.splashscreen" />
<gap:plugin name="org.apache.cordova.vibration" />
<icon src="icon.png" />
<icon gap:platform="android" gap:qualifier="ldpi" src="res/icon/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="res/icon/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="res/icon/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" version="1.0.0" />
<engine name="android" spec="~4.1.1" />
</widget>


Photo of Henrique Kieckbusch

Henrique Kieckbusch

  • 4 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
If you do use PhoneGap Build service to compile the project then stat reading this:
http://docs.build.phonegap.com/en_US/configuring_basics.md.html#The%20Basics

** Note:
- Remove unwanted tags which is not specified in the above documentation
- Add all tags which is required from the above documentation

Cheers


Photo of Henrique Kieckbusch

Henrique Kieckbusch

  • 4 Posts
  • 0 Reply Likes
Thanks amir..

I changed to this config.xml, and I am using build.phonegap but it still doesnt allow me to use $.post to external links. (using the phonegap app with desktop serving works perfect, just after make .apk that whitelist or something.. doesnt allow to connect to external links).

The config.xml after read the whole link you sent, is this:



<?xml version='1.0' encoding='utf-8'?>

<widget id="com.foryounetwork.foryougran" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

<name> name </name>
<description> desc </description>

<author email="mymail" href="link"> name </author>
<content src="index.html" />

<preference name='phonegap-version' value='cli-5.2.0' />

<plugin name='cordova-plugin-whitelist' spec='1.0.0' source='npm' />
<plugin name='cordova-plugin-splashscreen' spec='2.1.0' source='npm' />
<plugin name='cordova-plugin-media' spec='1.0.1' source='npm' />
<plugin name='cordova-plugin-file' spec='3.0.0' source='npm' />
<plugin name="cordova-plugin-crosswalk-webview" spec="1.3.0" source='npm' />

<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:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>

<allow-navigation href="*" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="5000" />
<preference name="AutoHideSplashScreen" value="false" />
<icon src="icon.png" />

</widget>




Whats wrong? Why $.post doesnt work for external links yet?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. You can't use a 'plugin' element. Use 'gap:plugin' and remove the 'spec' attribute. See the PGB Plugins section

2. You don't have any splashes, which will result in wrong scaling on iOS

3. If you don't have an image 'screen.png', remove
<preference name="SplashScreen" value="screen" />

4. You can't use a 'platform' element. Remove.
Photo of Henrique Kieckbusch

Henrique Kieckbusch

  • 4 Posts
  • 0 Reply Likes
Hello Petra, thank you!

But it still not working. Ajax $.post to external website still doesnt work:

Xml right now:



<?xml version='1.0' encoding='utf-8'?>

<widget id="com.foryounetwork.foryougran" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name> name </name>
<description> desc </description>
<author email="mymail" href="link"> name </author>
<content src="index.html" />
<preference name='phonegap-version' value='cli-5.2.0' />

<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<gap:plugin name='cordova-plugin-splashscreen' source='npm' />
<gap:plugin name='cordova-plugin-media' source='npm' />
<gap:plugin name='cordova-plugin-file' source='npm' />
<gap:plugin name="cordova-plugin-crosswalk-webview" source='npm' />

<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:*" />

<allow-navigation href="*" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />

<icon src="icon.png" />

</widget>


Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. Are you sure your config.xml is found, read and parsed?
(You could check by setting a different version attribute for the widget element and by finding your plugins in the plugins tab of your app's PGB page)

2. How, specifically, does your ajax call "not work"? Is any callback function called? What is the error message you receive? What is the http return code?
Photo of Henrique Kieckbusch

Henrique Kieckbusch

  • 4 Posts
  • 0 Reply Likes
It says there is no plugin used, it means it is not finding my config.xml?
It is in the root folder.



The Ajax is like this:

$.post('https://www.. site here',{
login : login,
pass : pass
} , function(a){
eval(a);
});


It just doesn't give any message. Using the PhoneGap app to test. it works fine.

I also put to test: .fail(function(){ alert('fail'); }); And it is called in .apk version.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. The Phonegap app needs a Cordova project, which has a different config.xml. You can't mix local build (Phonegap) with cloud build (Phonegap Build).

2. If your config isn't found, most likely causes are:
- config's XML is not well-formed (doesn't validate)
- config.xml and index.html aren't both in the root ("/") of your zip upload file.
- those filed are not named 'config.xml' and 'index.html'
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes