所有Mi设备上的应用程序关闭异常(在MIUI ROM上)

时间:2016-08-27 05:00:21

标签: android debugging

我制作了一个应用程序并且它正在处理所有模拟器和手机,除了具有MIUI的Mi设备。设置内容视图时出现异常。我正在附加logcat和java文件。

Java代码

protected void onCreate(Bundle savedInstanceState) {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    Display display = getWindowManager().getDefaultDisplay();
    final int width = display.getWidth();
    final int height = display.getHeight();

    super.onCreate(savedInstanceState);
    if (width==720)
        setContentView(R.layout.activity_main);
    else
        setContentView(R.layout.main_copy);
    System.out.println("Game Option A Screen (MainActivity.class)");
    SharedPreferences sp = getSharedPreferences("prefs", 0);
     p1 = sp.getString("player1Name", "Player 1");
     p2 = sp.getString("player2Name", "Player 2");
     p1pokemon = sp.getString("player1pokemon", "");
     p2pokemon = sp.getString("player2Pokemon", "");
     rl=(RelativeLayout)findViewById(R.id.rl);
}

logcat的

8348-8348/bt4u.com.pokemonbattles E/art: Throwing OutOfMemoryError "Failed to allocate a 20971884 byte allocation with 16777120 free bytes and 19MB until OOM"
        8348-8348/bt4u.com.pokemonbattles E/AndroidRuntime: FATAL EXCEPTION: main
        Process: bt4u.com.pokemonbattles, PID: 8348
        java.lang.RuntimeException: Unable to start activity ComponentInfo{bt4u.com.pokemonbattles/bt4u.com.pokemonbattles.MainActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
        at android.app.ActivityThread.access$800(ActivityThread.java:154)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5276)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
        Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
        t android.view.LayoutInflater.createView(LayoutInflater.java:637)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:686)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:745)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
        at bt4u.com.pokemonbattles.MainActivity.onCreate(MainActivity.java:47)
        at android.app.Activity.performCreate(Activity.java:6041)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394) 
        at android.app.ActivityThread.access$800(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5276) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:611)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:686) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:745) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:810) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:508) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:418) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
        at bt4u.com.pokemonbattles.MainActivity.onCreate(MainActivity.java:47) 
        at android.app.Activity.performCreate(Activity.java:6041) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394) 
        at android.app.ActivityThread.access$800(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5276) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 
     Caused by: java.lang.OutOfMemoryError: Failed to allocate a 20971884 byte allocation with 16777120 free bytes and 19MB until OOM
        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:613)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:446)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
        at android.content.res.Resources.createFromResourceStream(Resources.java:2822)
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2523)
        at android.content.res.Resources.loadDrawable(Resources.java:2421)
        at android.content.res.MiuiResources.loadDrawable(MiuiResources.java:393)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:751)
        at android.view.View.<init>(View.java:3740)
        at android.view.ViewGroup.<init>(ViewGroup.java:498)
        at android.widget.GridLayout.<init>(GridLayout.java:285)
        at android.widget.GridLayout.<init>(GridLayout.java:281)
        at android.widget.GridLayout.<init>(GridLayout.java:277)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:611) 
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:686) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:745) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:810) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:508) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:418) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
        at bt4u.com.pokemonbattles.MainActivity.onCreate(MainActivity.java:47) 
        at android.app.Activity.performCreate(Activity.java:6041) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394) 
        at android.app.ActivityThread.access$800(ActivityThread.java:154) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:135) 
        at android.app.ActivityThread.main(ActivityThread.java:5276) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 
    8348-8348/bt4u.com.pokemonbattles I/Process: Sending signal. PID: 8348 SIG: 9

0 个答案:

没有答案