Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build Android version #19

Open
dslamnig opened this issue Dec 19, 2020 · 6 comments
Open

Can't build Android version #19

dslamnig opened this issue Dec 19, 2020 · 6 comments

Comments

@dslamnig
Copy link

dslamnig commented Dec 19, 2020

ColorSpaceType not found. Tried many versions of tensorflow libraries, always the same failure. App crashes after taking a picture.

[...]
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.e2etflite.segmentation_and_style_transfer, PID: 31987
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/tensorflow/lite/support/image/ColorSpaceType;
at org.tensorflow.lite.task.vision.segmenter.OutputType$1.createMasksFromBuffer(OutputType.java:74)
at org.tensorflow.lite.task.vision.segmenter.ImageSegmenter.segment(ImageSegmenter.java:224)
at org.tensorflow.lite.task.vision.segmenter.ImageSegmenter.segment(ImageSegmenter.java:176)
at com.e2etflite.sample.backgroundstylizer.ui.segmentation.SegmentationAndStyleTransferViewModel.cropPersonFromPhoto(SegmentationAndStyleTransferViewModel.kt:113)
at com.e2etflite.sample.backgroundstylizer.ui.segmentation.SegmentationAndStyleTransferFragment$onViewCreated$1.invokeSuspend(SegmentationAndStyleTransferFragment.kt:193)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.tensorflow.lite.support.image.ColorSpaceType" on path: DexPathList[[zip file "/data/app/com.e2etflite.segmentation_and_style_transfer-LymZPOPdqyQVEYQ9JNYlRA==/base.apk"],nativeLibraryDirectories=[/data/app/com.e2etflite.segmentation_and_style_transfer-LymZPOPdqyQVEYQ9JNYlRA==/lib/arm, /data/app/com.e2etflite.segmentation_and_style_transfer-LymZPOPdqyQVEYQ9JNYlRA==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
[,,,]

@amindadgar
Copy link

It seems the crash is happening in coroutine scope in the file SegmentationAndStyleTransferViewModel.kt line 113 . Share the code causing the problem, I may help you.

@dslamnig
Copy link
Author

I'm trying to build the project as cloned, no modifications. The code is in the repo.
Since the Android build is based mostly on nightly TensorFlow builds, maybe org.tensorflow.lite.support.image.ColorSpaceType class was moved to another package, or removed.

@amindadgar
Copy link

After hours of struggling with versions I got no success too.
I've seen this issue in library repo and I tried the answer but I got no success. I'll attach the link below it maybe help you.
tensorflow/tensorflow#30755

@margaretmz
Copy link
Owner

The error is due to a mismatch in the version for the TFlite Support library which is used by the other libraries such as the task API. Try the following:

  • Invalidate caches / Restart Android Studio
  • Add implementation('org.tensorflow:tensorflow-lite-support:0.0.0-nightly') { changing = true } to make sure you have the latest tflite support library.

@hdk24
Copy link

hdk24 commented Apr 30, 2021

used latest tflite support library implementation("org.tensorflow:tensorflow-lite-support:0.1.0")
https://github.com/tensorflow/tflite-support/releases/

@ridoy-ai
Copy link

For everyone visiting the thread, please use latest tflite support library to solve the issue, I used:
implementation("org.tensorflow:tensorflow-lite-support:0.2.0")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants