hereismari / mnist-android-tensorflow

Handwritten digits classification from MNIST with TensorFlow on Android; Featuring Tutorial!
327 stars 66 forks source link

Run on Android drive crash #4

Closed LtveG closed 7 years ago

LtveG commented 7 years ago

Hi, I have run the code on Android Studio well without any error. BUT run on my Android drive (API16) ,the code crash! and get this error :

E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1 java.lang.NoSuchMethodError: android.os.Trace.beginSection at org.tensorflow.contrib.android.TensorFlowInferenceInterface.load(TensorFlowInferenceInterface.java:385) at org.tensorflow.contrib.android.TensorFlowInferenceInterface.initializeTensorFlow(TensorFlowInferenceInterface.java:91) at mariannelinhares.mnistandroid.Classifier.create(Classifier.java:62) at mariannelinhares.mnistandroid.MainActivity$1.run(MainActivity.java:100) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856) Anyone can help me? Thank u very much

hereismari commented 7 years ago

Not sure @LtveG but it seems it didn't recognize TensorFlow lib "java.lang.NoSuchMethodError" or something similar. You can check that, but not really sure, good luck though!

Charles808 commented 7 years ago

I also had the same problem. The weird thing is, It only happened in certain device. Any suggestion ?

hereismari commented 7 years ago

Hey Charles808, weird. Not sure how to fix it, but I'll try to have a look.

Charles808 commented 7 years ago

Yes, it's weird.

It works on my LG G3. But it doesn't work on Galaxy S6, Galaxy S7 and also LG G6

So, I don't think it is because of the wrong .so for specific ARM arch.

I tried to commented out every use of Trace.beginSection, but it is still persist. I also tried to change the .so and .jar to the nightly build at #150. Same problem.

The error message is the same as @LtveG . .

Charles808 commented 7 years ago

Hi, @mari-linhares !

I already found the cause of the error.

It's quite simple and stupid of me though. It is because I run it on device with API level of 17

While, the Trace used by Tensorflow library is only available starting from API level 18.

I have two solution for this :

  1. Used device with API level above 17
  2. Re-compile the tensorflow library and commented out the line using Trace function

Both will works.

And, please ignore what I said before in the first post. In S6, S7 and G6 is actually having a different error.

Sorry and Thank you !

hereismari commented 7 years ago

Awesome, good to know you found a solution, I'll update the bug!