Flutter - Unable to Install Application to Emulator - flutter

I have a Flutter project that previously run on Flutter 2.2. Recently, I upgraded to Flutter 2.10 but unable to run the application on Android emulator. I've followed the instruction on https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects. I run the emulator on Ubuntu.
What I've tried (from other StackOverflow posts) didn't work at all:
Restarting emulator
Removing dependencies (I removed all dependencies in pubspec.yaml)
Accepting Android SDK licenses
Using Android Pie version emulator
Running flutter clean
Uninstall the app on the emulator
flutter doctor shows no problem.
Sometimes the run process stuck on Installing/built APK, sometimes I get 'Error connecting to the service protocol'. I also get the following error
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
E/AndroidRuntime(10386): FATAL EXCEPTION: main
E/AndroidRuntime(10386): Process: com.app.example, PID: 10386
E/AndroidRuntime(10386): java.lang.NoSuchMethodError: No static method getMainExecutor(Landroid/content/Context;)Ljava/util/concurrent/Executor; in class Landroidx/core/content/ContextCompat; or its super classes (declaration of 'androidx.core.content.ContextCompat' appears in /data/app/com.app.example-pnJtFUSDIe4xWUHIPO1jNQ==/base.apk)
E/AndroidRuntime(10386): at io.flutter.embedding.android.FlutterView.onAttachedToWindow(FlutterView.java:483)
E/AndroidRuntime(10386): at android.view.View.dispatchAttachedToWindow(View.java:18347)
E/AndroidRuntime(10386): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
E/AndroidRuntime(10386): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
E/AndroidRuntime(10386): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
E/AndroidRuntime(10386): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
E/AndroidRuntime(10386): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
E/AndroidRuntime(10386): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
E/AndroidRuntime(10386): at android.view.Choreographer.doCallbacks(Choreographer.java:761)
E/AndroidRuntime(10386): at android.view.Choreographer.doFrame(Choreographer.java:696)
E/AndroidRuntime(10386): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
E/AndroidRuntime(10386): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(10386): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10386): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(10386): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime(10386): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10386): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(10386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I can run the same code (on the same project) to web browser. I can run the same code on the emulator if it's copied to another newly created project which is created with Flutter 2.10. I also have copied AndroidManifest.xml, build.gradle from the new project to the old one, but also not working.
Any solution or suggestion what should I do to fix it.

It looks like you still have references to previous versions of android libraries com.android... , latest flutter uses androidX.
Make sure you don't have any of
implementation 'com.android....`
in your gradle files.

Related

FFMPEG Kit issue in Banuba Video SDK : "FFmpegKit failed to start on brand"

I am trying to integrate Banuba Video Editor sdk in flutter.
The issue i am facing is as below
Banuba sdk works with native code for Android in Flutter
So Banuba requires FFMPEG dependency to define in Native Android
And I am already using 'ffmpeg_kit_flutter' plugin for flutter.
So both the FFMPEG kits are conflicted and some of the functions are not found. due to that I am receiving the below error.
When the app is launched I am receiving this Crash as mentioned
**java.lang.Error: FFmpegKit failed to start on brand: google, model: sdk_gphone_x86, device: generic_x86_arm, api level: 30, abis: x86 armeabi-v7a armeabi, 32bit abis: x86 armeabi-v7a armeabi, 64bit abis: .
** at com.arthenica.ffmpegkit.NativeLoader.loadLibrary(NativeLoader.java:50)
at com.arthenica.ffmpegkit.NativeLoader.loadFFmpegKit(NativeLoader.java:189)
at com.arthenica.ffmpegkit.FFmpegKitConfig.<clinit>(FFmpegKitConfig.java:145)
at com.arthenica.ffmpegkit.FFmpegKitConfig.enableFFmpegSessionCompleteCallback(FFmpegKitConfig.java:864)
at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.registerGlobalCallbacks(FFmpegKitFlutterPlugin.java:168)
at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.init(FFmpegKitFlutterPlugin.java:652)
at com.arthenica.ffmpegkit.flutter.FFmpegKitFlutterPlugin.onAttachedToActivity(FFmpegKitFlutterPlugin.java:198)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivityInternal(FlutterEngineConnectionRegistry.java:351)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.attachToActivity(FlutterEngineConnectionRegistry.java:324)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:194)
at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:498)
at com.sound.it.MainActivity.onCreate(MainActivity.kt:43)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
**Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_log_default_callback" referenced by "/data/app/~~umF3qlB9U53L4peU9nKYuQ==/com.sound.it-agqiFlNmMe17AHMK5gYIHw==/lib/x86/libffmpegkit.so"...**
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at com.arthenica.ffmpegkit.NativeLoader.loadLibrary(NativeLoader.java:48)
Looking for the solutions

Flutter AdMob will not launch

Trying to incorporate adMob into a flutter app and I am having this issue:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
lib/main.dart:1
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
E/AndroidRuntime(31743): FATAL EXCEPTION: pool-3-thread-1
E/AndroidRuntime(31743): Process: com.tendigitgrid.app_free, PID: 31743
E/AndroidRuntime(31743): java.lang.IllegalArgumentException: com.tendigitgrid.app_free: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(31743): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/AndroidRuntime(31743): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/AndroidRuntime(31743): at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
E/AndroidRuntime(31743): at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
E/AndroidRuntime(31743): at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
E/AndroidRuntime(31743): at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
E/AndroidRuntime(31743): at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
E/AndroidRuntime(31743): at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
E/AndroidRuntime(31743): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(31743): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(31743): at java.lang.Thread.run(Thread.java:920)
ANd it will not launch into the emulator to test.
I have minSDK set to 21 in my gradle file.
Update:
I tried installing the apk on my real phone and not in an emulator and it also did not work.

Flutter project not running after successful migration to null safety

I have problem running flutter project after successful migration to null safety. I use android studio. Here is the result of flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19041.985], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] Connected device (3 available)
• No issues found!
And here is the result of outdated dependency checks:
See https://dart.dev/go/null-safety-migration for a migration guide.
Analyzing project...
[-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\]
All sources appear to be already migrated. Nothing to do.
However, I get an error caused by a dependency (not used directly in my pubspec.yaml, but seems one of the packages is using it and this dependency has no null safety updated). So when I try to run it from android studio I get the following output (even though dart migrate should have mention even internal packages dependencies since it might be a stopper from running):
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:tinycolor
For solutions, see https://dart.dev/go/unsound-null-safety
lib/screens/invitations_screen.dart:115:5: Warning: Operand of null-aware operation '?.' has type 'TabController' which excludes null.
- 'TabController' is from 'package:flutter/src/material/tab_controller.dart' ('/D:/Flutter/flutterV1.0.0.0/packages/flutter/lib/src/material/tab_controller.dart').
_c1?.dispose();
^
/D:/Flutter/flutterV1.0.0.0/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.5.1/lib/flutter_datetime_picker.dart:311:32: Warning: Operand of null-aware operation '??' has type 'Color' which excludes null.
- 'Color' is from 'dart:ui'.
color: theme.backgroundColor ?? Colors.white,
^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Flutter\flutterV1.0.0.0\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\Flutter\flutterV1.0.0.0\bin\flutter.bat'' finished with non-zero exit value 1
* 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 23s
Exception: Gradle task assembleDebug failed with exit code 1
So I tried finally to run without sound-null-safety, but still an error keeps happening (I tried flutter clean --> Invalidate Caches/Restart --> pub get --> flutter run --no-sound-null-safety but still the same problem):
Using hardware rendering with device Android SDK built for x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 22.1s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Error connecting to the service protocol: failed to connect to http://127.0.0.1:57596/NxvUCmZt3sM=/
Note: Before the last trial of restarting android studio, this last error also showed an exception right before the "Error connecting ..." statement, and the exception was as I recall (sorry don't have the full stack trace as it doesn't show anymore):
androidx WindowInsetsCompat ---> NullPointerException on Preconditions.checkNonNull
EDIT
After going through dependencies in a new porject as suggested by #Taur, it turns out the problem when running without sound-null-safety was caused by flutter_typeahead dependency throwing the previously mentioned exception when I run the project:
E/AndroidRuntime(11173): java.lang.ExceptionInInitializerError
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat.<clinit>(WindowInsetsCompat.java:82)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat.toWindowInsetsCompat(WindowInsetsCompat.java:169)
E/AndroidRuntime(11173): at androidx.core.view.ViewCompat$Api21Impl$1.onApplyWindowInsets(ViewCompat.java:4753)
E/AndroidRuntime(11173): at android.view.View.dispatchApplyWindowInsets(View.java:9799)
E/AndroidRuntime(11173): at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7076)
E/AndroidRuntime(11173): at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7080)
E/AndroidRuntime(11173): at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7080)
E/AndroidRuntime(11173): at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1632)
E/AndroidRuntime(11173): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1734)
E/AndroidRuntime(11173): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1443)
E/AndroidRuntime(11173): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7125)
E/AndroidRuntime(11173): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935)
E/AndroidRuntime(11173): at android.view.Choreographer.doCallbacks(Choreographer.java:747)
E/AndroidRuntime(11173): at android.view.Choreographer.doFrame(Choreographer.java:682)
E/AndroidRuntime(11173): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921)
E/AndroidRuntime(11173): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(11173): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11173): at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime(11173): at android.app.ActivityThread.main(ActivityThread.java:6649)
E/AndroidRuntime(11173): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11173): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(11173): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
E/AndroidRuntime(11173): Caused by: java.lang.NullPointerException
E/AndroidRuntime(11173): at androidx.core.util.Preconditions.checkNotNull(Preconditions.java:119)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat.toWindowInsetsCompat(WindowInsetsCompat.java:169)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat.toWindowInsetsCompat(WindowInsetsCompat.java:149)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat$BuilderImpl20.build(WindowInsetsCompat.java:1706)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat$Builder.build(WindowInsetsCompat.java:1588)
E/AndroidRuntime(11173): at androidx.core.view.WindowInsetsCompat$Impl.<clinit>(WindowInsetsCompat.java:748)
E/AndroidRuntime(11173): ... 22 more

FATAL EXCEPTION: main, having an error while starting app / Flutter

I am having some error while starting my android app down below. I think it has to do with AndroidManifest.xml Thank you for help in advance!
Debug console output:
√ Built build\app\outputs\flutter-apk\app-debug.apk.
E/AndroidRuntime(12850): FATAL EXCEPTION: main
E/AndroidRuntime(12850): Process: com.example.finalproject, PID: 12850
E/AndroidRuntime(12850): java.lang.RuntimeException: Unable to instantiate application io.flutter.app.FlutterApplication: java.lang.ClassNotFoundException: Didn't find class "io.flutter.app.FlutterApplication" on path: DexPathList[[zip file "/data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/lib/arm64, /data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(12850): at android.app.LoadedApk.makeApplication(LoadedApk.java:1230)
E/AndroidRuntime(12850): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6575)
E/AndroidRuntime(12850): at android.app.ActivityThread.access$1400(ActivityThread.java:227)
E/AndroidRuntime(12850): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1890)
E/AndroidRuntime(12850): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(12850): at android.os.Looper.loop(Looper.java:224)
E/AndroidRuntime(12850): at android.app.ActivityThread.main(ActivityThread.java:7590)
E/AndroidRuntime(12850): at java.lang.reflect.Method.invoke(Native Method)
Didn't find class "io.flutter.app.FlutterApplication" on path: DexPathList[[zip file "/data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/lib/arm64, /data/app/com.example.finalproject-TKk2pSYMBdlivmhMJqry9A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
There seems to be an issue in the references that the Flutter project uses. You can run either flutter clean or flutter pub cache repair to help rebuild the references used in the project, then run flutter pub get to download the configured plugins.

java.lang.NoSuchMethodError: com.vungle.warren.Vungle.updateConsentStatus after updating to latest Vungle SDK

I am using Vungle ad network via MoPub SDK for showing ads in Android Application. I have just updated the Vungle SDK to latest as per their changelog (version 6.3.12). Now the app is crashing. The exception is as below:
08-03 16:56:58.480 14071-14071/com.globaldelight.vizmato E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.globaldelight.vizmato, PID: 14071
java.lang.NoSuchMethodError: com.vungle.warren.Vungle.updateConsentStatus
at com.mopub.mobileads.VungleRouter$2.onSuccess(VungleRouter.java:85)
at com.vungle.warren.Vungle$2.onResponse(Vungle.java:479)
at com.vungle.warren.network.VungleApiClient$4.onResponse(VungleApiClient.java:514)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Could someone please help me solve this issue?
Thanks in advance.