Flutter tflite plugin not doing recognitions in release version of app - android

I have been trying to use the flutter tflite plugin in my app and so far have been testing it in dev/debug where it is working i.e. when I run the following
var recognitions = await Tflite.runModelOnImage(
path: croppedFile.path, // required
imageMean: 0.0, // defaults to 117.0
imageStd: 255.0, // defaults to 1.0
numResults: 2, // defaults to 5
threshold: 0.2, // defaults to 0.1
asynch: true // defaults to true
);
it does give me back some recognitions. However when I make a release version of the same code it does not return any recognitions when run on the same device with same input data. I am making the release version using following steps:
//step 1
flutter build appbundle
// step 2
java -jar bundletool-all-1.3.0.jar build-apks --bundle=app-release.aab --output=app-release.apks --ks=key.jks --ks-pass= --ks-key-alias=key --key-pass=
// step 3
java -jar bundletool-all-1.3.0.jar install-apks --apks=app-release.apks
I have also added following in my android build.gradle
aaptOptions {
noCompress 'tflite'
noCompress 'lite'
}
How is it possible to get a different result in release whereas the same code works in debug version of app? What am I missing in my setup?
NOTE: I can only test this on Android
UPDATE
Digging further, I ran the app in profile mode and found following logs (Note: These only show up in profile mode so I am not sure how far it is from the release version. Also, I don't get these error when running in debug):
2020-11-08 20:04:34.623 4869-4940/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference, java.lang.NullPointerException: Attempt to invoke virtual method 'org.tensorflow.lite.Tensor org.tensorflow.lite.Interpreter.getInputTensor(int)' on a null object reference
at sq.flutter.tflite.TflitePlugin.feedInputTensor(TflitePlugin.java:326)
at sq.flutter.tflite.TflitePlugin.feedInputTensorImage(TflitePlugin.java:371)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:477)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.Messag
...
2020-11-08 02:08:07.438 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.453 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.460 23087-23136/? I/qtaguid: Tagging socket 89 with tag 6b55000000000(439632) for uid -1 failed errno=-24
2020-11-08 02:08:07.460 23087-23136/? I/NetworkManagementSocketTagger: tagSocketFd(89, 439632, -1) failed with errno-24
2020-11-08 02:08:07.469 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.486 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.521 657-657/? I/chatty: uid=1000(system) /system/bin/surfaceflinger identical 2 lines
2020-11-08 02:08:07.540 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.542 22602-22654/com.flutterApp.gng I/flutter: Found 3 faces
2020-11-08 02:08:07.557 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.566 1449-2272/? W/StorageManager: getStorageLowBytes lowPercent : 5, lowBytes : 2861259366, maxLowBytes : 524288000
2020-11-08 02:08:07.577 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
2020-11-08 02:08:07.588 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.608 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
2020-11-08 02:08:07.622 657-657/? I/HWComposer: getActiveConfigs: Attempted to access invalid display -1
2020-11-08 02:08:07.641 22602-22654/com.flutterApp.gng I/flutter: PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy
at sq.flutter.tflite.TflitePlugin$TfliteTask.<init>(TflitePlugin.java:427)
at sq.flutter.tflite.TflitePlugin$RunModelOnImage.<init>(TflitePlugin.java:465)
at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:102)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1
As I don't see the behavior in debug mode, I am still confused on what is going on in the app when running the release version.

Related

Android CameraX VideoRecorder error > Encoder cannot created : null

I am building an Android app that records video using Camera X.
The probe in a Samsung A52 and it works correctly.
When running on a Galaxy Core A03 I get these errors:
E/Recorder: Unable to initialize video encoder.
androidx.camera.video.internal.encoder.InvalidConfigException: Encoder cannot created: null
at androidx.camera.video.internal.workaround.EncoderFinder.findEncoder(EncoderFinder.java:88)
at androidx.camera.video.internal.encoder.EncoderImpl.(EncoderImpl.java:214)
at androidx.camera.video.Recorder.setupVideo(Recorder.java:1294)
at androidx.camera.video.Recorder.initializeInternal(Recorder.java:998)
at androidx.camera.video.Recorder.lambda$onSurfaceRequested$0$androidx-camera-video-Recorder(Recorder.java:396)
at androidx.camera.video.Recorder$$ExternalSyntheticLambda16.run(Unknown Source:4)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:111)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7815)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1094)
Caused by: java.lang.NullPointerException
at android.media.MediaCodec.native_setup(Native Method)
at android.media.MediaCodec.(MediaCodec.java:1912)
at android.media.MediaCodec.createByCodecName(MediaCodec.java:1890)
at androidx.camera.video.internal.workaround.EncoderFinder.findEncoder(EncoderFinder.java:85)
at androidx.camera.video.internal.encoder.EncoderImpl.(EncoderImpl.java:214) 
at androidx.camera.video.Recorder.setupVideo(Recorder.java:1294) 
at androidx.camera.video.Recorder.initializeInternal(Recorder.java:998) 
at androidx.camera.video.Recorder.lambda$onSurfaceRequested$0$androidx-camera-video-Recorder(Recorder.java:396) 
at androidx.camera.video.Recorder$$ExternalSyntheticLambda16.run(Unknown Source:4) 
at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:111) 
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231) 
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7815) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1094) 
D/Recorder: Transitioning Recorder internal state: INITIALIZING --> ERROR
D/PreviewView: Surface requested by Preview.
D/SurfaceViewImpl: Surface created.
D/SurfaceViewImpl: Surface changed. Size: 960x720
D/PreviewView: Preview transformation info updated. TransformationInfo{cropRect=Rect(0, 0 - 960, 720), rotationDegrees=90, targetRotation=0}
D/PreviewTransform: Transformation info set: TransformationInfo{cropRect=Rect(0, 0 - 960, 720), rotationDegrees=90, targetRotation=0} 960x720 false
D/SurfaceViewImpl: Surface set on Preview.
D/SyncCaptureSessionBase: [androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl#d97cfb7] getSurface...done
D/Camera2CameraImpl: {Camera#1dd1e08[id=0]} Posting surface closed
java.lang.Throwable
at androidx.camera.camera2.internal.Camera2CameraImpl.postSurfaceClosedError(Camera2CameraImpl.java:1174)
at androidx.camera.camera2.internal.Camera2CameraImpl$2.onFailure(Camera2CameraImpl.java:1116)
at androidx.camera.core.impl.utils.futures.Futures$CallbackListener.run(Futures.java:340)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
D/DeferrableSurface: surface closed, useCount=0 closed=true androidx.camera.core.SurfaceRequest$2#3051f61
D/DeferrableSurface: Surface terminated[total_surfaces=2, used_surfaces=0](androidx.camera.core.SurfaceRequest$2#3051f61}
D/DeferrableSurface: Surface created[total_surfaces=3, used_surfaces=0](androidx.camera.core.SurfaceRequest$2#8dfc68e}
D/Recorder: Surface is requested in state: ERROR, Current surface: 0
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mrkevin574.teteo, PID: 16045
java.lang.IllegalStateException: Surface was requested when the Recorder had encountered error androidx.camera.video.internal.ResourceCreationException: androidx.camera.video.internal.encoder.InvalidConfigException: Encoder cannot created: null
at androidx.camera.video.Recorder.onSurfaceRequested(Recorder.java:406)
at androidx.camera.video.VideoCapture.createPipeline(VideoCapture.java:416)
at androidx.camera.video.VideoCapture.resetPipeline(VideoCapture.java:482)
at androidx.camera.video.VideoCapture.lambda$createPipeline$0$androidx-camera-video-VideoCapture(VideoCapture.java:433)
at androidx.camera.video.VideoCapture$$ExternalSyntheticLambda0.onError(Unknown Source:10)
at androidx.camera.camera2.internal.Camera2CameraImpl.lambda$postSurfaceClosedError$14(Camera2CameraImpl.java:1175)
at androidx.camera.camera2.internal.Camera2CameraImpl$$ExternalSyntheticLambda7.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7815)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1094)
V/FA: Recording user engagement, ms: 3688
D/TransportRuntime.SQLiteEventStore: Storing event with priority=HIGHEST, name=FIREBASE_CRASHLYTICS_REPORT for destination cct
D/TransportRuntime.JobInfoScheduler: Scheduling upload for context TransportContext(cct, HIGHEST, MSRodHRwczovL2NyYXNobHl0aWNzcmVwb3J0cy1wYS5nb29nbGVhcGlzLmNvbS92MS9maXJlbG9nL2xlZ2FjeS9iYXRjaGxvZ1xBSXphU3lCcnBTWVQ0RkZMMDlyZUhKaTZIOUZZZGVpU25VVE92Mk0=) with jobId=-1451806366 in 1000ms(Backend next call timestamp 1649111614302). Attempt 1
I/Process: Sending signal. PID: 16045 SIG: 9
here the code of getVideoCapture():
private fun getVideoCapture() : VideoCapture<Recorder>{
val qualitySelector = QualitySelector.fromOrderedList(
listOf(Quality.UHD, Quality.FHD, Quality.HD, Quality.SD),
FallbackStrategy.lowerQualityOrHigherThan(Quality.SD)
)
val recorder = Recorder.Builder()
.setExecutor(ContextCompat.getMainExecutor(requireContext()))
.setQualitySelector(qualitySelector)
.build()
return VideoCapture.withOutput(recorder)
}
I have it exactly as the Android documentation tells me.
I'm also having the same error after learning about CameraX at the following link https://developer.android.com/codelabs/camerax-getting-started
I think it's true what Morrison Chang said, there is something problem with Low End Android devices.
So I downgraded the quality of the Recorder contained inside the startCamera() function from HIGHEST to SD or HD and it's work.
val recorder = Recorder.Builder()
//.setQualitySelector(QualitySelector.from(Quality.HIGHEST))
.setQualitySelector(QualitySelector.from(Quality.SD))//change to Quality.SD or Quality.HD
.build()
videoCapture = VideoCapture.withOutput(recorder)

Android Emulator SDK--30 is not working with AR application [Google sceneform sdk]

We are developing an AR application with google-sceneform sdk, the app is getting crashed on Android 11 (Real Device) after the successful launch. we are able to identify the plane and place an object but after some time it will crash.
So we are trying it on emulator sdk-30. But after running the application it shows Failed to create AR Session.
I have followed the whole steps provided by Google in this Link but it didn't work.
Tried all the steps with android studio 4.1 and SDK-30 with emulator version 30.2.6 which is not worked.
The normal hand sign for scanning the surface is also not shown.
But with SDK-27 it worked. We need the sdk-30 to be worked.
Q1: is the emulator failing issue is a known issue? did anyone faced this before?
This is the log for Emulator.
2020-12-28 16:38:58.742 7153-7153/com.quintar.myapplication E/StandardArFragment: Error: Failed to create AR session
com.google.ar.core.exceptions.UnavailableException
at com.google.ar.sceneform.ux.BaseArFragment.initializeSession(BaseArFragment.java:391)
at com.google.ar.sceneform.ux.BaseArFragment.onResume(BaseArFragment.java:338)
#### SKIPPING SOME LINES HERE ####
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: com.google.ar.core.exceptions.FatalException: Failed to launch installer.
at com.google.ar.core.p.b(InstallService.java:53)
at com.google.ar.core.p.a(InstallService.java:40)
at com.google.ar.core.InstallActivity.startInstaller(InstallActivity.java:116)
at com.google.ar.core.InstallActivity.access$200(InstallActivity.java:125)
at com.google.ar.core.k.onClick(InstallActivity.java:3)
#### SKIPPING SOME LINES HERE ####
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: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.ar.core }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2067)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727)
Q2: it is very much appreciatable if anyone can help me to fix the on Android 11 crash issue.
this is crash log on Android 11 (Real device)
2020-12-21 14:19:01.868 14629-14629/? A/DEBUG: Abort message: 'Scudo ERROR: invalid chunk state when
deallocating address 0x0073944b2ea0
'
2020-12-21 14:19:02.415 14629-14629/? A/DEBUG: #03 pc 00000000000431bc
/apex/com.android.runtime/lib64/bionic/libc.so
(scudo::reportInvalidChunkState(scudo::AllocatorAction, void*)+76) (BuildId:
95f68a34fdf7b31f42d3f811d5d88f58)
2020-12-21 14:19:03.665 1091-6178/? E/AudioSystem: invalid attributes { Content type:
AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_UNKNOWN Source: -1 Flags: 0x800 Tags: } when
converting to stream
2020-12-21 14:19:06.839 895-1615/? E/soundtrigger: audio_extn_sound_trigger_update_stream_status:
invalid input device 0x0, for event 2
In file 'YourProject/app/build.gradle' set the next dependecies for Android Target API 30 with the last of AR Sceneform Library:
android {
defaultConfig {
...
targetSdkVersion 30
...
}
}
dependencies {
...
api "com.google.ar.sceneform:core:1.17.1"
api "com.google.ar.sceneform.ux:sceneform-ux:1.17.1"
api "com.google.ar:core:1.22.0"
...
}

Flutter can't detect 'model.tflite' file from assets folder (FileNotFoundException)

Background
I'm making a fruit classification app using flutter on android studio. The app will work as follows:
Take a picture with the camera.
Predict the type of fruit in the picture.
To do step (2), I'm using a 'model.tflite' file that was exported from teachable machine. I'm also using the tflite plugin for flutter.
The Problem
When my program tries to predict the image, I get the following message in the console:
E/MethodChannel#tflite( 7296): Failed to handle method call
E/MethodChannel#tflite( 7296): java.lang.IllegalArgumentException: Unsupported value: java.io.FileNotFoundException: flutter_assets/assets/model.tflite
E/MethodChannel#tflite( 7296): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:278)
E/MethodChannel#tflite( 7296): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:69)
E/MethodChannel#tflite( 7296): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:236)
E/MethodChannel#tflite( 7296): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:98)
E/MethodChannel#tflite( 7296): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#tflite( 7296): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#tflite( 7296): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#tflite( 7296): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#tflite( 7296): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#tflite( 7296): at android.os.Looper.loop(Looper.java:197)
E/MethodChannel#tflite( 7296): at android.app.ActivityThread.main(ActivityThread.java:7948)
E/MethodChannel#tflite( 7296): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#tflite( 7296): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#tflite( 7296): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
I/flutter ( 7296):
I/flutter ( 7296): ERROR: PlatformException(error, Unsupported value: java.io.FileNotFoundException: flutter_assets/assets/model.tflite, null)
Flutter can't seem to find the model.tflite file from my assets folder!
What I've tried
I have triple checked the indentations in pubspec.yaml (below). The file paths and names of directories are also correct.
flutter:
assets:
- assets/labels.txt
- assets/model.tflite
I have read the tflite docs.
I've downloaded the model.tflite as a floating point type and quantized type.
I have tried renaming the model.tflite file (you could tell I was getting desperate).
I have also tried changing certain parameters within my code. Below is the function where the error seems to be happening - it is called whenever the user takes a picture.
Future classifyImage() async {
try{
String res = await Tflite.loadModel(
model: 'assets/model.tflite',
labels: 'assets/labels.txt',
numThreads: 1,
isAsset: true,
useGpuDelegate: true
);
print(res);
var recognitions = await Tflite.runModelOnImage(
path: _image.path,
imageMean: 117.0,
imageStd: 1.0,
numResults: 1,
threshold: 0.5,
asynch: true,
);
_recognitions = recognitions;
await Tflite.close();
} catch (error){
print(' ');
print('ERROR: $error');
}
Here is a screenshot of my project directories.
I have also tried flutter clean, quitting android studio and restarting the project.
PLEASE HELP! I'm currently waiting for someone to float from the heavens and magically fix my problem. I'm also a beginner to flutter, so any general suggestions to my code would be greatly appreciated :-).
Thank you.
Go ahead and open the android / app / build.gradle file and add the following code inside the android block.
aaptOptions {
noCompress 'tflite'
noCompress 'lite'
}
I went on my project the next day and the error doesn't seem to be coming up. Not too sure what happened...
Perhaps it was something to do with my laptop?

Trying to create basic application using HERE Android Lite SDK

I am trying to run a basic example of an application with new Android Lite SDK from HERE and getting such error:
E/AndroidTangramPlatformBridge: parse
org.xmlpull.v1.XmlPullParserException: END_TAG expected (position:START_TAG (empty) <axis tag='wdth' stylevalue='100.0'>#279:51 in java.io.InputStreamReader#739274e)
at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2088)
at com.here.sdk.mapviewlite.FontFileParser.processDocument(Unknown Source:105)
at com.here.sdk.mapviewlite.FontFileParser.parse(Unknown Source:21)
at com.here.sdk.mapviewlite.FontFileParser.parse(Unknown Source:18)
at com.here.sdk.mapviewlite.AndroidTangramPlatformBridge.<init>(Unknown Source:33)
at com.here.sdk.mapviewlite.MapViewLite.onCreate(Unknown Source:6)
at com.here.hellomap.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:7458)
at android.app.Activity.performCreate(Activity.java:7448)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3409)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
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:2199)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
D/HwCustConnectivityManagerImpl: isBlockNetworkRequestByNonAis, INVALID_SUBSCRIPTION_ID
D/ActivityThread: add activity client record, r= ActivityRecord{d1ae1ac token=android.os.BinderProxy#853d260 {com.here.hellomap/com.here.hellomap.MainActivity}} token= android.os.BinderProxy#853d260
E/: [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
D/ZrHung.AppEyeUiProbe: notify runnable to start.
I/HwSecImmHelper: mSecurityInputMethodService is null
D/HwAppInnerBoostImpl: set config for com.here.hellomap BOOST_FLAG=false REPORT_DURATION_CLICK=1000 REPORT_TIMES_CLICK=3 REPORT_DURATION_SLIDE=5000 REPORT_TIMES_SLIDE=16
D/OpenGLRenderer: HWUI Binary is enabled
W/HiTouch_HiTouchSensor: depended package hiTouch does n't exist!
I/HiTouch_HiTouchSensor: HiTouch restricted: system app HiTouch don't exist.
D/HiTouch_PressGestureDetector: onAttached, package=com.here.hellomap, windowType=1, mHiTouchRestricted=true
E/analytics: [ERROR] analytics - Failed to get the authentication token: Authentication failed, error code: 1
E/analytics: [ERROR] analytics - Failed to get the authentication token: Authentication failed, error code: 1
[ERROR] analytics - Invalid access key
I/HwPhoneWindow: updateLayoutParamsColor false mSpecialSet=false, mForcedNavigationBarColor=false, navigationBarColor=ff000000, mNavBarShow=true, mIsFloating=false
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I see only a blank map on my HUAWEI P Smart (on Virtual device code runs normally).
Does anyone have an idea of how to solve it?
Please check authentication token for android Lite version. Also check for the permission java class that has to be correctly written. The accompanying example apps can be found on GitHub : https://github.com/heremaps/here-sdk-examples
To try out these examples, add your HERE credentials (access_key_id and access_key_secret) to the AndroidManifest.xml file, and add the HERE SDK to the libs folder.

CLJSRN Release Build Runtime Failure

I inherited this CLJS React Native codebase and I'm trying to upgrade the Android SDK to v26 with React 16.4 and RN 0.56. The debug build works great but the release build fails when starting up with the following call stack:
2018-11-21 10:31:30.731 16727-16790/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: XXX, PID: 16727
com.facebook.react.common.JavascriptException: Can't find variable: a, stack:
<unknown>#12:60553
<unknown>#12:60366
<unknown>#12:518500
c#2:822
i#2:394
t#2:324
global code#322:8
at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Any ideas on how to get the non-minified version of the call stack? Is the minification done by the cljs to js compiler? Or the RN bundler/packager?
I'm currently using advanced optimizations on the cljs to js compiler. If I switch it to whitespace optimizations, then I get a build error
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
I can work around it by doing the bundling separately
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/build/intermediates/assets/release/index.android.bundle --assets-dest /usr/src/app/android/app/build/intermediates/res/merged/release
But I hit another failure
Unable to load script from assets 'index.android.bundle'.
Any ideas what else I can try?
Update 1: The "Unable to load script from assets 'index.android.bundle'." error message was caused by the index.android.bundle file being placed in the wrong folder. The following command worked:
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/src/main/assets/index.android.bundle --assets-dest /usr/src/app/android/app/src/main/res/
The unminified call stack looks like:
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Exception: Can't find variable: document (index.android.bundle:1632)
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Stack: index.android.bundle:1632:43
loadModuleImplementation#index.android.bundle:162:14
guardedLoadModule#index.android.bundle:83:47
metroRequire#index.android.bundle:72:79
global code#index.android.bundle:1639:8
2018-11-27 15:07:00.749 23765-23859/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: XXX, PID: 23765
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
at com.facebook.react.bridge.CatalystInstanceImpl.access$1000(CatalystInstanceImpl.java:39)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 
Caused by: com.facebook.jni.CppException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 
APK worked OK after I restarted the RN upgrade process with react-native-git-upgrade. There was another issue after the upgrade with some unresolved symbol during runtime but that turned out to be an issue with the externs file because I had switched from the deprecated BackAndroid to BackHandler.

Categories

Resources