XiaoMi / mace

MACE is a deep learning inference framework optimized for mobile heterogeneous computing platforms.
Apache License 2.0
4.94k stars 819 forks source link

安卓部署后会闪退 #591

Closed CheungBH closed 4 years ago

CheungBH commented 4 years ago

你好,我尝试在安卓上跑demo,发现会闪退,然后出现以下报错信息。这是什么原因啊

java.lang.RuntimeException: java.lang.AssertionError: Already disposed: Project (Disposed) demo_mace at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:179) at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:678) at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:683) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:373) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.doWriteAction(ExternalSystemApiUtil.java:392) at com.intellij.openapi.externalSystem.service.project.manage.ReprocessContentRootDataActivity$runActivity$1.run(ReprocessContentRootDataActivity.kt:42) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.AssertionError: Already disposed: Project (Disposed) demo_mace at com.intellij.openapi.components.impl.ComponentManagerImpl.lambda$throwAlreadyDisposed$1(ComponentManagerImpl.java:245) at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:53) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:973) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57) at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53) at com.intellij.openapi.components.impl.ComponentManagerImpl.throwAlreadyDisposed(ComponentManagerImpl.java:243) at com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:236) at com.intellij.openapi.components.impl.ComponentManagerImpl.getComponent(ComponentManagerImpl.java:146) at com.intellij.openapi.roots.ProjectRootManager.getInstance(ProjectRootManager.java:42) at com.intellij.openapi.roots.ex.ProjectRootManagerEx.getInstanceEx(ProjectRootManagerEx.java:26) at com.intellij.openapi.externalSystem.service.project.AbstractIdeModifiableModelsProvider.commit(AbstractIdeModifiableModelsProvider.java:432) at com.intellij.openapi.externalSystem.service.project.manage.ReprocessContentRootDataActivity$runActivity$1$5.run(ReprocessContentRootDataActivity.kt:42) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1057) at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$doWriteAction$7(ExternalSystemApiUtil.java:392) at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315) at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:156) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762) at java.awt.EventQueue.access$500(EventQueue.java:98) at java.awt.EventQueue$3.run(EventQueue.java:715) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:732) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:755) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:704) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

lu229 commented 4 years ago

@CheungBH 这个是android studio软件的错误信息,对诊断问题没有帮助。可以贴一下出错的adb logcat日志看看。

CheungBH commented 4 years ago

Screenshot from 2020-02-05 09-47-22

你好logcat截图显示是有点东西找不到。我想问下这是环境没配置好还是有哪一步没执行,还是缺了什么文件呢?

CheungBH commented 4 years ago

2020-02-05 09:47:10.822 3296-3358/? E/AndroidRuntime: FATAL EXCEPTION: jniThread Process: com.xiaomi.mace.demo, PID: 3296 java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1016) at java.lang.System.loadLibrary(System.java:1672) at com.xiaomi.mace.JniMaceUtils.(JniMaceUtils.java:20) at com.xiaomi.mace.JniMaceUtils.maceMobilenetCreateGPUContext(Native Method) at com.xiaomi.mace.demo.AppModel$1.run(AppModel.java:44) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:216) at android.os.HandlerThread.run(HandlerThread.java:65)

好像图片附不上去...

lu229 commented 4 years ago

@CheungBH 是android编译问题导致,在 Application.mk 中添加 APP_STL := c++_shared应该就好了, 可以网上搜一下,比如这个,里面有谈到这个问题。

CheungBH commented 4 years ago

但我在整个项目里面都没找到.mk文件,是要自己新建还是会系统自己编译出来的?新建的话建在哪里,编译的话我又缺了哪一步呢..

lu229 commented 4 years ago

@CheungBH 如果是使用的Gradle的话,可以在build.gradle中为cmake添加“-DANDROID_STL=c++_shared”参数,可参考这个文章

顺便问一下,我这边刚发现您编译的是mace Android example, 一般情况是不会有这个问题的,你那边NDK的版本是?

CheungBH commented 4 years ago

r15c。我现在想起来我跑的这个是半年多前clone下来的。好像中途更新过?会不会是这个原因

lu229 commented 4 years ago

@CheungBH ,那怪不得,您用r17或以上吧,应该就没有这个问题了。如果必须要使用r15,可以按照前面说的方法那么去改。

CheungBH commented 4 years ago

好的我试试!谢谢。 想知道是不是docker bazel这些都没有改版过?就是我重新装NDK,然后clone下mace和mace-models,按之前的步骤做就行了? 还有一个问题想求证一下。我之前5月跑通过demo。但是这次跑,怎么都没有mace_runtime.h这个文件,这也是改版的原因不

lu229 commented 4 years ago

@CheungBH docker和bazel基本没有改版,不需要重新装NDK,两个NDK可以共存,装完NDK17之后,让您的gradle使用的ndk切换成r17就可以了。 mace_runtime.h没有了是我们的代码进行了修改,删除掉了。

CheungBH commented 4 years ago

你好,我重新弄了一下,然后在终端进行 adb install ./app/build/outputs/apk/app/release/app-app-release.apk 可以跑通了,谢谢~

不过还有个问题,当我在Android studio里面跑的时候,会有问题这个报错 Cause: buildOutput.apkData must not be null

logcat里面是这样的 2020-02-06 21:39:20.807 748-748/? E/Thermal-daemon: [charger_ic] temp_new :27 temp_old :28 2020-02-06 21:39:20.809 748-748/? E/Thermal-daemon: Report temperature: [charger_ic] temp :27 report_threshold:1 2020-02-06 21:39:20.811 748-748/? E/Thermal-daemon: [ap] temp_new :27 temp_old :28 2020-02-06 21:39:20.813 748-748/? E/Thermal-daemon: Report temperature: [ap] temp :27 report_threshold:1 2020-02-06 21:39:25.813 748-748/? E/Thermal-daemon: [battery] temp_new :25 temp_old :24 2020-02-06 21:39:25.815 748-748/? E/Thermal-daemon: Report temperature: [battery] temp :25 report_threshold:1 2020-02-06 21:39:26.654 1914-2464/? E/HwNaturalBase: [DLMJob-2]: [DLM] execute a invalid policy, skip. exp:Get earliest item time failed, table: com.huawei.nb.model.collectencrypt.RawUserInfoStatistic 2020-02-06 21:39:26.655 1914-2464/? E/HwNaturalBase: [DLMJob-2]: [DLM] execute a invalid policy, skip. exp:Get earliest item time failed, table: com.huawei.nb.model.collectencrypt.RawAppProbe 2020-02-06 21:39:26.821 1914-2464/? E/HwNaturalBase: [DLMJob-2]: [DLM] execute a invalid policy, skip. exp:Get earliest item time failed, table: com.huawei.nb.model.collectencrypt.RawCellRecord 2020-02-06 21:39:28.879 1866-3484/? E/HsmCoreServiceImpl: onTransact in code is: 102 2020-02-06 21:39:29.863 1866-2212/? E/Hicom_PolicyCenterService: unrecognized exception captured during handleMessage: 75 exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.huawei.systemserver.emcom.policycenter.policycenterservice.decisionsystem.SingleTaskDecisionSystem.updateFirstPathHelper()' on a null object reference 2020-02-06 21:39:41.003 1898-2092/? E/HwChrExceptionListener: read chrKmsgPlat Exception 2020-02-06 21:39:41.004 1898-2092/? E/HwCHRWifiFile: getDevFileResult throw FileNotFoundException 2020-02-06 21:39:43.245 25442-25442/? E/JankService: child Thread receive to stop 2020-02-06 21:39:43.386 774-960/? E/JankService: all data read ok 2020-02-06 21:40:00.026 1965-2070/? E/HwLauncher: SettingsEx , no such field. 2020-02-06 21:40:00.065 29968-29968/? E/DateView: DateView,mCurrentTime: 1580996400065 2020-02-06 21:40:00.097 29968-29968/? E/ndroid.systemu: No package ID ff found for ID 0xffffffff. 2020-02-06 21:40:00.099 29968-29968/? E/ndroid.systemu: No package ID ff found for ID 0xffffffff. 2020-02-06 21:40:00.108 29968-29968/? E/ndroid.systemu: No package ID ff found for ID 0xffffffff. 2020-02-06 21:40:02.415 1426-1665/? E/HiData_HwArbitrationStateMachine: Unhandled Message: 4 in State: InitialState 2020-02-06 21:40:02.433 3461-25443/? E/SUPL20_LocMan: tm.getCellLocation() returned null 2020-02-06 21:40:02.472 1948-1948/? E/HwModemCapability: isCapabilitySupport java.lang.StringIndexOutOfBoundsException: length=7; index=7 2020-02-06 21:40:02.484 1948-1948/? E/Mapcon  : MapconSMManager: getStateMachineByIpsecId fail, ipsecId=4!!!!!!!!!! 2020-02-06 21:40:03.250 1866-2212/? E/Hicom_PolicyCenterService: unrecognized exception captured during handleMessage: 75 exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.huawei.systemserver.emcom.policycenter.policycenterservice.decisionsystem.SingleTaskDecisionSystem.updateFirstPathHelper()' on a null object reference 2020-02-06 21:40:08.511 25444-25444/? E/JankService: child Thread receive to stop

想知道这是个啥问题..

CheungBH commented 4 years ago

噢,解决了!非常感谢~