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 badge3 Answers
Reset to default 0Since 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 arelease APK
by default.The internet permission is not added by default in the
AndroidManifest
file in therelease 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
评论列表(0条)