cordova android avd 访问 apache 服务器 xampp config.xml 权限
cordova android avd access apache server xampp config.xml permission
我为 windows 安装了 XAMPP:
https://www.apachefriends.org/de/download.html
然后我为android设置了一个应用程序:
https://www.npmjs.com/package/vue-cli-plugin-cordova
一切正常。我可以从我的网络服务器获取数据:
然后我用Axios获取数据:
const baseUrl = 'http://10.0.2.2/lumen-api/public/api/'
const capacitiesUrl = `${baseUrl}maschinen`
return await Axios.request({
method: 'GET',
url: capacitiesUrl,
data: ''
})
之后我收到了一个 http-Error。它不起作用。
我试图为我的 config.xml-文件添加一些权限:
https://medium.com/the-web-tub/electron-on-cordova-29ede5d6d789
和
我现在的问题是,我应该在哪里为我的 android cordova-Application 添加一些权限?
我找不到正确的文件。它只是 config.xml 文件吗?
我的config.xml-文件:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.demo.app"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<!--<widget id="com.vue.example.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> -->
<name>Hallo Welt</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</config-file>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
这对我有用:
我的 config.xml 看起来像这样:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.demo.app"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>VueExampleAppName</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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="electron">
<preference name="ElectronSettingsFilePath" value="res/electron/settings.json" />
<icon src="res/icon/electron/foreground.png" />
</platform>
<platform name="android">
<allow-intent href="market:*" />
<icon background="res/icon/android/background.png" density="ldpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="mdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="hdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxxhdpi" foreground="res/icon/android/foreground.png" />
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
我为 windows 安装了 XAMPP:
https://www.apachefriends.org/de/download.html
然后我为android设置了一个应用程序:
https://www.npmjs.com/package/vue-cli-plugin-cordova
一切正常。我可以从我的网络服务器获取数据:
然后我用Axios获取数据:
const baseUrl = 'http://10.0.2.2/lumen-api/public/api/'
const capacitiesUrl = `${baseUrl}maschinen`
return await Axios.request({
method: 'GET',
url: capacitiesUrl,
data: ''
})
之后我收到了一个 http-Error。它不起作用。 我试图为我的 config.xml-文件添加一些权限:
https://medium.com/the-web-tub/electron-on-cordova-29ede5d6d789
和
我现在的问题是,我应该在哪里为我的 android cordova-Application 添加一些权限? 我找不到正确的文件。它只是 config.xml 文件吗?
我的config.xml-文件:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.demo.app"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<!--<widget id="com.vue.example.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> -->
<name>Hallo Welt</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</config-file>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
这对我有用:
我的 config.xml 看起来像这样:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.demo.app"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>VueExampleAppName</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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="electron">
<preference name="ElectronSettingsFilePath" value="res/electron/settings.json" />
<icon src="res/icon/electron/foreground.png" />
</platform>
<platform name="android">
<allow-intent href="market:*" />
<icon background="res/icon/android/background.png" density="ldpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="mdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="hdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxxhdpi" foreground="res/icon/android/foreground.png" />
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>