Zeeshan Ansari
Zeeshan Ansari

Reputation: 1483

API not working/http error SocketException: Failed host lookup in Release Build(working in debug mode) For Flutter

Getting Some Of Notes Regarding path_provider-1.5.1 and API not working which I integrated through http/dio in Release Build(working in debug mode) For Flutter.

Note: /home/webelightpc/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.5.1/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

ich

Upvotes: 3

Views: 5750

Answers (3)

lvingstone
lvingstone

Reputation: 239

if you're using vscode, and you've added the necessary permission and still get socketException, then its vscode. go to run and debug section in vscode, untick all Exceptions. enter image description here

Upvotes: 1

Taqi Tahmid Tanzil
Taqi Tahmid Tanzil

Reputation: 330

For those people who are new in flutter,here is the full demo. you have to add permission above "Application" tag

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.reprecinct.app.reprecinct">

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

   <application
        android:label="your app label"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

Upvotes: 2

Zeeshan Ansari
Zeeshan Ansari

Reputation: 1483

According to https://github.com/flutter/flutter/issues/27883

It's strange that without adding permission in AndroidManifest.xml it'll work in debug but in release modeany API request will not work, solutions is as simple as below...

just add permission like this

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

in your app's android/app/src/main/AndroidManifest.xml

Upvotes: 13

Related Questions