android - Phonegap 构建 config.xml 和地理位置
问题描述
在 PhoneGap 构建中使用地理定位时,我遇到了一个非常奇怪的问题。我让它与我的 config.xml 一起工作,如下所示:
<?xml version='1.0' encoding='utf-8'?>
<widget id="net.seekadventure" version="0.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Seek Adventure Map</name>
<description>
A map to help you find your next Adventure!
</description>
<author email="myEmail" href="https://www.seekadventure.net">
Seek ADventure Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<preference name="permissions" value="none"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<plugin name="cordova-plugin-geolocation" spec="1" />
<icon src="icon.png" />
<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>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
关闭的部分是,当我安装它并在手机上打开它时,它会给我一个弹出窗口,上面写着:
“此应用是为旧版 Android 构建的,可能无法正常运行。请尝试检查更新,或联系开发人员”
因为我得到了那个错误,所以我做了一些研究并将它添加到我的 config.xml
<preference name="android-minSdkVersion" value="27" />
<preference name="android-maxSdkVersion" value="29" />
<preference name="android-targetSdkVersion" value="28" />
当我添加上面的代码时,它修复了关于在旧版本上构建但 GPS 权限不起作用的错误......有什么想法吗?
更新:
我还尝试为插件指定源和版本,但没有帮助:
<plugin name="cordova-plugin-geolocation" source="npm" spec="4.0.2" />
解决方案
我没有在我的 config/xml 中指定 CLI 版本,这是导致问题的原因:
<preference name="phonegap-version" value="cli-9.0.0" />
推荐阅读
- anylogic - 如何使用 Java 创建 shapetext
- node.js - 如何给APP获取连接权限?
- mongodb - 可以对只有少量文档的集合进行 COLLSCAN 吗?
- timestamp - 获取基板托盘范围内的系统时间
- node.js - Node JS - 如何在节点 JS 中使用 OAuth 1 流实现 GET 请求
- reactjs - 我的复选框没有从选中或取消选中更改,但我可以看到状态值正在更改,这是怎么回事?
- json - 当 JSON 作为响应发送但使用纯字符串时,Go 并发 TCP 服务器挂起
- python - 如何修复 ImportError: cannot import name 'classname' from 'filename.ipynb' (C:\Python397\lib\test\__init__.py)
- node.js - 如何在 Node.js 中发出 get 请求以查看集合在 MongoDB 中使用了多少字节?
- react-native - 页面更改后 React-native-popup-dialog 未关闭