Redmi Note 4 doesn't run apps from Android studio

时间:2017-10-12 10:00:55

标签: android redmi-device

I recently bought a Xiaomi Redmi Note 4 and I try to use it as device to run an application from Android studio..

The first time, it runs ok, but after that, it crashes and it says that there is a problem with the app and it can't run it. The code is correct!

I become developer and enable USB Debuging and installation through USB, but when I try to enable USB Debuging (security), it pops a message "The device i temporary restricted"...

The message that pops in my device is that:

java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.NoSuchFieldException: No field mAssets in class Landroid/content/res/MiuiResourcesImpl; (declaration of 'android.content.res.MiuiResourcesImpl' appears in /system/framework/framework.jar) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5431) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6195) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764) Caused by: java.lang.IllegalStateException: java.lang.NoSuchFieldException: No field mAssets in class Landroid/content/res/MiuiResourcesImpl; (declaration of 'android.content.res.MiuiResourcesImpl' appears in /system/framework/framework.jar) at com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources(MonkeyPatcher.java:442) at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:308) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5428) ... 8 more Caused by: java.lang.NoSuchFieldException: No field mAssets in class Landroid/content/res/MiuiResourcesImpl; (declaration of 'android.content.res.MiuiResourcesImpl' appears in /system/framework/framework.jar) at java.lang.Class.getDeclaredField(Native Method) at com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources(MonkeyPatcher.java:433) ... 11 more

Is there anyone that can help me? Thank you!

4 个答案:

答案 0 :(得分:3)

Redmi Note 4智能手机出现问题。 以下说明适用于PC和Mac。

转到设置>其他设置(在系统和设备下)>开发者选项

  1. 滚动到页面底部并禁用启用MIUI优化
  2. 启用 USB调试
  3. 启用通过USB安装
  4. 启用 USB调试(安全设置)

答案 1 :(得分:1)

我遇到了同样的问题。我无法启用Install Via USB选项,但是,我找到了一个实际工作的解决方案。

以下是启用它的步骤。

  1. 在手机上安装PlexVPN应用
  2. 打开PlexVPN然后将VPN设置为中国(例如中国 - 上海)并连接
  3. 转到开发者选项并启用通过USB安装选项
  4. 享受:)

答案 2 :(得分:0)

Try this: maybe it will help you.

Additional Settings > Developer Option > there at the bottom just turn off MIUI optimization.

答案 3 :(得分:0)

我已经尝试了上述所有方法,但不幸的是,这些方法都不适合我。

根本原因是MIUI(https://en.wikipedia.org/wiki/MIUI)内部存在某些缺陷。

为避免崩溃,您需要避免使用这些外部软件包。

我使用了buck build,所以我只是禁用了Exopackage。