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
Related
I have tested bannerAds it is working correctly but when I try to load interstitial ad it crashes the app.
MinSdkVersion 29
I have tried to load the ad in initState and the build method separately.
Banner ads are running correctly.
InterstitialAd loadInterstitialAd() {
return InterstitialAd(
adUnitId: "ca-app-pub-3940256099942544/1033173712",
listener: AdListener(onAdLoaded: (_) {
setState(() {
_isAdLoaded = true;
});
}, onAdFailedToLoad: (_ad, error) {
_ad.dispose();
print("Ad Exited with error $error");
}, onAdClosed: (_ad) {
Navigator.pop(context);
_ad.dispose();
}),
request: AdRequest());
}
#override
Widget build(BuildContext context) {
InterstitialAd _ad = loadInterstitialAd();
_ad.load();
return Scaffold(
body: Center(
child: MaterialButton(
onPressed: () {},
color: Colors.red,
)
),
);
}
Error log is like
E/AndroidRuntime(22505): FATAL EXCEPTION: main
E/AndroidRuntime(22505): Process: tech.deepaksharma.statussaver, PID: 22505
E/AndroidRuntime(22505): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/InterstitialAd;
E/AndroidRuntime(22505): at io.flutter.plugins.googlemobileads.FlutterInterstitialAd.load(FlutterInterstitialAd.java:70)
E/AndroidRuntime(22505): at io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.onMethodCall(GoogleMobileAdsPlugin.java:299)
E/AndroidRuntime(22505): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/AndroidRuntime(22505): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/AndroidRuntime(22505): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/AndroidRuntime(22505): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(22505): at android.os.MessageQueue.next(MessageQueue.java:343)
E/AndroidRuntime(22505): at android.os.Looper.loop(Looper.java:188)
E/AndroidRuntime(22505): at android.app.ActivityThread.main(ActivityThread.java:7582)
E/AndroidRuntime(22505): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(22505): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(22505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
E/AndroidRuntime(22505): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.InterstitialAd" on path: DexPathList[[zip file "/data/app/tech.deepaksharma.statussaver-7ebD-4rtvclB1sSW4YF-Lw==/base.apk"],nativeLibraryDirectories=[/data/app/tech.deepaksharma.statussaver-7ebD-4rtvclB1sSW4YF-Lw==/lib/arm64, /data/app/tech.deepaksharma.statussaver-7ebD-4rtvclB1sSW4YF-Lw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
E/AndroidRuntime(22505): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime(22505): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(22505): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(22505): ... 12 more
I/Process (22505): Sending signal. PID: 22505 SIG: 9
Lost connection to device.
I had the same issue, and fixed it by adjusting some dependencies in my build.gradle file.
The problem seems to be caused by play-services-ads version 20, which moves the InterstitialAd class to the namespace "com.google.android.gms.ads.interstitial" (previously it was in namespace "com.google.android.gms.ads").
The Flutter plugin Google Mobile Ads version 0.12.1+1 uses play-services-ads version 19.7, so it tries to load the InterstitialAd class from the old namespace. The problem in my case is that we use Admob mediation, and we use third party mediation adapters. The latest versions of these adapters were using play-services-ads version 20, and that caused the issue. The solution for me was checking the change log in the Admob mediation page, for each adapter we use, and then include the version of the adapter using play-services-ads version 19.7. For example, we use:
implementation 'com.google.ads.mediation:adcolony:4.4.1.0'
implementation 'com.google.ads.mediation:applovin:9.15.2.0'
implementation 'com.google.ads.mediation:tapjoy:12.7.1.0'
implementation 'com.google.ads.mediation:facebook:6.3.0.1'
EDIT: Google just released the google_mobile_ads package version 0.13.0, which targets GMA for Android dependency version 20.1.0, so the issue will be gone if you update this package.
try updating to the latest Google Mobile Ads SDK first
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.
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?
As the title says, I'm trying to set up anonymous sign in using Firebase firestore for my Flutter app, but it crashes on Android. It works perfectly fine on iOS.
I set up Firebase for my app using the wizard found in the firebase console, and used all the suggested version numbers when configuring the android app.
My dependencies in the android/build.gradle file are as follows:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
And in the android/app/build.gradle file the following is set:
minSdkVersion 21
targetSdkVersion 28
I also downloaded and placed the google-services.json file into the path android/app
I know I'm connected to Firebase because I set up google analytics and I can see myself as an active user in the analytics panel
This is my set up for the anonymous sign in:
In the "auth.dart" file:
import 'package:firebase_auth/firebase_auth.dart';
class AuthService {
// this instance allows us to communicate with Firebase in the backend
final FirebaseAuth _auth = FirebaseAuth.instance;
// sign in anon
Future signInAnon() async {
try {
AuthResult result = await _auth.signInAnonymously();
FirebaseUser user = result.user;
return user;
} catch (e) {
print(e.toString());
return null;
}
}
and in the SignIn widget, where I use a button that calls the anonSignIn method:
GestureDetector(
onTap: () async {
dynamic result = await _auth.signInAnon();
if (result == null) {
print('error signing in');
} else {
print('anon user signed in');
print(result);
}
},
child: Text(
'Skip for now >',
style: TextStyle(color: eigthColor),
),
),
The app prints the right results for iOS in the debug console, but when running on Android, both the emulator and on a real device (Samsung), the app quits when the button is pressed and all that is shown in the debug console is below. I'm a development noob. Please help!
**
W/BiChannelGoogleApi(11081): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak#c8b9c14
E/AndroidRuntime(11081): Process: com.tsf.freshee_scratch, PID: 11081
E/AndroidRuntime(11081): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArrayMap;
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzam.zzc(Unknown Source:22)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzam.zzde(Unknown Source:17)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzam.zzdd(Unknown Source:8)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzan.zzdf(Unknown Source:1)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzm.isAnonymous(Unknown Source:47)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzat.zzi(Unknown Source:57)
E/AndroidRuntime(11081): at com.google.firebase.auth.internal.zzat.zzg(Unknown Source:10)
E/AndroidRuntime(11081): at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source:62)
E/AndroidRuntime(11081): at com.google.firebase.auth.FirebaseAuth$zzb.zza(Unknown Source:5)
E/AndroidRuntime(11081): at com.google.firebase.auth.api.internal.zzcl.zzdx(Unknown Source:13)
E/AndroidRuntime(11081): at com.google.firebase.auth.api.internal.zzen.zzen(Unknown Source:35)
E/AndroidRuntime(11081): at com.google.firebase.auth.api.internal.zzen.zza(Unknown Source:41)
E/AndroidRuntime(11081): at com.google.firebase.auth.api.internal.zzep.zza(Unknown Source:9)
E/AndroidRuntime(11081): at com.google.firebase.auth.api.internal.zzdx.dispatchTransaction(Unknown Source:9)
E/AndroidRuntime(11081): at com.google.android.gms.internal.firebase_auth.zza.onTransact(Unknown Source:13)
E/AndroidRuntime(11081): at android.os.Binder.execTransact(Binder.java:739)
E/AndroidRuntime(11081): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.util.ArrayMap" on path: DexPathList[[zip file "/data/app/com.tsf.freshee_scratch-RyjASMTcDx7DTMAHwjdqeg==/base.apk"],nativeLibraryDirectories=[/data/app/com.tsf.freshee_scratch-RyjASMTcDx7DTMAHwjdqeg==/lib/arm64, /data/app/com.tsf.freshee_scratch-RyjASMTcDx7DTMAHwjdqeg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
E/AndroidRuntime(11081): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
E/AndroidRuntime(11081): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(11081): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(11081): ... 16 more
D/ViewRootImpl#c13a6a1MainActivity: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager(11081): prepareNavigationBarInfo() DecorView#5990a33[MainActivity]
D/InputMethodManager(11081): getNavigationBarColor() -352319669
I/Process (11081): Sending signal. PID: 11081 SIG: 9
Lost connection to device.
Exited (sigterm)
**
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.