Phonegap 构建配置.xml和地理位置



我在PhoneGap构建中使用地理位置时遇到了一个非常奇怪的问题。我让它与我的配置一起工作.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构建的,可能无法正常工作。尝试检查更新,或联系开发人员">

由于我遇到了这个错误,我做了一些研究并将其添加到我的配置中.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" />

我没有在我的配置/xml中指定CLI版本,这是导致问题的原因:

<preference name="phonegap-version" value="cli-9.0.0" />

最新更新