Flutter应用程序不从WordPress网站获取主页数据?

icomxhvb  于 2023-04-22  发布在  Flutter
关注(0)|答案(1)|浏览(98)

我在一个新闻应用程序项目工作,需要获取和显示数据,从网站上,只要它得到任何新的职位更新到任何类别在那里列出。
我已经建立了应用程序没有问题或警告,但仍然当我打开应用程序在移动终端上它只是加载,没有显示只有一个类别正在获取和休息的所有类别显示,但数据不显示在应用程序内,也没有给出任何错误,有人能告诉我这里出了什么问题吗???
我已经在下面添加了build gradle…

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.*****.news"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        signingConfig signingConfigs.release
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
           debuggable true
           renderscriptDebuggable true
           jniDebuggable true
           minifyEnabled true
       }
   }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    dependenciesInfo {
        includeInApk true
        includeInBundle true
    }
    buildToolsVersion '32.0.0'
    ndkVersion '24.0.8215888'
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services'
[
  {
    "repositoryUrl": "https://packages.jetbrains.team/maven/p/ij/intellij-redist",
    "artifacts": [
      {
        "groupId": "junit",
        "artifactId": "junit",
        "annotations": {
          "[4.0, 5.0)": {
            "groupId": "org.jetbrains.externalAnnotations.junit",
            "artifactId": "junit",
            "version": "4.12-an1"
          }
        }
      },
      {
        "groupId": "org.hamcrest",
        "artifactId": "hamcrest-core",
        "annotations": {
          "[1.0, 1.3)": {
            "groupId": "org.jetbrains.externalAnnotations.org.hamcrest",
            "artifactId": "hamcrest-core",
            "version": "1.3-an1"
          }
        }
      },
      {
        "groupId": "com.fasterxml.jackson.core",
        "artifactId": "jackson-core",
        "annotations": {
          "[2.0, 3.0)": {
            "groupId": "org.jetbrains.externalAnnotations.com.fasterxml.jackson.core",
            "artifactId": "jackson-core",
            "version": "2.9.6-an1"
          }
        }
      },
      {
        "groupId": "com.fasterxml.jackson.core",
        "artifactId": "jackson-databind",
        "annotations": {
          "[2.0, 3.0)": {
            "groupId": "org.jetbrains.externalAnnotations.com.fasterxml.jackson.core",
            "artifactId": "jackson-databind",
            "version": "2.9.6-an1"
          }
        }
      },
      {
        "groupId": "com.miglayout",
        "artifactId": "miglayout-swing",
        "annotations": {
          "[5.0, 5.1]": {
            "groupId": "org.jetbrains.externalAnnotations.com.miglayout",
            "artifactId": "miglayout-swing",
            "version": "5.1-an1"
          }
        }
      },
      {
        "groupId": "io.netty",
        "artifactId": "netty-buffer",
        "annotations": {
          "[4.0, 4.2)": {
            "groupId": "org.jetbrains.externalAnnotations.io.netty",
            "artifactId": "netty-buffer",
            "version": "4.1.27.Final-an1"
          }
        }
      },
      {
        "groupId": "io.netty",
        "artifactId": "netty-common",
        "annotations": {
          "[4.0, 4.2)": {
            "groupId": "org.jetbrains.externalAnnotations.io.netty",
            "artifactId": "netty-common",
            "version": "4.1.27.Final-an1"
          }
        }
      },
      {
        "groupId": "io.netty",
        "artifactId": "netty-resolver",
        "annotations": {
          "[4.0, 4.2)": {
            "groupId": "org.jetbrains.externalAnnotations.io.netty",
            "artifactId": "netty-resolver",
            "version": "4.1.27.Final-an1"
          }
        }
      },
      {
        "groupId": "io.netty",
        "artifactId": "netty-transport",
        "annotations": {
          "[4.0, 4.2)": {
            "groupId": "org.jetbrains.externalAnnotations.io.netty",
            "artifactId": "netty-transport",
            "version": "4.1.27.Final-an1"
          }
        }
      },
      {
        "groupId": "org.picocontainer",
        "artifactId": "picocontainer",
        "annotations": {
          "[1.0, 1.2]": {
            "groupId": "org.jetbrains.externalAnnotations.org.picocontainer",
            "artifactId": "picocontainer",
            "version": "1.2-an1"
          }
        }
      },
      {
        "groupId": "org.yaml",
        "artifactId": "snakeyaml",
        "annotations": {
          "[1.20, 1.3)": {
            "groupId": "org.jetbrains.externalAnnotations.org.yaml",
            "artifactId": "snakeyaml",
            "version": "1.23-an1"
          }
        }
      }
    ]
  }
]
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
 * Generated file. Do not edit.
 * This file is generated by the Flutter tool based on the
 * plugins that support the Android platform.
 */
@Keep
public final class GeneratedPluginRegistrant {
  private static final String TAG = "GeneratedPluginRegistrant";
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    try {
      flutterEngine.getPlugins().add(new com.jhomlala.better_player.BetterPlayerPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin better_player, com.jhomlala.better_player.BetterPlayerPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.analytics.FlutterFirebaseAnalyticsPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin firebase_analytics, io.flutter.plugins.firebase.analytics.FlutterFirebaseAnalyticsPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin firebase_core, io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin firebase_messaging, io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin flutter_inappwebview, com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new dev.vbonnet.flutterwebbrowser.FlutterWebBrowserPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin flutter_web_browser, dev.vbonnet.flutterwebbrowser.FlutterWebBrowserPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin fluttertoast, io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin google_mobile_ads, io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new com.iyaffle.launchreview.LaunchReviewPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin launch_review, com.iyaffle.launchreview.LaunchReviewPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.packageinfo.PackageInfoPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin package_info, io.flutter.plugins.packageinfo.PackageInfoPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.share.SharePlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin share, io.flutter.plugins.share.SharePlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin shared_preferences_android, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin url_launcher_android, io.flutter.plugins.urllauncher.UrlLauncherPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.videoplayer.VideoPlayerPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin video_player_android, io.flutter.plugins.videoplayer.VideoPlayerPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new creativemaybeno.wakelock.WakelockPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin wakelock, creativemaybeno.wakelock.WakelockPlugin", e);
    }
    try {
      flutterEngine.getPlugins().add(new io.flutter.plugins.webviewflutter.WebViewFlutterPlugin());
    } catch(Exception e) {
      Log.e(TAG, "Error registering plugin webview_flutter_android, io.flutter.plugins.webviewflutter.WebViewFlutterPlugin", e);
    }
  }
}
gv8xihay

gv8xihay1#

WebView正在调试模式下工作,因为它在android/app/src/debug/androidManifest.xml文件中具有Internet权限
您需要在android/app/src/main/androidManifest.xml文件中添加相同的内容

<uses-permission android:name="android.permission.INTERNET"/>

我希望它能很好地工作。
一切顺利

相关问题