Failing to run Flutter app on a different machine - flutter

I have been working on a flutter project for a while now, but I had to change the PC I am using for some reasons. the thing is that every time I try to run the app I get bunch of errors then the app crashes and the connection get lost. I tried to run the app from the old PC again and It worked fine.
This is the stack of errors I get before the crash:
E/LB (21021): fail to open file: No such file or directory
I/m.example.test(21021): ProcessProfilingInfo new_methods=92 is saved saved_to_disk=1 resolve_classes_delay=8000
D/DecorView: getWindowModeFromSystem windowmode is 1
I/flutter (21021): True
E/AndroidRuntime(21021): FATAL EXCEPTION: flutter-worker-1
E/AndroidRuntime(21021): Process: com.example.test1, PID: 21021
E/AndroidRuntime(21021): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/tekartik/sqflite/LogLevel;
E/AndroidRuntime(21021): at com.tekartik.sqflite.SqflitePlugin.onOpenDatabaseCall(SqflitePlugin.java:733)
E/AndroidRuntime(21021): at com.tekartik.sqflite.SqflitePlugin.onMethodCall(SqflitePlugin.java:983)
E/AndroidRuntime(21021): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:261)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:321)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger$SerialTaskQueue.flush(DartMessenger.java:173)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger$SerialTaskQueue.lambda$dispatch$0$io-flutter-embedding-engine-dart-DartMessenger$SerialTaskQueue(DartMessenger.java:163)
E/AndroidRuntime(21021): at io.flutter.embedding.engine.dart.DartMessenger$SerialTaskQueue$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime(21021): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(21021): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(21021): at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime(21021): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tekartik.sqflite.LogLevel" on path: DexPathList[[zip file "/data/app/~~Jf92ML0d6XYgNbFc-Me8kg==/com.example.test1-i0I0QGqwfxD8m-Juiw5BfQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~Jf92ML0d6XYgNbFc-Me8kg==/com.example.test1-i0I0QGqwfxD8m-Juiw5BfQ==/lib/arm64, /data/app/~~Jf92ML0d6XYgNbFc-Me8kg==/com.example.test1-i0I0QGqwfxD8m-Juiw5BfQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(21021): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
E/AndroidRuntime(21021): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(21021): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(21021): ... 12 more
I/Process (21021): Sending signal. PID: 21021 SIG: 9
Lost connection to device.
Anyone have any idea of what is going on here?
Thanks in advance.

Are you sure you have the same version of flutter as the computer you are using? You can check this thread

Related

How to resolve Flutter unsatisfied link error?

In Firebase crashlytics, I am getting the following information about the crash.
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myawesomeapp/com.example.myawesomeapp.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/base.apk", zip file "/data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.en.apk", zip file "/data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.es.apk", zip file "/data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.x86.apk", zip file "/data/app/com.example.myawesomeapp-zqi6k7PQCL8VlHwCIoANUA==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/lib/x86, /data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/base.apk!/lib/x86, /data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.en.apk!/lib/x86, /data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.es.apk!/lib/x86, /data/app/com.example.myawesomeapp-dghasjbcdcjdfhcn==/split_config.x86.apk!/lib/x86, /data/app/com.example.myawesomeapp-zqi6k7PQCL8VlHwCIoANUA==/split_config.xxhdpi.apk!/lib/x86, /system/lib, /system/vendor/lib]]] couldn't find "libflutter.so"
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

How to resolve java.lang.NoClassDefFoundError errors in flutter?

When I run the app from flutter to the Android simulator, the following error is returned, and it does not run, I don't know what the problem is, please advise on the error.
Launching lib/main.dart on Android SDK built for arm64 in debug mode...
lib/main.dart:1
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:57149/NUW2Tq4P_Hg=/ws
E/AndroidRuntime( 8510): FATAL EXCEPTION: main
E/AndroidRuntime( 8510): Process: com.example.qnsdk_example, PID: 8510
E/AndroidRuntime( 8510): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
E/AndroidRuntime( 8510): at com.yolanda.health.qnblesdk.out.QNBleApi.setBleDeviceDiscoveryListener(QNBleApi.java:787)
E/AndroidRuntime( 8510): at com.example.qnsdk.QNSdkPlugin.setBleDeviceDiscoveryListener(QNSdkPlugin.kt:146)
E/AndroidRuntime( 8510): at com.example.qnsdk.QNSdkPlugin.onMethodCall(QNSdkPlugin.kt:82)
E/AndroidRuntime( 8510): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/AndroidRuntime( 8510): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/AndroidRuntime( 8510): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/AndroidRuntime( 8510): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$R4HPk6oFVb-i-YR_PN9YE6kqx1I.run(Unknown Source:12)
E/AndroidRuntime( 8510): at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime( 8510): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime( 8510): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 8510): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 8510): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8510): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 8510): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime( 8510): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.localbroadcastmanager.content.LocalBroadcastManager" on path: DexPathList[[zip file "/data/app/com.example.qnsdk_example-cDdo9nfJTxqNGC_B2Gxa2g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.qnsdk_example-cDdo9nfJTxqNGC_B2Gxa2g==/lib/arm64, /data/app/com.example.qnsdk_example-cDdo9nfJTxqNGC_B2Gxa2g==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime( 8510): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime( 8510): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 8510): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 8510): ... 14 more
I/flutter ( 8510): initSDK 1108
I/Process ( 8510): Sending signal. PID: 8510 SIG: 9
Lost connection to device.
Exited (sigterm)
and in the sdk manager
android sdk command-line tools (latest)
I followed it because I had to check it, but the error does not go away and continues.
Try this:
Open Tools > SDK Manager
choose Appearance & Behavior > System Settings > Android SDK
Select SDK Tools
Check Android SDK Command-line tools and click ‘apply’.

Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference

I have a problem when running a tflite model in my image classification app project( flutter ).
I have converted my CNN model to a tflite model via the code below:
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model('/content/drive/MyDrive/CNN_Model/10.07.CNNmodel.100.92')
# converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_LATENCY]
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
I tested the output of the tflite model and believe that it was converted successful. But when I added to my dart file in my project by the code:
Future loadModel() async {
await Tflite.loadModel(
model: 'assets/tflite/converted_model.tflite',
labels: 'assets/tflite/labels.txt',
);
}
After I ran the main.dart, took a picture to test, I got these errors:
E/AndroidRuntime( 6189): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime( 6189): Process: com.hajaj_projects.cat_vs_dog, PID: 6189
E/AndroidRuntime( 6189): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime( 6189): at android.os.AsyncTask$4.done(AsyncTask.java:415)
E/AndroidRuntime( 6189): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime( 6189): at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime( 6189): at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime( 6189): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
E/AndroidRuntime( 6189): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 6189): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 6189): at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime( 6189): Caused by: java.lang.IllegalArgumentException: Internal error: Failed to run on the given Interpreter: Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.
E/AndroidRuntime( 6189): Node number 21 (FlexAddV2) failed to prepare.
E/AndroidRuntime( 6189):
E/AndroidRuntime( 6189): at org.tensorflow.lite.NativeInterpreterWrapper.run(Native Method)
E/AndroidRuntime( 6189): at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:204)
E/AndroidRuntime( 6189): at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:374)
E/AndroidRuntime( 6189): at org.tensorflow.lite.Interpreter.run(Interpreter.java:332)
E/AndroidRuntime( 6189): at sq.flutter.tflite.TflitePlugin$RunModelOnImage.runTflite(TflitePlugin.java:504)
E/AndroidRuntime( 6189): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:471)
E/AndroidRuntime( 6189): at sq.flutter.tflite.TflitePlugin$TfliteTask.doInBackground(TflitePlugin.java:445)
E/AndroidRuntime( 6189): at android.os.AsyncTask$3.call(AsyncTask.java:394)
E/AndroidRuntime( 6189): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime( 6189): ... 4 more
I/Process ( 6189): Sending signal. PID: 6189 SIG: 9
Lost connection to device.
When I removed the Normalization layer in my CNN model then converted it again, the app runs smoothly. But removing Normalization model decreased lots of my model accuracy.
I'm new to flutter. By any chance, has anybody encountered and resolved this before? Thanks for spending time.
dependencies {
implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly-SNAPSHOT'
// This dependency adds the necessary TF op support.
implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly-SNAPSHOT'
}
The converted model contains the Select TF ops. This means the model requires the Select TF op dependency.
If the above dependency is too big footprint, please consider creating a custom AAR through the selective build https://www.tensorflow.org/lite/guide/reduce_binary_size
See also https://www.tensorflow.org/lite/guide/ops_select.

Flutter StreamProvider with CloudFirestore causing error on Resume

Having a weird issue and cant seem to figure out if I have something setup wrong (new with Providers and streams) or if its a bug. Everything seems to work fine except when the app resumes after being backed out with the back button, on Android, and then restarted. Steps to reproduce:
Launch App
hit back button to close app (not just minimize)
Relaunch app
I get the following error:
D/AndroidRuntime( 3566): Shutting down VM
E/AndroidRuntime( 3566): FATAL EXCEPTION: main
E/AndroidRuntime( 3566): Process: com.crimsonowl.scryer, PID: 3566
E/AndroidRuntime( 3566): java.lang.NullPointerException: Attempt to invoke virtual method 'void io.flutter.plugin.common.MethodChannel.invokeMethod(java.lang.String, java.lang.Object)' on a null object reference
E/AndroidRuntime( 3566): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.onEvent(CloudFirestorePlugin.java:429)
E/AndroidRuntime( 3566): at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$DocumentObserver.onEvent(CloudFirestorePlugin.java:402)
E/AndroidRuntime( 3566): at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore##21.3.0:504)
E/AndroidRuntime( 3566): at com.google.firebase.firestore.DocumentReference$$Lambda$3.onEvent(Unknown Source:6)
E/AndroidRuntime( 3566): at com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore##21.3.0:42)
E/AndroidRuntime( 3566): at com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(Unknown Source:6)
E/AndroidRuntime( 3566): at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime( 3566): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime( 3566): at com.google.android.gms.internal.tasks.zzb.dispatchMessage(com.google.android.gms:play-services-tasks##17.0.2:6)
E/AndroidRuntime( 3566): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 3566): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 3566): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 3566): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 3566): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process ( 3566): Sending signal. PID: 3566 SIG: 9
After a lot of debugging and trying to figure out what was causing it. Ive narrow the problem down to StreamProvider and my user data. In my main screen I load a stream of the Users data with this:
return FutureProvider.value(
value: Provider.of<IAPProvider>(context).initialize(),
child: StreamProvider<User>.value(
value: DatabaseProvider().streamUser(user.uid),
child: MainScreen(),
),
);
And the code for the stream is this:
Stream<User> streamUser(String id) {
return Firestore.instance
.collection(USER_COLLECTION)
.document(id)
.snapshots()
.map((snap) => User.fromFirestore(snap));
}
I figured out that anytime I try to write to the User document on the cloud firestore database the app crashes, but only when I have done the steps above. On the initial launch (and works fine if I relaunch after it crashes) everything works as expected. Something like this:
Firestore.instance.collection(USER_COLLECTION).document(user.uid).updateData({'last_login': FieldValue.serverTimestamp()});

Android: Published App crashes with ClassNotFoundException

I have just published my first app today but for some reason when I use the published version I keep getting a ClassNotFoundException error when it starts up. It works fine when I test it in debug mode on my phone so I'm not sure whats causing this.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.androidProjects.personal/com.androidProjects.personal.GAAClubFinderActivity}: java.lang.ClassNotFoundException: com.androidProjects.personal.GAAClubFinderActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2141)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2260)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.androidProjects.personal.GAAClubFinderActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1039)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2132)
... 11 more
Any Ideas?