Closed JavierCane closed 8 years ago
EDIT: You can already merge this pull request. See the next comment for the explanation :)
DON'T MERGE THIS PR.
Sorry but this PR isn't complete. I thought it was a simple typo but now I'm facing some problems.
Setting the config.xml
to the specified parent value in the PR ("/"
):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.xxx.yyy" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/">
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
</config-file>
</platform>
</widget>
The ionic build --release android --info
command execution gives the error: net.js:633 throw new TypeError('invalid data');
And trying to fix it with the "/*"
value in the config.xml
like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.xxx.yyy" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
</config-file>
</platform>
</widget>
The ionic build --release android --info
command execution gives the error: platforms/android/build/intermediates/res/release/xml/config.xml:27: error: Error parsing XML: unbound prefix
And at this xml line I have the uses-permissions statement:
<config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
</config-file>
I've been searching for the solution to this error and some people recommend to "clean the project" in the Eclipse IDE. But I don't know how to proceed dealing with an ionic/cordova app.
I though it provably was due to the android XML namespace, so I tried with:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.uvinum.mobileapp" version="2.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android">
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
</config-file>
</platform>
</widget>
But the it gave me errors like:
platforms/android/AndroidManifest.xml:4: Error: The <supports-screens> element must be a direct child of the <manifest> root element [WrongManifestParent]
<supports-screens android:largeScreens="false" android:smallScreens="false" android:xlargeScreens="false" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~platforms/android/AndroidManifest.xml:5: Error: The <uses-permission> element must be a direct child of the <manifest> root element [WrongManifestParent]
<uses-permission android:maxSdkVersion="15" android:name="android.permission.READ_CONTACTS" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
platforms/android/AndroidManifest.xml:6: Error: The <uses-permission> element must be a direct child of the <manifest> root element [WrongManifestParent]
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "WrongManifestParent":
The <uses-library> element should be defined as a direct child of the
<application> tag, not the <manifest> tag or an <activity> tag. Similarly,
a <uses-sdk> tag much be declared at the root level, and so on. This check
looks for incorrect declaration locations in the manifest, and complains if
an element is found in the wrong place.
http://developer.android.com/guide/topics/manifest/manifest-intro.html
So I guess I should put a value in the parent
attribute of the config-file
tag which make some reference to the application
tag, but I don't really know which is the exact proper value.
Sorry for the confusion with the PR and thanks for your help. I hope solving this issue could help future cases who, like me, copy&paste the documentation example.
Sorry for the confusion. I've finally managed it :)
I didn't notice that after running an ionic build --release android
, the script will append the configuration statements specified in the config.xml
and, at the moment of removing those statements form the config.xml
and executing another ionic build
command, the script will NOT remove the previous statements from the AndroidManifest.xml
.
So, finally, I've had only to:
AndroidManifest.xml
widget
tagionic build
In conclusion: You can merge this pull request :)
fix(hooks): fix for update_platform_config.js documentation example
Fix for the example included in the update_platform_config after prepare hook documentation not properly closing the config-file XML tag.