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

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?

Related

UnityWidget crashing upon loading using flutter_unity_widget

Ive created a simple flutter program to test out the plugin on flutter. ive set up a simple unity project with a button and imported it using the plugin to the flutter project. everything builds up correctly and my app runs, however the app crashes upon loading the UnityWidget
To Reproduce
Steps to reproduce the behavior:
create simple app in unity and flutter
exported unity as per instructions on Readme
moved unityLibrary from 'project Root/unity/android' to 'project Root/android' in order to fix unityLibrary not found build error
UnityWidgetController? overallController;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Second Route'),
),
body: SafeArea(
top: true,
bottom: true,
child: Stack(
children: [
UnityWidget(
onUnityCreated: onUnityCreate,
borderRadius: BorderRadius.zero,
),
],
),
),
);
}
void onUnityCreate(UnityWidgetController controller) {
overallController = controller;
controller.postMessage("ButtonManager", "setFromFlutter", "message");
}
**Unity (please complete the following information): ver 2020.3.5f1
OS: MacOS BigSur 11.4 (20F71)
Smartphone (please complete the following information):
OnePlus 5T Android 10
heres the error message
W/Gralloc3(31563): mapper 3.x is not supported
I/IL2CPP (31563): JNI_OnLoad
E/_flutter_widge(31563): Invalid ID 0x00000000.
D/AndroidRuntime(31563): Shutting down VM
E/AndroidRuntime(31563): FATAL EXCEPTION: main
E/AndroidRuntime(31563): Process: com.example.unity_flutter_widget, PID: 31563
E/AndroidRuntime(31563): android.content.res.Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime(31563): at android.content.res.Resources.getText(Resources.java:367)
E/AndroidRuntime(31563): at android.content.res.Resources.getString(Resources.java:460)
E/AndroidRuntime(31563): at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
E/AndroidRuntime(31563): at com.unity3d.player.UnityPlayer.<init>(Unknown Source:271)
E/AndroidRuntime(31563): at com.xraph.plugin.flutter_unity_widget.UnityPlayerUtils$Companion$createPlayer$1.run(UnityPlayerUtils.kt:45)
E/AndroidRuntime(31563): at android.os.Handler.handleCallback(Handler.java:883)
E/AndroidRuntime(31563): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(31563): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31563): at android.app.ActivityThread.main(ActivityThread.java:7697)
E/AndroidRuntime(31563): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31563): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E/AndroidRuntime(31563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
D/ViewRootImpl[MainActivity](31563): windowFocusChanged hasFocus=false inTouchMode=true
I/Process (31563): Sending signal. PID: 31563 SIG: 9
Lost connection to device.
Exited (sigterm)
After a few days of googling, i managed to find the answer.
After exporting to android, i needed to enter this
<string name="game_view_content_description">Game view</string>
into the styles.xml file, within the resources tag
it is located in unityLibrary/src/main/res/values

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 tflite plugin not doing recognitions in release version of app

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.

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