某些设备上的FC错误启动应用程序

时间:2015-04-06 08:46:04

标签: java android

我开发了一个程序,它从数据库中获取一组数据并显示给用户。我已经测试了这个应用程序: LG G2,HTC One X,三星Galaxy S,S4,S5,Note3,Note4,摩托罗拉Moto X,Nexus 5,6,7,9 等设备及其确定无误运行

但是在某些设备上启动时,例如: Sony Xperia S(Android OS 4.1.1),华为G510(Android OS 4.1.1)以及其他此类设备,它没有运行并显示FC错误

MainActivity.java代码:

public class MainActivity extends ActionBarActivity {

private Toolbar toolbar;
private RelativeLayout select_smiley, select_manavi, select_day, select_ayad;
private Context context = this;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);



    ////Smiley Animations
    ImageView image_smiley = (ImageView) findViewById(R.id.main_smiley_category);
    Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
    image_smiley.startAnimation(animation1);
    //
    ImageView image_love = (ImageView) findViewById(R.id.main_love_category);
    Animation animation2 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate2);
    image_love.startAnimation(animation2);
    //
    ImageView image_day = (ImageView) findViewById(R.id.main_day_category);
    Animation animation3 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
    image_day.startAnimation(animation3);
    //
    ImageView image_sentences = (ImageView) findViewById(R.id.main_sentences_category);
    Animation animation4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate2);
    image_sentences.startAnimation(animation4);
    //////////////////////
    ////Text Animations///
    TextView text_title_smile = (TextView) findViewById(R.id.main_text_smiley);
    TextView text_info_smile = (TextView) findViewById(R.id.main_info_smiley);
    Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.show_maintext);
    text_title_smile.startAnimation(anim);
    text_info_smile.startAnimation(anim);
    //
    TextView text_title_love = (TextView) findViewById(R.id.main_text_love);
    TextView text_info_love = (TextView) findViewById(R.id.main_info_love);
    Animation anim2 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.show_maintext);
    text_title_love.startAnimation(anim2);
    text_info_love.startAnimation(anim2);
    //
    TextView text_title_day = (TextView) findViewById(R.id.main_text_day);
    TextView text_info_day = (TextView) findViewById(R.id.main_info_day);
    Animation anim3 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.show_maintext);
    text_title_day.startAnimation(anim3);
    text_info_day.startAnimation(anim3);
    //
    TextView text_title_sentences = (TextView) findViewById(R.id.main_text_sentences);
    TextView text_info_sentences = (TextView) findViewById(R.id.main_info_sentences);
    Animation anim4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.show_maintext);
    text_title_sentences.startAnimation(anim4);
    text_info_sentences.startAnimation(anim4);
    //
    /////////////////////
    // Select Layout
    select_smiley = (RelativeLayout) findViewById(R.id.select_smiley);
    select_smiley.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new Timer().schedule(new TimerTask() {
                public void run() {
                    MainActivity.this.runOnUiThread(new Runnable() {
                        public void run() {
                            startActivity(new Intent(MainActivity.this, Category_Smiley_Page.class));
                            overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out);
                        }
                    });
                }
            }, 850);
        }
    });

    select_manavi = (RelativeLayout) findViewById(R.id.select_manavi);
    select_manavi.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new Timer().schedule(new TimerTask() {
                public void run() {
                    MainActivity.this.runOnUiThread(new Runnable() {
                        public void run() {
                            startActivity(new Intent(MainActivity.this, Category_manavi_page.class));
                            overridePendingTransition(R.anim.push_down_in, R.anim.push_down_out);
                        }
                    });
                }
            }, 850);
        }
    });

    select_day = (RelativeLayout) findViewById(R.id.select_day);
    select_day.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new Timer().schedule(new TimerTask() {
                public void run() {
                    MainActivity.this.runOnUiThread(new Runnable() {
                        public void run() {
                            startActivity(new Intent(MainActivity.this, Category_Day_Page.class));
                            overridePendingTransition(R.anim.slide_in_left, R.anim.slide_in_right);
                        }
                    });
                }
            }, 850);
        }
    });

    select_ayad = (RelativeLayout) findViewById(R.id.select_ayad);
    select_ayad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new Timer().schedule(new TimerTask() {
                public void run() {
                    MainActivity.this.runOnUiThread(new Runnable() {
                        public void run() {
                            startActivity(new Intent(MainActivity.this, Category_Ayad_Page.class));
                            overridePendingTransition(R.anim.slide_in_right, R.anim.slide_in_left);
                        }
                    });
                }
            }, 850);
        }
    });
}

@Override
public void onBackPressed() {
    final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(this);
    dialogBuilder
            .withTitle("exit")
            .withTitleColor("#FFFFFF")
            .withDividerColor("#11000000")
            .withMessage("are you sure ?")
            .withMessageColor("#FFFFFFFF")
            .withDialogColor("#00BCD4")
            .withIcon(getResources().getDrawable(R.drawable.ic_launcher))
            .withDuration(500)
            .withEffect(Effectstype.RotateBottom)
            .withButton1Text("yes")
            .withButton2Text("no")
            .isCancelableOnTouchOutside(true)

            .setButton1Click(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(v.getContext(), "test", Toast.LENGTH_SHORT).show();
                    finish();
                }
            })
            .setButton2Click(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(v.getContext(), "test", Toast.LENGTH_SHORT).show();
                    dialogBuilder.dismiss();
                }
            })
            .show();

}

public void help_dialog (View view){
    final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(this);
    dialogBuilder
            .withTitle("help")
            .withTitleColor("#FFFFFF")
            .withDividerColor("#11000000")
            .withMessage("message")
            .withMessageColor("#FFFFFFFF")
            .withDialogColor("#3eb0bb")
            .withDuration(500)
            .withEffect(Effectstype.Newspager)
            .withButton1Text("ok")
            .isCancelableOnTouchOutside(true)

            .setButton1Click(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialogBuilder.dismiss();
                }
            })
            .show();

}

public void fragment_search_click(View view){
    new Timer().schedule(new TimerTask() {
        public void run() {
            MainActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    startActivity(new Intent(MainActivity.this, Search_page.class));
                }
            });
        }
    }, 850);
}
public void fragment_favorite_click(View view){
    new Timer().schedule(new TimerTask() {
        public void run() {
            MainActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    startActivity(new Intent(MainActivity.this, Search_page.class));
                }
            });
        }
    }, 850);
}
public void fragment_connect_click(View view){
    new Timer().schedule(new TimerTask() {
        public void run() {
            MainActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    startActivity(new Intent(MainActivity.this, ConnectUs_page.class));
                }
            });
        }
    }, 850);
}
public void fragment_about_click(View view){
    new Timer().schedule(new TimerTask() {
        public void run() {
            MainActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    startActivity(new Intent(MainActivity.this, about_page.class));
                }
            });
        }
    }, 850);
}

Logcat日志(索尼):

04-06 07:35:47.976    1002-1002/com.tellfa.smsbox E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tellfa.smsbox/com.tellfa.smsbox.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
        at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5612)
        at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1809)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1721)
        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:58)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:748)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2784)
        at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2844)
        at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1542)
        at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:140)
        at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
        at com.tellfa.smsbox.MainActivity.onCreate(MainActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:5008)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)

请帮我解决最简单的问题

1 个答案:

答案 0 :(得分:0)

正如其他人之前已经回答的那样,@ style可能会出现问题:java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12