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.
Related
Just started Flutter course from freecodecamp and can't resolve this problem for couple of hours... I have installed firebase plugins, all are in pubspec.yaml
firebase_core: ^1.17.1
firebase_auth: ^3.3.19
cloud_firestore: ^3.1.17
firebase_analytics: ^9.1.9
like in course video have to change in android/app/build.gradle
defaultConfig {minSdkVersion 19 and add
multiDexEnlabed true}
its and dependency
dependencies{
implementation 'com.android.support:multidex:1.0.3'}
in course it goes well but i have this issue:
Launching lib\main.dart on ONEPLUS A6003 in debug mode...
lib\main.dart:1
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\dev\projects flutter\notatki\android\app\build.gradle' line: 28
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9s4pif6pkcf99jbjr51rbhd01.android() is applicable for argument types: (build_9s4pif6pkcf99jbjr51rbhd01$_run_closure2) values: [build_9s4pif6pkcf99jbjr51rbhd01$_run_closure2#6e3389a0]
* Try:> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
when i run app in flutter run -v in terminal it gives me some more:
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:699:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
Was trying to change minSdkVersion, target, compile, changing versions of firebase (in dependency, was not downloading it.....) all not work.
But when i'll comment out all installed firebase dependences, multiDexEnlabed true and this implementation 'com.android.support:multidex:1.0.3'
this demo application just works fine
Flutter ble - write characteristic error
I'm not being able to write on ble pheriperal device, using flutter_blue library, it throws this exception:
Unhandled Exception: PlatformException(write_characteristic_error, service (0000ff06-0000-1000-8000-00805f9b34fb) could not be located on the device, null, null)
E/flutter (29808): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (29808): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (29808): <asynchronous suspension>
E/flutter (29808): #2 BluetoothCharacteristic.write (package:flutter_blue/src/bluetooth_characteristic.dart:120:18)
E/flutter (29808): <asynchronous suspension>
E/flutter (29808): #3 DeviceScreen._buildServiceTiles.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:untitled/main.dart:176:23)
or another error saying : Write is not permited.
I'm using example code provided by flutter blue library, here is the code that im trying to write after device is connected:
onWritePressed: () async {
await c.write(_getRandomBytes(), withoutResponse: true);
await c.read();
},
onNotificationPressed: () async {
await c.setNotifyValue(!c.isNotifying);
if (c.properties.read) {
await c.read();
}
List<int> _getRandomBytes(){
String command = "55 AA 00 01 50 3C 00";
return command.codeUnits;
}
The hardware device is working fine in Kotlin, data is sent and received.
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);
}
}
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.
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.