我已经运行了Android示例TF-Lite应用,并且没有错误,但是如果我尝试使用Android.mk在AOSP中构建相同的示例应用(SpeechActivity部分),则会出现以下错误。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.mmiservice/com.mycompany.mmiservice.SpeechActivity}: java.lang.IllegalArgumentException: Invalid handle to Interpreter.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2820)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6565)
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:767)
Caused by: java.lang.IllegalArgumentException: Invalid handle to Interpreter.
at org.tensorflow.lite.NativeInterpreterWrapper.resizeInput(Native Method)
at org.tensorflow.lite.NativeInterpreterWrapper.resizeInput(NativeInterpreterWrapper.java:155)
at org.tensorflow.lite.Interpreter.resizeInput(Interpreter.java:191)
at com.mycompany.mmiservice.SpeechActivity.onCreate(DummyActivity.java:143)
我已将相同下载的conv_actions_frozen.tflite和conv_action_labels.txt添加到“ / assets”目录,并在Android.mk中按如下所示进行指定。
LOCAL_ASSET_FILES += $(call find-subdir-assets)
错误日志似乎表明模型未正确加载到Interpreter中。
有人可以建议我做错了吗?