RuntimeException: Unable to start activity ComponentInfo(tensorflow.lite.examples)

#help_request #tflite

I am working on this project: TensorFlow Lite image classification Android example application

I run this project on my own phone (xiaomi redmi note 8) on Android Studio (not emulator)

When I run this project on Android Studio, TFL Classify applications gives the following error: application keep stopping.

Then Android Studio gives this error:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.tensorflow.lite.examples.classification, PID: 7599
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.tensorflow.lite.examples.classification/org.tensorflow.lite.examples.classification.ClassifierActivity}: java.lang.IllegalArgumentException: No enum constant org.tensorflow.lite.examples.classification.tflite.Classifier.Model.QUANTİZED_EFFİCİENTNET
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3119)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
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:1839)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6864)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalArgumentException: No enum constant org.tensorflow.lite.examples.classification.tflite.Classifier.Model.QUANTİZED_EFFİCİENTNET
at java.lang.Enum.valueOf(Enum.java:258)
at org.tensorflow.lite.examples.classification.tflite.Classifier$Model.valueOf(Classifier.java:47)
at org.tensorflow.lite.examples.classification.CameraActivity.onCreate(CameraActivity.java:195)
at android.app.Activity.performCreate(Activity.java:7232)
at android.app.Activity.performCreate(Activity.java:7221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2964)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3119)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
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:1839)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6864)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

I updated SDK version 28 to 29.0.2 but it didn’t work

1 Like

@Ugur_Ercelik Please give us a link of the project that it has a problem to take a look.

1 Like

I wanted to put the link, but I got an error “Sorry, you can’t include links in your posts.”
So i put like this
Project link :

github.com.tensorflow.examples.tree.master.lite.examples.image_classification.android

1 Like

Hi @Ugur_Ercelik it seems that the project builds OK to my AS.
Download again the projects from here go to the image_classification/android folder and build it again.

Also check that inside Classifier.java file there is:

/** The model type used for classification. */
  public enum Model {
    FLOAT_MOBILENET,
    QUANTIZED_MOBILENET,
    FLOAT_EFFICIENTNET,
    QUANTIZED_EFFICIENTNET
  }

Best

3 Likes

Yes thats right.The error is caused by UI string.I looked app->res->values->strings.xml

And there,like this
Quantized_Efficientnet
Float_Efficientnet
Quantized_MobileNet
Float_Mobilenet

Then,i changed like this

QUANTIZED_EFFICIENTNET
FLOAT_EFFICIENTNET
QUANTIZED_MOBILENET
FLOAT_MOBILENET

And problem is solved.Thanks for your opinion

2 Likes