【问题标题】:Ionic App - No Internet Access离子应用程序 - 没有互联网访问
【发布时间】:2016-06-03 00:58:57
【问题描述】:

我用 ionic 和 Phonegap 构建了一个小型移动 Android 6 应用。这不是我的第一个 Hybrid 应用程序,而是我第一个使用 Ionic 的应用程序。该应用程序调用一个查询 MySQL 数据库并将一些信息返回到视图的 php 文件。该应用程序可根据需要在线和本地运行,但在我通过 PhoneGap 构建后无法访问互联网。没有加载我的样式以及从 PHP 调用返回的信息。我已经通过 PhoneGap 发布了该应用程序,并通过三星 Galaxy 5 进行了测试;我在 Mac 上开发了所有东西。

我根据需要安装了 Cordova 白名单插件,并为清单添加了必要的权限,但我需要另一双眼睛来查看它。

这是我的 config.xml 文件:

config.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testrest902325" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>NAME</name>
  <description>
       DESCRIPTION
    </description>
  <author email="name@name.edu" href="http://example.com.com/">
    </author>
  <content src="index.html"/>
<access origin="*"/>
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>
  </feature>
</widget>

这是我的 AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.testrest902325" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
</manifest>

【问题讨论】:

  • 您是否尝试过从 config.xml 文件设置权限?尽可能尝试:
  • @DataGuy Phonegap 不是webserver or a webbrowser。您的资产(html、css、javascript 等)在哪里?他们在线还是在设备上? 请在你的帖子中回答这个问题
  • @DataGuy 同样,您不需要对 AndroidManifest.xml 进行更改或修复(特殊情况除外)。请在您的帖子中回答以下问题。因为这似乎是你关于这个主题的第一篇文章。这是您的第一个混合应用程序吗?您的目标平台及其目标版本是什么:Android 4、5、6? iOS 7、8、9?你在什么平台上开发?视窗,MacOS?一旦您回答了帖子中的问题,请在 cmets 中回复,以便我知道您已在帖子中添加信息。
  • 您要求的所有内容都已添加到帖子中。谢谢
  • @DataGuy 当您回复时,您需要在回复中使用我的句柄,否则我看不到它。像这样@jessemonroy650

标签: android cordova


【解决方案1】:

我有非常相似的问题;即使安装了白名单插件并获得了必要的权限,我的应用也从未连接到我的网络服务。

然后我想尝试在 config.xml 中包含白名单插件。因此,在我的项目文件夹中,我运行了以下命令,该命令更新了我的 config.xml

cordova plugin add cordova-plugin-whitelist --save

之后,我的自动构建系统生成的 APK 连接到我的网络服务。

【讨论】:

  • 感谢 Chandru,它对我有用,顺便说一句,我必须删除 android 平台,然后在构建之前再次添加。
猜你喜欢
  • 2017-03-30
  • 2014-10-18
  • 1970-01-01
  • 2018-08-28
  • 1970-01-01
  • 2018-04-24
  • 1970-01-01
  • 1970-01-01
  • 2014-11-01
相关资源
最近更新 更多