Currently creating an app with Flutter.
I have created an issue on the official github but figured I'd ask here too if thats cool.
Steps To Reproduct:
flutter run --release
Install on Android device (reproduced on multiple)
App will hang when attempting Firebase.initializeApp()
NOTE
I do not personally think this is a firebase issue but when we all had to update our app for AndroidX compatibility and firebase_message also called for us to create the Application.kt file to implement it's newest pubs (which I need to use due to other dependencies).
ANY HELP WOULD BE GREATLY APPRECIATED. I really think this has something to do with the Kotlin files. I say that BECAUSE I MOVED THE AWAIT FIREBASE>INITAPP call in the main.dart file lower, and I got the same kind of output but instead referencing the SharedPrefs pub I was using.
Make sense?
What do YOUR Kotlin files look like?
Main.Dart File:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await SharedPreferences.getInstance();
Admob.initialize();
await Admob.requestTrackingAuthorization();
DynamicLinkService.handleDynamicLinks();
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]).then(
(_) {
runApp(
StringConstants(
child: AuthProvider(auth: Auth(), child: MyApp()),
),
);
},
);
}
pubspec.yaml
version: 1.0.0+29
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_core: "^0.5.3"
# Newly reworked plugins covered by this migration guide:
firebase_auth: "^0.18.4"
cloud_firestore: "^0.14.4"
cloud_functions: "^0.7.2"
firebase_storage: "^5.2.0"
firebase_messaging: ^7.0.3 # Updated to work with new core only plugins (no new changes):
firebase_admob: "^0.10.3"
firebase_analytics: "^6.3.0"
firebase_dynamic_links: "^0.6.3"
Output:
E/flutter (27399): [ERROR:flutter/lib/ui/ui_dart_state.cc(184)] Unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
E/flutter (27399): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:160)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399): #1 MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:348)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399): #2 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399): #3 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:75)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399): #4 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399): #5 main (package:instapray/main.dart:20)
E/flutter (27399): <asynchronous suspension>
E/flutter (27399):
MainActivity.kt:
class MainActivity: FlutterActivity() {
}
Application.kt:
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application:FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}
override fun registerWith(registry:PluginRegistry) {
io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}
This involved an update to the core Firebase pubs. Thanks.
Related
After running my app, it's showing the splash screen and never goes away. Even if I close & reboot the app and even I run the flutter run by Flutter run lib/main.dart is showing nothing only but the splash screen , I also added the WidgetsFlutterBinding.ensureInitialized(); but still nothing is working for me. trying everything like flutter clean & flutter pub get I haven't use any package for the splash-screen. plz can anyone identify the problem would appriciated.
I've added my terminal below after launching the app.
Thanks again.
W/FlutterActivityAndFragmentDelegate(18992): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
E/flutter (18992): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter (18992): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:246:7)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #3 main (package:pdfscanner/main.dart:7:3)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992):
my main.dart looks like this:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: "Document Scanner",
home: HomePage(),
),
);
}
this is my build.gradle in android mainstream
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here for the 1st error on the terminal says
A splash screen was provided to Flutter, but this is deprecated.
See flutter.dev/go/android-splash-migration for migration steps.
this was solved by removing <meta-data/> snippet on AndroidManifest.xml , which is :
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#mipmap/launch_image"
/>
and for these part of error on terminal , which is :
E/flutter (18992): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:246:7)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #3 main (package:pdfscanner/main.dart:7:3)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992):
I just have to remove
await Firebase.initializeApp();
which is right after the line
WidgetsFlutterBinding.ensureInitialized();
on main.dart , and by doing so I can see my main home_page.dart again. Everything works fine.
Error :
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel dev.fluttercommunity.plus/package_info)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
<asynchronous suspension>
#1 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:377:43)
<asynchronous suspension>
#2 MethodChannelPackageInfo.getAll (package:package_info_plus_platform_interface/method_channel_package_info.dart:13:17)
<asynchronous suspension>
#3 PackageInfo.fromPlatform (package:package_info_plus/package_info_plus.dart:36:26)
<asynchronous suspension>
I don't know where this error come from
Face the same issue while using
package_info_plus: ^3.0.2
Issue solved after completely restart the app/service
Am new to flutter and was trying around Firebase, but the app doesn't initialize Firebase on release
it throws an error, yet it works wen you just run the app. Am using android studio
** E/flutter (12950): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: MissingPluginException(No implementation found
for method Firebase#initializeC ore on channel
plugins.flutter.io/firebase_core)
E/flutter (12950): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:156) E/flutter
(12950): E/flutter (12950): #1
MethodChannel.invokeListMethod
(package:flutter/src/services/platform_channel.dart:344) E/flutter
(12950):
E/flutter (12950): #2 MethodChannelFirebase._initializeCore
(package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30)
E/flutter (12950):
E/flutter (12950): #3 MethodChannelFirebase.initializeApp
(package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:75)
E/flutter (12950):
E/flutter (12950): #4 Firebase.initializeApp
(package:firebase_core/src/firebase.dart:44) E/flutter (12950):
E/flutter (12950): #5 main
(package:ug_campus_papers_example/main.dart:13) E/flutter (12950):
E/flutter (12950):
**
Line 13 is the await Firebase.initializeApp();
My Main file is
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'App1 Test',
home: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (BuildContext context, AsyncSnapshot<User> snapshot) {
if (snapshot.hasData) {
User user = FirebaseAuth.instance.currentUser;
return Make1(user: user,);
} else
return SignInScreen();
},
),
);
}
}
The pubspec.yaml file is as below
name: ug_camp_example
description: My Flutter app 1.
version: 3.0.1+3
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_core: "^0.7.0"
firebase_storage: "^7.0.0"
firebase_auth: "^0.20.1"
cloud_firestore: "^0.16.0+1"
ug_camp:
path: ../
cupertino_icons: ^1.0.2
google_fonts:
provider:
file_picker: ^1.1.1
flutter_plugin_pdf_viewer:
sqflite:
path:
flutterwave:
flutter_launcher_icons: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter_icons:
image_path: "assets/images/apptest1.png"
android: true
ios: true
flutter:
uses-material-design: true
Please try the following:
Update your firebase packages to the latest versions. You're very outdated.
Ensure you've added your google-services.json to the project.
You mentioned you are using Android Studio, although are you running on Android or iOS? I can provide more instructions depending on the platform.
I'm creating a Flutter application.
If I run this application on debug mode webview works well
but if I run this application on release mode it shows blank screen. It's showing PlatformException
I tried to get help from github issues but couldn't find the solution.
Manifest
<uses-permission android:name="android.permission.INTERNET"/>
build.gradle
minSdkVersion 20
targetSdkVersion 29
pubspec.yaml
webview_flutter: ^1.0.7
Error Log
E/flutter (16872): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
E/flutter (16872): at io.flutter.plugin.platform.j$a.g(Unknown Source:229)
E/flutter (16872): at io.flutter.embedding.engine.i.j$a.b(Unknown Source:152)
E/flutter (16872): at io.flutter.embedding.engine.i.j$a.j(Unknown Source:144)
E/flutter (16872): at e.a.c.a.j$a.a(Unknown Source:17)
E/flutter (16872): at io.flutter.embedding.engine.e.b.d(Unknown Source:57)
E/flutter (16872): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter (16872): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (16872): at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (16872): at android.os.Looper.loop(Looper.java:183)
E/flutter (16872): at android.app.ActivityThread.main(ActivityThread.java:7660)
E/flutter (16872): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (16872): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (16872): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (16872): , null, null)
E/flutter (16872): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581)
E/flutter (16872): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
E/flutter (16872): <asynchronous suspension>
E/flutter (16872): #2 TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1036)
E/flutter (16872): <asynchronous suspension>
E/flutter (16872): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:742)
E/flutter (16872): <asynchronous suspension>
E/flutter (16872): #4 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:195)
E/flutter (16872): <asynchronous suspension>
Please check for "android.permission.INTERNET" pemission in your Manifest file. In "app/src/main/AndroidManifest.xml" folder.
I use flutter_inappwebview: ^5.3.2 plugin and faced same issue in release mode.
I think you did not give internet permission in android/app/src/main/AndroidManifest.xml
add this line into the <manifest of android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
and more information for Flutter Insecure http is not allowed by platform you can see this discussion
<uses-permission android:name="android.permission.INTERNET" /> //This line add
<application
android:name="io.demo.app.test"
android:label="ProjectName"
android:usesCleartextTraffic="true" //This line add
android:icon="#mipmap/ic_launcher">
I believe I ran into this same issue and what was happening was that there was both a cached flutter engine that had been initialised as well as a new flutter engine created later.
From that I went with a cached flutter engine and used a method channel to navigate as required.
So at some point somewhere(probably in your MainActivity or iOS equivalent) setup your Cached Flutter Engine:
val flutterEngine = FlutterEngine(this)
flutterEngine.dartExecutor.executeDartEntrypoint(
DartExecutor.DartEntrypoint.createDefault()
)
FlutterEngineCache
.getInstance()
.put(INSERT_YOUR_DESIRED_FLUTTER_ENGINE_ID_HERE, flutterEngine)
Then when you want to open your FlutterFragment(Android example):
var flutterEngine = FlutterEngineCache
.getInstance()
.get(INSERT_YOUR_FLUTTER_ENGINE_ID_FROM_BEFORE_HERE)
var flutterFragment = FlutterFragment
.withCachedEngine(INSERT_YOUR_FLUTTER_ENGINE_ID_FROM_BEFORE_HERE)
.build()
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
INSERT_YOUR_DESIRED_METHOD_CHANNEL_NAME_HERE
).invokeMethod("setRoute", INSERT_ROUTE_YOU_WANT_HERE)
openFragment(flutterFragment!!)
And an example of how you might use this method channel in your Flutter Dart code
class _MyViewState extends State<MyView> {
static const myMethodChannel = const MethodChannel(INSERT_YOUR_DESIRED_METHOD_CHANNEL_NAME_HERE);
Future<void> _handleMethodCalls(MethodCall call) async {
switch (call.method) {
case "setRoute":
Navigator.pushReplacmentNamed(context, INSERT_YOUR_DESIRED_ROUTE_NAME_HERE)
...
}
}
...
#override
void initState() {
super.initState();
platform.setMethodCallHandler(_handleMethodCalls);
}
}
I've searched the whole internet, tried every possible solution, still I'm not being able to sign in using GoogleSignIn from my flutter app.
Things I've tried :
1. Added SHA-1 Certificate
2. Added SHA-256 Certificate
3. Filled O-Auth Screen
4. Enabled GoogleSignIn in firebase
5. Added support email
Testing currently only in debug mode. As the app is in its initial stages right now I don't want to build a release version yet. Using debug SHA-1 and SHA-256 fingerprints.
Future<FirebaseUser> _signIn(BuildContext context) async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken, idToken: googleAuth.idToken);
AuthResult userDetails =
await _firebaseAuth.signInWithCredential(credential);
ProviderDetails providerInfo =
ProviderDetails(userDetails.user.providerId);
List<ProviderDetails> providerData = List<ProviderDetails>();
providerData.add(providerInfo);
UserDetails details = UserDetails(
providerDetails: userDetails.user.providerId,
userEmail: userDetails.user.email,
userName: userDetails.user.displayName,
photoUrl: userDetails.user.photoUrl,
providerData: providerData);
return userDetails.user;
}
Error I get
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception:
PlatformException(sign_in_failed,
com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter (12322): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:564
E/flutter (12322): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:316
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #2 MethodChannel.invokeMapMethod
package:flutter/…/services/platform_channel.dart:344
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #3 GoogleSignIn._callMethod
package:google_sign_in/google_sign_in.dart:218
E/flutter (12322): <asynchronous suspension>
E/flutter (12322): #4 GoogleSignIn._addMethodCall.<anonymous closure>
package:google_sign_in/google_sign_in.dart:27
E/flutter (12322): #5 _rootRun (dart:async/zone.dart:1120:38)
E/flutter (12322): #6 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (12322): #7 _FutureListener.handleWhenComplete
(dart:async/future_impl.dart:150:18)
E/flutter (12322): #8
Future._propagateToListeners.handleWhenCompleteCallback
(dart:async/future_impl.dart:609:39)
E/flutter (12322): #9 Future._propagateToListeners
(dart:async/future_impl.dart:665:37)
E/flutter (12322): #10 Future._addListener.<anonymous closure>
(dart:async/future_impl.dart:348:9)
E/flutter (12322): #11 _rootRun (dart:async/zone.dart:1124:13)
E/flutter (12322): #12 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (12322): #13 _CustomZone.runGuarded
(dart:async/zone.dart:923:7)
E/flutter (12322): #14 _CustomZone.bindCallbackGuarded.<anonymous
closure> (dart:async/zone.dart:963:23)
E/flutter (12322): #15 _microtaskLoop
(dart:async/schedule_microtask.dart:41:21)
E/flutter (12322): #16 _startMicrotaskLoop
(dart:async/schedule_microtask.dart:50:5)
E/flutter (12322):
I know this question was posted quite some time ago but in case anybody else had issues, in addition to all of the above steps, I also enabled Google People API. Make sure that you are on the right email and project.
https://console.developers.google.com/apis/library/people.googleapis.com?q=people&id=5877a7af-1d13-4098-a53e-b5e2d7a87a4f&project=phamton-test
Did you rebuild the project after adding the dependencies?
Sometimes you need to rebuild your project whenever you add any platform specific plugin before it can be used effectively
So as regards to this error, if you find yourself facing it at any point.
There are 2 things that could possibly be wrong
Your app is not on the playstore and you're testing locally with a signed app.
You should probably go and add more SHA keys, if you have only SHA-1 go ahead and put SHA-256. Also be weary of your test environment as it could also mean that your apk mode(Testing or Production) is not correlating.