0
votes

I run a Tensorflow example (https://github.com/tensorflow/examples/blob/master/lite/examples/image_classification/android/README.md) on android studio and I get the following error.

E/AndroidRuntime: FATAL EXCEPTION: main Process: org.tensorflow.lite.examples.classification, PID: 18855 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.tensorflow.lite.examples.classification/org.tensorflow.lite.examples.classification.ClassifierActivity}: java.lang.ClassNotFoundException: Didn't find class "org.tensorflow.lite.examples.classification.ClassifierActivity" on path: DexPathList[[zip file "/data/app/org.tensorflow.lite.examples.classification-1/base.apk"],nativeLibraryDirectories=[/data/app/org.tensorflow.lite.examples.classification-1/lib/arm64, /data/app/org.tensorflow.lite.examples.classification-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2625) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6238) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.tensorflow.lite.examples.classification.ClassifierActivity" on path: DexPathList[[zip file "/data/app/org.tensorflow.lite.examples.classification-1/base.apk"],nativeLibraryDirectories=[/data/app/org.tensorflow.lite.examples.classification-1/lib/arm64, /data/app/org.tensorflow.lite.examples.classification-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.Instrumentation.newActivity(Instrumentation.java:1079) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2615) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6238) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) I/Process: Sending signal. PID: 18855 SIG: 9

1
Kindly provide your Activity code here and exactly which block of code is making this issue. This log is not enough. - Usman Khan
Can you describe all the steps that you have followed from the moment that you cloned github repo until the error message please? - Theo Itzaris
I cloned the example, i imported it in android File ->Open->\examples-master\examplesmaster\lite\examples\image_classification\android\app\src\mainstudio and then i run it and i took this message - Anatoli Stampolou
try importing it using the path in my answer that stops with the android folder and doesn't go inside the src folder. I've tried it twice now and it works fine on my laptop. - Nikos Hidalgo
@NikosHidalgo File->C:\examples-master\lite\examples\image_classification\android thats my path. Can you tell me please the android version? When i did build project everything goes well when i run it can't install it either on emulator or my device. - Anatoli Stampolou

1 Answers

0
votes

If you download the project from github it has many subfolders that you don't need and some of them that you shouldn't use (eg. ios related folders). If you want to run the android version then in Android studio try to open the project not from the master folder, but from the following subpath:

examples-master/lite/examples/image_classification/android

then let gradle download all dependencies and build your project (Build -> Make Project). If you're getting a "Select SDK" error when you're trying to run it, just do a File-> Sync project with gradle files and you should be able to run it just fine after that!