android - Flutter app won't connect to my local API - Stack Overflow

The application from the mobile phone does not connect to my local ASP Web API, although the debug vers

The application from the mobile phone does not connect to my local ASP Web API, although the debug version of the application running on the emulator works with it correctly, while running "flutter build apk" and installing it on the mobile phone does not work. The phone and the server are on the same network, which is why I can't figure out what the problem is.

The application from the mobile phone does not connect to my local ASP Web API, although the debug version of the application running on the emulator works with it correctly, while running "flutter build apk" and installing it on the mobile phone does not work. The phone and the server are on the same network, which is why I can't figure out what the problem is.

Share edited Mar 4 at 11:37 VLAZ 29.2k9 gold badges63 silver badges84 bronze badges asked Mar 4 at 11:31 Денис ВолчекДенис Волчек 31 bronze badge
Add a comment  | 

3 Answers 3

Reset to default 0

Since the app requires an internet connection to communicate with your local ASP Web API.

  • the debug version of the application running correctly.

  • the command flutter build apk builds a release APK by default.

  • The internet permission is not added by default in the AndroidManifest file in the release version.

Try to:

1. Open AndroidManifest.xml:

Navigate to android/app/src/main/AndroidManifest.xml in your project.

2. Add the INTERNET Permission:

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

3. Additional Permissions to Consider

  • Access Network State:

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

  • Access Wi-Fi State:

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

what IP address is in your code when you run flutter build apk? It should not be 10.0.2.2. 10.0.2.2 is for emulators to host machines only. you need to use the LAN ip address of your machine, connect your phone to the same network as your machine. Look at the logcat for more info, it may give you more insight as well. here is a screenshot of logcat

With your android device connected, you can use adb reverse to grant your device access to local host running on your computer.

See this article for more info.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745046525a4608132.html

相关推荐

  • android - Flutter app won&#39;t connect to my local API - Stack Overflow

    The application from the mobile phone does not connect to my local ASP Web API, although the debug vers

    8小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信