Infinite splash screen on android - android

In my project, I was using flutter 3.0.3. Once I updated to 3.0.4 and updated dependencies, suddenly when I launched the app on android, the splash screen is showing continuously(never going to the main app). I tried by moving to my previous commit, downgrading flutter but to no avail.
This happened before but I luckily fixed it by upgrading kotlin jdk to 8(was 7 before).
I am using flutter_native_splash library. But it looks it doesn't have any impact on my project.
This question talks about only release mode. But, in my case it is happening both release and debug modes. I would really appreciate your help on this!
My main function:
void mainCommon() {
WidgetsFlutterBinding.ensureInitialized();
SentryFlutter.init(
(options) => options.dsn = Config.sentryDsn,
appRunner: () async {
await Firebase.initializeApp();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
final GlobalKey<ScaffoldMessengerState> messengerKey = GlobalKey<ScaffoldMessengerState>();
await BlocOverrides.runZoned(
() async => App(
api: Api(Config.grpcChannel),
database: await Config.db,
appDirectory: await getApplicationDocumentsDirectory(),
notificationManager: await NotificationManager.init(Config.grpcChannel),
messengerKey: messengerKey,
),
blocObserver: AppBlocObserver(errorCallback: BlocErrorHandler(messengerKey).errorCallback),
);
},
);
}

This is not for all cases. But, upgrading firebase_core and firebase_messaging could solve for some cases. In my case, it solved the problem for the first. But, once I upgraded all my other packages, it occurred again.
Android studio sucks. When I used Visual Studio Code, the exception was thrown in main where I initialised firebase. But in android, it ignored exception so I wasted a lot of time finding where the problem was.
To see the error in Android studio, you need to get mainCommon in try/catch bloc:
try {
await Firebase.initializeApp();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(App(
api: Api(Config.grpcChannel),
database: await Config.db,
appDirectory: await getApplicationDocumentsDirectory(),
notificationManager: await NotificationManager.init(Config.grpcChannel),
));
} catch (e) {
logger.e("Got exception in mainCommon: $e");
rethrow;
}

Related

How to add Firebase-Crashlytics to Flutter project?

Trying to add Firebase Crashlytics to an app. Added to file android/app/build.gradle: apply plugin: 'com.google.firebase.crashlytics'. Added to the android/build.gradle file: classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'.
Initialized:
if (!kIsWeb) {
if (kDebugMode) {
await FirebaseCrashlytics.instance
.setCrashlyticsCollectionEnabled(false);
}
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
}
In my initState created a crash():
void initState() {
super.initState();
FirebaseCrashlytics.instance.crash();
}
But nothing is output in the console:
How to set it up correctly?
If this line is getting executed, then Crashlytics won't send any crashes:
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
See this document for reference. Make sure this is not getting executed when running your tests.
Also, when testing, I would recommend you having more control when the crash happens, like using a button. Similar to this:
TextButton(
onPressed: () => throw Exception(),
child: const Text("Throw Test Exception"),
),
The Crashlytics SDK, in some scenarios, will try to upload the crash reports when restarting the app. If the crashes happen too early into the startup process, it can prevent Crashlytics from actually uploading the crash report.
In addition, this will help you avoid having too many crashes.

auth().signInWithPhoneNumber() not working for react-native

I am using react-native to build an android app while authentication is done using firebase. I am using the following libraries :
#react-native-firebase/app
#react-native-firebase/auth
The authentication is working perfectly fine for signInWithEmailAndPassword() but not with the phone no :
The below is the function :
signInWithPhoneNumber = () => {
auth().signInWithPhoneNumber('+91 1234 567 890')
.then(confirmationResult => {
this.setState({
confirm: confirmationResult
})
})
.catch(function (error) {
console.error(error);
});
}
It's not going into the .then() and my screen for the emulator is getting stuck with blank black screen.
UPDATE (May 20, 2021)
Seems line the issue is fixed in the latest version.
This is a known issue in the firebase phone auth sdk.
Ref: https://github.com/firebase/firebase-android-sdk/issues/2164
Until Google fixes it, add the following line in your build.gradle
implementation "androidx.browser:browser:1.2.0"

Url Launcher does not work with MissingPluginException Flutter

I am trying to launch a url in my flutter application. What i'm trying to do is very simple and it works in all other projects except for this one! The browser should be launched on an inkwell onTap event. I tried the exact same code in other projects and worked. I also tried to create a new flutter project and the code worked.
The app does not crash and i don't get any error but on Debug i get a missing plugin exception.
I tried flutter clean and flutter run but didn't work! I tried invalidating cache and restart but also didn't work! I tried removing and re installing the plugin but also didn't work!
Here's the code:
_launchMapsUrl() async {
final url = 'https://www.google.com';
if (await canLaunch(url)) {
await launch(url);
} else {
print('Could not launch $url');
}
}
the onTap:
onTap: () {
_launchMapsUrl();
},
The Compiled and Target SDK versions are 29 and the version of the launcher in my pubspec.yaml is url_launcher: ^5.7.10
For the record the other projects that the code worked in are of the same versions
I think it has something to do with caching issue i'm not really sure, i'm very new to flutter.
Can you please recommend a solution.

react native firebaseURL not found

Upon pushing some data to firebase in react native I get the following error that my firebase database URL is undefined. I am using the android emulator here. Maybe I am missing something I need to push to firebase in my android build gradle file?
I am currently also using firebase auth for this app it it does work perfectly fine but I had to modify the android build gradle. I'm wondering if this could be a similar issue? If so does anyone know what I need to add?
I'm new to react-native sorry :(
Below is my config and my firebase app initialization
sendNoteToDatabase = () => {
const firebaseConfig = {
apiKey: 'my api key',
authDomain: '*********-37824.firebaseapp.com',
databaseURL: 'https://******-37824.firebaseio.com/',
projectId: '******-23288'
}
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
const note = {
title: "this.state.title",
who: "this.state.who",
time: "this.state.time"
}
firebase.database().ref('Users/').set(note).then((data) => {
//success callback
console.log('data ', data)
}).catch((error) => {
//error callback
console.log('error ', error)
})
}
I have checked the URL and I am using a realtime database. I'm not sure if this is an issue with my code structure or a problem with android?
using Franks Advice I was able to solve it by initializing the firebase app using the componentDidMount hook
componentDidMount(){
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
}

Xamarin.forms - Xam.Plugin.Media throwing error This functionality is not implemented in the portable version of this assembly

I am using Xam.Plugin.Media for implementing functions for taking and picking a photo on Android and iOS. I installed the latest stable version of Xam.Plugin.Media NuGet package (version 4.0.0.9) and followed the steps from Author on GitHub and when I press the button this message pops up and no matter what I do it wont go away. So if you any of you had this problem and resloved it please help me, and if you have any additional information about this error, please, help me.
I have tried the following to resolve this, but with no success:
Re-installing package several times
Deleting Obj and Bin folders
Clean + build
This is my view model:
public ICommand UploadImageCommand => new Command(async () =>
{
await Resiliency.TryAsync(IsBusy, async () =>
{
await UploadImageAsync();
});
});
private async Task UploadImageAsync()
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DialogService.ShowExceptionAlertAsync("No Camera");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
SaveToAlbum = true
});
if (file == null)
return;
_imagePath = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
}
Additional information:
When debbuging it crashes on the first line of the method - "await CrossMedia.Current.Initialize();"
This is happening on Android and I am using physical device (Huawei P9 Lite 7.0 API 24), but the same happens on Emulator API 23 6.0
I am using Visual studio 2015 enterprise with update 3
Yes the package is installed on the core project and on the android and iOS project
Check out the response of the original Developer on the GitHub Repository
Xam.Plugin.Media throwing error This functionality is not implemented in the portable version of this assembly #559
You can also download the sample and see how it works

Categories

Resources