简体   繁体   English

Android Emulator可以上网但是App无法连接Firebase

[英]Android Emulator is able to the Internet but the App is unable to connect to Firebase

I'm trying to debug a Flutter app on an Emulator through AVD (Intellij).我正在尝试通过 AVD (Intellij) 在模拟器上调试 Flutter 应用程序。 Everything works fine on a physical device.在物理设备上一切正常。 I can connect to the inte.net through the Emulator (Chrome browsing works) But I'm unable to connect to the Firebase server through the App in the emulator.我可以通过模拟器连接到inte.net(Chrome浏览器可以)但是我无法通过模拟器中的应用程序连接到Firebase服务器。

Here's the error stack trace这是错误堆栈跟踪

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:59768/9pXmC0Ic4uc=/ws
Syncing files to device Android SDK built for x86...
W/DynamiteModule( 6185): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6185): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6185): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
I/il.arnet_helpe( 6185): The ClassLoaderContext is a special shared library.
I/chatty  ( 6185): uid=10146(app.zumy.mil.arnet_helper) AsyncTask #1 identical 2 lines
I/il.arnet_helpe( 6185): The ClassLoaderContext is a special shared library.
...
**W/Firestore( 6185): (24.3.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
W/Firestore( 6185): 
W/Firestore( 6185): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
...**
>putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/il.arnet_helpe( 6185): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/Firestore( 6185): (24.3.1) [WatchStream]: (b4b5c28) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.
W/DynamiteModule( 6185): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6185): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6185): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller( 6185): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
W/DynamiteModule( 6185): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6185): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6185): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller( 6185): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
W/DynamiteModule( 6185): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6185): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6185): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller( 6185): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
D/EGL_emulation( 6185): eglMakeCurrent: 0xe0f191e0: ver 2 0 (tinfo 0xe0f3e260)
W/DynamiteModule( 6185): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6185): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6185): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller( 6185): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]

I have added the following to /android/app/main/AndroidManifest.xml我已将以下内容添加到 /android/app/main/AndroidManifest.xml

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

I have tried the cold boot option.我试过冷启动选项。 It's not an issue with DNS because I CAN connect to the Inte.net through Chrome in the Emulator.这不是 DNS 的问题,因为我可以通过模拟器中的 Chrome 连接到 Inte.net。 I'm currently on Android 10.0 but I also tried 11. What could be missing?我目前使用的是 Android 10.0,但我也尝试过 11。可能缺少什么?

This looks like an open unresolved issue with Firebase on Android emulators.这看起来像是 Firebase 在 Android 模拟器上的一个未解决的问题 So I gave up on running this on an emulator and instead using Edge (Web) instead to debug and continue with the development所以我放弃了在模拟器上运行它,而是使用 Edge (Web) 来调试并继续开发

Just make sure to pass in the options or else you WON'T be able to run your app on any browser or on Windows App.只需确保传递选项,否则您将无法在任何浏览器或 Windows 应用程序上运行您的应用程序。 Here's the config needed for WEB.这是 WEB 所需的配置。

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM