Flutter released app not working on the device, when installed

对着背影说爱祢 提交于 2019-12-10 10:28:20

问题


When I am debugging the app, everything works fine, but after I perform these commands:

flutter clean
flutter build apk
flutter install

The installed app is not working properly (Not loading data from API). Any ideas?

pubspec.yaml:

name: test_app
description: A new Flutter project.
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0+2
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true


回答1:


Since this is a problem that might concern other developers and the question deserves an answer I've decided to post it as an answer rather than a comment.

When you create a new flutter project, the framework won't add any permissions to AndroidManifest.xml or any configurations to Info.plist for iOS. This has to be done manually by the developer.

Also, there are some flutter packages that take care of runtime permissions, but these permissions require user input (grant permission or deny it). Runtime permissions are sensitive permissions but internet access permission is not in this category, so there's no need for requesting user feedback on it.

To be even more confusing, the flutter framework can do API requests in debug mode or on simulators without Internet permission added to the AndroidManifest.xml (maybe in the future we'll get an error/warning) about missing permission from the flutter team, until then, don't forget to add it in your AndroidManifest.xml file.



来源:https://stackoverflow.com/questions/56046492/flutter-released-app-not-working-on-the-device-when-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!