简体   繁体   English

Flutter app(android)在发布模式下无法在真实设备上运行

[英]Flutter app(android) not working on real device in release mode

I've been building a demo app to practice flutter, the app's running perfectly fine in the emulator as well as on real devices when connected.我一直在构建一个演示应用程序来练习颤振,该应用程序在模拟器以及连接后的真实设备上运行得非常好。 But now, I've been trying to run the APK file on my mobile and it seems to not work.但是现在,我一直在尝试在我的手机上运行 APK 文件,但它似乎不起作用。 I can log in to the app meaning the internet permission is working.我可以登录该应用程序,这意味着互联网许可正在运行。 But when it comes to the home screen which pulls data from a server, the app does not work.但是,当涉及从服务器提取数据的主屏幕时,该应用程序无法运行。 Maybe there's something wrong in the code relevant, but I can't seem to fix it.也许相关代码有问题,但我似乎无法修复它。

I've attached the code for the home screen as well, the provider part is the thing that is having issues.我也附上了主屏幕的代码,提供者部分是有问题的东西。 AND ALSO THE DATABASE HAS THE DATA MEANING THE LIST IS NOT EMPTY AT ALL并且数据库有数据意味着列表根本不是空的

 import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import './new_enquiry_screen.dart'; import '../providers/enquiries_provider.dart'; import '../screens/new_enquiry_screen.dart'; import '../widgets/drawer_widget.dart'; import '../widgets/follow_up_list_tile_widget.dart'; class EnquiryScreen extends StatelessWidget { const EnquiryScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return DefaultTabController( length: 3, child: Scaffold( drawer: DrawerWidget(), appBar: AppBar( bottom: const TabBar( tabs: [ Tab(text: 'Follow Ups'), Tab(text: 'Leads'), Tab(text: 'Past'), ], ), title: Text( 'Enquiries', ), backgroundColor: Theme.of(context).primaryColor, ), body: TabBarView( children: [ ChangeNotifierProvider<EnquiriesProvider>.value( value: EnquiriesProvider(), child: Consumer<EnquiriesProvider>( builder: (_, provider, child) { int length = provider.enquiries.length; return length == 0 ? Center( child: CircularProgressIndicator(), ) : ListView.builder( itemCount: length, itemBuilder: (_, index) { return FollowUpListTileWidget( provider.enquiries.elementAt(index), ); }, ); }, ), ), const Center( child: Text('Leads Up'), ), const Center( child: Text('Past Up'), ), ], ), floatingActionButton: FloatingActionButton( backgroundColor: Theme.of(context).primaryColor, onPressed: () { Navigator.of(context).pushNamed(NewEnquiryScreen.routeName); }, child: Icon( Icons.add, color: Theme.of(context).accentColor, size: 30, ), ), ), ); } }

 import 'package:flutter/material.dart'; import '../models/enquiry.dart'; class FollowUpListTileWidget extends StatelessWidget { const FollowUpListTileWidget(this._enquiry, {Key? key}) : super(key: key); final Enquiry _enquiry; @override Widget build(BuildContext context) { return Card( elevation: 10, margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 5.0), child: ListTile( leading: CircleAvatar( child: Text( _enquiry.name.characters.first.toUpperCase(), style: TextStyle( color: Theme.of(context).accentColor, ), ), backgroundColor: Theme.of(context).primaryColor, ), title: Text(_enquiry.name), subtitle: FittedBox(child: Text(_enquiry.email)), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon( Icons.phone, ), ), IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon(Icons.whatsapp), ), IconButton( color: Theme.of(context).primaryColor, onPressed: () {}, icon: const Icon(Icons.edit), ), ], ), ), ); } }

尝试在真实设备上以调试模式运行应用程序,如果它正在运行,则检查清单文件是否已在android/app/main/AndroidManifest.xml中授予互联网权限,默认情况下在调试模式下互联网权限已退出且最重要请从您的问题标题中删除所有大写字母,因为它很难阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当设备大小更改时,如何在Android应用中的Flutter View发行模式下重建Flutter小部件? - How to rebuild Flutter widgets when device size changes, in release mode for Flutter View in Android app? Flutter 应用程序发布 apk 在真实设备上无法正常工作 - Flutter Application release apk not working properly on Real Device 我的TTS应用程序无法在实际的Android设备中运行 - My tts app is not working in real android device Android应用程序在模拟器上工作,但不在真实设备上 - Android app working on emulator but not on real device Android应用程序可在模拟器上运行,但不能在真实设备上运行,SharePreferences - Android app working on emulator but not real device, SharePreferences Android 应用程序在真实设备上崩溃但在模拟器上工作 - Android app crashing on real device but working on emulator Android应用程式在侦错模式下运作良好,但在发布模式下当机 - Android app working fine in debug mode but crashing in release mode Flutter - firebase_app_check 在发布模式下不工作,如何解决? - Flutter - firebase_app_check not working in release mode, how fix it? flutter android 应用程序在发布模式下冻结在初始屏幕上 - flutter android app freezes on the splash screen in release mode Flutter 通知自定义声音在 android 的发布模式下不起作用 - Flutter Notification custom sound not working in release mode in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM