Flutter release 网络请求错误问题

在测试环境中网络请求正常,但是release之后,出现如下问题:

E/flutter (17981): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: Failed host lookup: 'api.dev.echoes.tech' (OS Error: No address associated with hostname, errno = 7)
E/flutter (17981): #0      IOClient.send (package:http/src/io_client.dart:33)
E/flutter (17981): <asynchronous suspension>
E/flutter (17981): #1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:169)
E/flutter (17981): <asynchronous suspension>

网络地址找不到。

解决方法:

在路径为android/app/src/main/AndroidManifest.xml的配置文件添加权限配置:

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="echo"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />

增加最后一行:<uses-permission android:name="android.permission.INTERNET" />即可。