I am following the Codelab: https://codelabs.developers.google.com/codelabs/mlkit-android-custom-model/#0 and it works as it is, but as soon as I remove the provided local model to force using the cloud model, I get an obscure error.
What I do different to the codelab is:
// manager.registerLocalModelSource(localModelSource)
manager.registerCloudModelSource(cloudSource)
return FirebaseModelOptions.Builder()
.setCloudModelName(HOSTED_MODEL_NAME)
// .setLocalModelName("asset")
.build()
Commenting out the "local" model configuration, so I force the project to use the hosted ML Kit model.
However, I get the following error when running my model:
E/MainActivity: com.google.firebase.ml.common.FirebaseMLException: The load task failed
com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.ml.common.FirebaseMLException: The load task failed
at com.google.android.gms.tasks.zzu.getResult(Unknown Source:17)
at work.beltran.mlkitcustommodelcodelab.MainActivity$onCreate$$inlined$use$lambda$1.then(MainActivity.kt:61)
at com.google.android.gms.tasks.zzd.run(Unknown Source:26)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6590)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.google.firebase.ml.common.FirebaseMLException: The load task failed
at com.google.android.gms.internal.firebase_ml.zzgy.zzf(Unknown Source:75)
at com.google.android.gms.internal.firebase_ml.zzgu.call(Unknown Source:8)
at com.google.android.gms.internal.firebase_ml.zzgp.zza(Unknown Source:0)
at com.google.android.gms.internal.firebase_ml.zzgq.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:172)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: com.google.firebase.ml.common.FirebaseMLException: Cannot load custom model
at com.google.android.gms.internal.firebase_ml.zzhn.zzey(Unknown Source:148)
at com.google.android.gms.internal.firebase_ml.zzha.zzfb(Unknown Source:75)
at com.google.android.gms.internal.firebase_ml.zzha.call(Unknown Source:0)
at com.google.android.gms.internal.firebase_ml.zzgp.zza(Unknown Source:0)
at com.google.android.gms.internal.firebase_ml.zzgq.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:172)
at android.os.HandlerThread.run(HandlerThread.java:65)
My project can be found here: https://github.com/miquelbeltran/codelab-mlkit-android-custom-model/tree/4aa336d9efca6eafcd01acc9417ad194aa12233e
Some stuff I tried:
My project has internet permission and Firebase Analytics works, as I can see events on the DebugView.
The local model is the same as the hosted model in ML Kit.
The model name is correct.
Running on a rooted emulator, navigating to the app data folder, I can find my models folder named like this:
/data/data/work.beltran.mlkitcustommodelcodelab/no_backup/com.google.firebase.ml.custom.models/W0RFRkFVTFRd+MTo2ODI2MzU4OTg3OTY6YW5kcm9pZDozMGYwZDA3MmQ5NDBjODEx/mobilenet
However the folder is empty
My only guess: Firebase decides to not to download the model for some reason, can't figure out why.
I had to add the SHA certificate fingerprints to make it work.
If you are missing that step, the ML model will not be downloaded.
Follow the instructions here to generate the SHA for your certificates: https://developers.google.com/android/guides/client-auth
And introduce the output on your device project settings.
Related
I have uploaded (updated) my apk in google play console. After upload to google play I just download it from play store and installed. It crash when I try to open the app.
My app created in ionic 3.
It not working only after I upload into google play.
My SHA1 certificate are also properly presented.
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to create application com.gae.scaffolder.plugin.Application: com.gae.scaffolder.plugin.MessageGuardException_RFA6IDMwNA: DP: 304 (RmluZ2VycHJpbnQgMjAxOTA3MDIgWy4rKysrLl0gYXJtZWFiaS12N2E6YXJtZWFiaS12N2EgMjYvMi4xLjAvLSBtb3Rvcm9sYS9hbGkvYWxpOjguMC4wL09QUzI3LjgyLTQ1LzU2OnVzZXIvcmVsZWFzZS1rZXlz)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5838)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1674)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by: com.gae.scaffolder.plugin.MessageGuardException_RFA6IDMwNA: DP: 304 (RmluZ2VycHJpbnQgMjAxOTA3MDIgWy4rKysrLl0gYXJtZWFiaS12N2E6YXJtZWFiaS12N2EgMjYvMi4xLjAvLSBtb3Rvcm9sYS9hbGkvYWxpOjguMC4wL09QUzI3LjgyLTQ1LzU2OnVzZXIvcmVsZWFzZS1rZXlz)
at com.gae.scaffolder.plugin.Application.onCreate(Unknown Source:169)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5835)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1674)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by: java.lang.UnsatisfiedLinkError: DP: 304
at com.gae.scaffolder.plugin.Application$Application.wuxig(Unknown Source:690)
at java.lang.reflect.Method.invoke(Native Method)
at com.gae.scaffolder.plugin.Application$Application.Honlx(Unknown Source:99)
at com.gae.scaffolder.plugin.Application$Application.loqunIlzz(Unknown Source:201)
at java.lang.reflect.Method.invoke(Native Method)
at com.gae.scaffolder.plugin.Application.onCreate(Unknown Source:117)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5835)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1674)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
So i download my apk from google play console. I have two apks in there, derived apk and original apk.
What is different between two?
My original apk works well but derived apk crash. Why?
Thanks in advance.
You possibly have some anti-tampering mechanism in place that checks either the integrity of the AndroidManifest.xml file or verifies the certificate your app is signed with.
Because your app is enrolled in App Signing by Play, Play adds one meta-data in the manifest and re-signs your APK (that's the "derived APK"), and it seems that the anti-tampering library you're using is not friendly to this practice thus crashes when detects one of these modifications.
If you use dexguard, make sure to use a version past 8.3: https://www.guardsquare.com/en/blog/dexguard-83-released
It works well if I download the model from Firebase but it doesn't work if I try to replace the model with a manually trained model in TF which was then converted to tf-lite.
Do you think it's a limitation of AutoML or just something I missed in the conversion process?
Here is the error message:
2020-05-13 12:06:42.189 10296-10368/com.google.firebase.samples.apps.mlkit E/ODAutoMLImgLabelerTask: Error while loading the AutoML image labeling model.
android.os.RemoteException
at com.google.firebase.ml.vision.automl.zzj.zzol(com.google.firebase:firebase-ml-vision-automl##18.0.5:89)
at com.google.android.gms.internal.firebase_ml.zzso.zzol(com.google.firebase:firebase-ml-vision##24.0.3:78)
at com.google.android.gms.internal.firebase_ml.zzqr.zzf(com.google.firebase:firebase-ml-common##22.1.1:53)
at com.google.android.gms.internal.firebase_ml.zzqr$zza.zzoo(com.google.firebase:firebase-ml-common##22.1.1:7)
at com.google.android.gms.internal.firebase_ml.zzqr$zza.call(com.google.firebase:firebase-ml-common##22.1.1:24)
at com.google.android.gms.internal.firebase_ml.zzpx.zza(com.google.firebase:firebase-ml-common##22.1.1:32)
at com.google.android.gms.internal.firebase_ml.zzpw.run(com.google.firebase:firebase-ml-common##22.1.1)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(com.google.firebase:firebase-ml-common##22.1.1:6)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.firebase.ml.common.FirebaseMLException: Local model load failed with the model options: Local model path: automl/manifest.json. Remote model name: unspecified.
at com.google.firebase.ml.common.internal.modeldownload.zzj.zza(com.google.firebase:firebase-ml-common##22.1.1:36)
at com.google.firebase.ml.vision.automl.zzj.zzol(com.google.firebase:firebase-ml-vision-automl##18.0.5:85)
at com.google.android.gms.internal.firebase_ml.zzso.zzol(com.google.firebase:firebase-ml-vision##24.0.3:78)
at com.google.android.gms.internal.firebase_ml.zzqr.zzf(com.google.firebase:firebase-ml-common##22.1.1:53)
at com.google.android.gms.internal.firebase_ml.zzqr$zza.zzoo(com.google.firebase:firebase-ml-common##22.1.1:7)
at com.google.android.gms.internal.firebase_ml.zzqr$zza.call(com.google.firebase:firebase-ml-common##22.1.1:24)
at com.google.android.gms.internal.firebase_ml.zzpx.zza(com.google.firebase:firebase-ml-common##22.1.1:32)
at com.google.android.gms.internal.firebase_ml.zzpw.run(com.google.firebase:firebase-ml-common##22.1.1)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(com.google.firebase:firebase-ml-common##22.1.1:6)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.IllegalArgumentException: Internal error: Cannot create interpreter: Didn't find op for builtin opcode 'MUL' version '2'
Registration failed.
Think it is a problem in the conversion/implementation in Android Studio.
I got the same problem but could not solve it.
I tested it with a .tflite from teachable machine and there were no problem...
I've been working on an Android project recently which required me to implement Google Sign-In feature in one the activity using Firebase. There's this unusual problem that I'm facing:
Whenever I build the program on my Android phone the google sign-in works fine. Enabling me to sign in easily.
(I commit my code to Github)
Now when my mentor fetches the updated code from GitHub and builds the project on his phone, the Google Sign-In does not work i.e. he's unable to log in.
He gets the following error:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Code: 12500, message: 12500:
at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:109)
at com.firebase.ui.auth.ui.idp.SingleSignInActivity.onActivityResult(SingleSignInActivity.java:128)
at android.app.Activity.dispatchActivityResult(Activity.java:7317)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4436)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4484)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1743)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
However, when I send him the APK build on my system it works fine on his device.
What could be the possible reason for this and how do I solve this problem?
I've a multi feature app.
Installed App version works perfectly.
n
Instant App version was working till yesterday. Now I can build it correctly but I get this error when trying to install any of the instant modules.
Does anyone have the same issue ?
I cannot understand the error message:
Failed to finalize session : INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed parse during installPackageLI: Failed to read manifest from /data/app/vmdl138992238.tmp/base.apk: For input string: "otb"
I do not have any otb string.
otb is a the name of a feature module, but not the one I'm tring to install
EDIT:
I tried to rename the module otb to ootb. I got the same error having it "For input string: "ootb""
also I retrieved the logcat stacktrace:
07-01 01:51:37.516 776-817/? W/PackageManager: Failed parse during installPackageLI
android.content.pm.PackageParser$PackageParserException: Failed to read manifest from /data/app/vmdl1025494079.tmp/base.apk
at android.content.pm.PackageParser.parseBaseApk(PackageParser.java:1252)
at android.content.pm.PackageParser.parseClusterPackage(PackageParser.java:1133)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:952)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:966)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:16828)
at com.android.server.pm.PackageManagerService.installPackageTracedLI(PackageManagerService.java:16767)
at com.android.server.pm.PackageManagerService.-wrap29(Unknown Source:0)
at com.android.server.pm.PackageManagerService$7.run(PackageManagerService.java:14255)
at android.os.Handler.handleCallback(Handler.java:769)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Caused by: java.lang.NumberFormatException: For input string: "ootb"
at java.lang.Integer.parseInt(Integer.java:608)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:133)
at android.content.res.TypedArray.getInt(TypedArray.java:373)
at android.content.pm.PackageParser.parseActivity(PackageParser.java:4184)
at android.content.pm.PackageParser.parseBaseApplication(PackageParser.java:3612)
at android.content.pm.PackageParser.parseBaseApkCommon(PackageParser.java:2103)
at android.content.pm.PackageParser.parseBaseApk(PackageParser.java:1984)
at android.content.pm.PackageParser.parseBaseApk(PackageParser.java:1236)
at android.content.pm.PackageParser.parseClusterPackage(PackageParser.java:1133)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:952)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:966)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:16828)
at com.android.server.pm.PackageManagerService.installPackageTracedLI(PackageManagerService.java:16767)
at com.android.server.pm.PackageManagerService.-wrap29(Unknown Source:0)
at com.android.server.pm.PackageManagerService$7.run(PackageManagerService.java:14255)
at android.os.Handler.handleCallback(Handler.java:769)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Ok I maybe found the source of the problem for anyone having the same issue.
This may be related to android O SDK (API 26).
Compiling and targeting API 26 works correctly for classical app but is giving this error for instant apps at install time.
Rolling back to compile SDK 25 solved the problem in my case.
I'll wait for the final API/gradle plugin before tryng again.
I recently checked for my GP crash logs and I am getting this callstack very frequently. Could you please help me.
A few things:
The failed to add asset path sometimes shows /data/app/com.xxx.xxx.xxx-x/base.apk and sometimes /mnt/asec/com.xxx.xxx.xxx-x/base.apk.
The device android versions (where it is reported) varies from Android 4.4. to Android 7.0
In the GP console, Android version shows Android 7.0 for all crashes but the device list has devices with Android version 6.0, 5.0, etc which is unclear.
I have two apps with shared user Id, say with package names P1, P2. For P1, the failed to add asset path sometimes shows /data/app/P2 and sometimes /mnt/asec/P1. Isn't this incorrect and what could cause this?
Call stacks:
java.lang.RuntimeException: Unable to create BackupAgent android.app.backup.FullBackupAgent: android.content.res.Resources$NotFoundException: failed to add asset path data/app/com.P2.xxx/base.apk
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:3452)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.content.res.Resources$NotFoundException: failed to add asset path /data/app/com.P2.xxx/base.apk
at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:281)
at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:359)
at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:638)
at android.app.ResourcesManager.getResources(ResourcesManager.java:730)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2068)
at android.app.LoadedApk.getResources(LoadedApk.java:780)
at android.app.ContextImpl.<init>(ContextImpl.java:2244)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2184)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2175)
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:3422)
Another crash:
android.content.res.Resources$NotFoundException: failed to add asset path /mnt/asec/com.P1.xxx/base.apk
at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:281)
at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:359)
at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:638)
at android.app.ResourcesManager.getResources(ResourcesManager.java:730)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2052)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2266)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2210)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2196)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5861)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1710)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
Please check if the App has external drive permissions.
In my case this issue triggered when ADB installed the App to the device which is screen locked, the same test has passed when the device is awake, so even though permissions available to this App
I have this error for com.android.billingclient:billing. Problem is "there is no account in the device", for example a new device or reset to vendor settings.
So just add an account in global settings.