简体   繁体   中英

Redmi Note 4 doesn't run apps from Android studio

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!

There is a problem with the Redmi Note 4 smartphone. The following instructions will work with the PC and Mac.

Go to Settings > Additional Settings (under System and Device) > Developer Options

  1. Scroll to the bottom of the page and disable Turn on MIUI optimization
  2. Enable USB debugging
  3. Enable Install via USB
  4. Enable USB Debugging(Security setting)

Try this: maybe it will help you.

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

I faced the same issue. I was not able to enable Install Via USB option, however, I found a solution that actually worked.

Here are the steps to enable it.

  1. Install PlexVPN app on your mobile phone
  2. Open PlexVPN then set VPN to China (eg China-Shanghai ) and connect
  3. Go to Developer Options and enable Install Via USB option
  4. Enjoy :)

I have tried all of the methods above, but unfortunately, none of it works for me.

The root cause is some defect inside MIUI( https://en.wikipedia.org/wiki/MIUI ).

To avoid this crash, you need to avoid using these external package.

I used buck build, so I simply disable Exopackage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM