我的颤振应用程序在Android上显示黑屏,因为它无法连接到互联网



一直在做这个flutter项目,一切都很顺利。现在我完成了,想把它部署到android上,但应用程序不能在真正的android设备上工作,我注意到应用程序的数据使用量是0.00,所以我试着在android.xml上添加所有权限,甚至添加了更多的安全规则,但都无济于事。请问有没有人遇到过这种情况,解决方案是什么?

事情是这样的

首先,我没有在main中初始化FlutterBinding。所以我必须在初始化firebase

之前像这样添加它
void main() async {
///Flutter binding initialized
WidgetsFlutterBinding.ensureInitialized();
///Firebase initialized
await Firebase.initializeApp();
runApp(MyApp());
}

第二(只是为了确保一切正常工作)我添加了谷歌服务的依赖在我的项目水平build.gradle

dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.13'  // Google Services plugin
}

然后firebase插件在我的app级build。gradle

apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services'  // Google Services plugin
android {
// ...
}

就是这样…我的app工作了

相关内容

最新更新