Android应用程序中的Logcat错误

时间:2014-08-11 23:14:28

标签: android android-logcat

我遇到了logcat错误的问题。所有类都没有错误,并且还在manifest.xml文件中添加了类。当我运行我的应用程序时,在启动画面后应用程序崩溃。我不知道问题是什么。给logcat错误。

08-11 19:06:12.073:E / AndroidRuntime(1156):致命异常:主要 08-11 19:06:12.073:E / AndroidRuntime(1156):进程:com.example.takeit,PID:1156 08-11 19:06:12.073:E / AndroidRuntime(1156):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.takeit / com.example.takeit.MainActivity2}:android.view.InflateException:Binary XML文件行#1:错误膨胀类android.widget.RelativeLayout 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread.access $ 800(ActivityThread.java:135) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.os.Handler.dispatchMessage(Handler.java:102) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.os.Looper.loop(Looper.java:136) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread.main(ActivityThread.java:5017) 08-11 19:06:12.073:E / AndroidRuntime(1156):at java.lang.reflect.Method.invokeNative(Native Method) 08-11 19:06:12.073:E / AndroidRuntime(1156):at java.lang.reflect.Method.invoke(Method.java:515) 08-11 19:06:12.073:E / AndroidRuntime(1156):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779) 08-11 19:06:12.073:E / AndroidRuntime(1156):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 08-11 19:06:12.073:E / AndroidRuntime(1156):at dalvik.system.NativeStart.main(Native Method) 08-11 19:06:12.073:E / AndroidRuntime(1156):引起:android.view.InflateException:二进制XML文件行#1:错误膨胀类android.widget.RelativeLayout 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.createView(LayoutInflater.java:620) 08-11 19:06:12.073:E / AndroidRuntime(1156):at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.inflate(LayoutInflater.java:469) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.inflate(LayoutInflater.java:397) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.inflate(LayoutInflater.java:353) 08-11 19:06:12.073:E / AndroidRuntime(1156):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.Activity.setContentView(Activity.java:1929) 08-11 19:06:12.073:E / AndroidRuntime(1156):at com.example.takeit.MainActivity2.onCreate(MainActivity2.java:20) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.Activity.performCreate(Activity.java:5231) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 08-11 19:06:12.073:E / AndroidRuntime(1156):... 11更多 08-11 19:06:12.073:E / AndroidRuntime(1156):引起:java.lang.reflect.InvocationTargetException 08-11 19:06:12.073:E / AndroidRuntime(1156):at java.lang.reflect.Constructor.constructNative(Native Method) 08-11 19:06:12.073:E / AndroidRuntime(1156):at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.LayoutInflater.createView(LayoutInflater.java:594) 08-11 19:06:12.073:E / AndroidRuntime(1156):......还有23个 08-11 19:06:12.073:E / AndroidRuntime(1156):引起:java.lang.OutOfMemoryError 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.content.res.Resources.loadDrawable(Resources.java:2110) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.content.res.TypedArray.getDrawable(TypedArray.java:602) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.View。(View.java:3554) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.View。(View.java:3484) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.view.ViewGroup。(ViewGroup.java:464) 08-11 19:06:12.073:E / AndroidRuntime(1156):在android.widget.RelativeLayout。(RelativeLayout.java:236) 08-11 19:06:12.073:E / AndroidRuntime(1156):... 26更多

没有应用运行。但是当我点击注册按钮保存用户名和密码并转到菜单页面时它会崩溃。

08-13 15:09:37.476:E / AndroidRuntime(1113):致命异常:主要 08-13 15:09:37.476:E / AndroidRuntime(1113):进程:com.example.takeit,PID:1113 08-13 15:09:37.476:E / AndroidRuntime(1113):java.lang.NullPointerException 08-13 15:09:37.476:E / AndroidRuntime(1113):at com.example.takeit.SignUP $ 1.onClick(SignUP.java:46) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.view.View.performClick(View.java:4438) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.view.View $ PerformClick.run(View.java:18422) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.os.Handler.handleCallback(Handler.java:733) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.os.Handler.dispatchMessage(Handler.java:95) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.os.Looper.loop(Looper.java:136) 08-13 15:09:37.476:E / AndroidRuntime(1113):在android.app.ActivityThread.main(ActivityThread.java:5017) 08-13 15:09:37.476:E / AndroidRuntime(1113):at java.lang.reflect.Method.invokeNative(Native Method) 08-13 15:09:37.476:E / AndroidRuntime(1113):at java.lang.reflect.Method.invoke(Method.java:515) 08-13 15:09:37.476:E / AndroidRuntime(1113):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779) 08-13 15:09:37.476:E / AndroidRuntime(1113):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 08-13 15:09:37.476:E / AndroidRuntime(1113):at dalvik.system.NativeStart.main(Native Method)

SignUp.java

             public class SignUP extends Activity 
                   {


        EditText editTextUserName,editTextPassword,editTextConfirmPassword;
        Button btnCreateAccount;

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

                // get Instance  of Database Adapter
                loginDataBaseAdapter=new DataBaseAdapter(this);
                loginDataBaseAdapter=loginDataBaseAdapter.open();

                // Get Refferences of Views
                editTextUserName=(EditText)findViewById(R.id.editTextUserName);
                editTextPassword=(EditText)findViewById(R.id.editTextPassword);


                btnCreateAccount=(Button)findViewById(R.id.buttonCreateAccount);


                btnCreateAccount.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        String userName=editTextUserName.getText().toString();
                        String password=editTextPassword.getText().toString();
                        String 
        confirmPassword=editTextConfirmPassword.getText().toString();

                        // check if any of the fields are vaccant

               if(userName.equals("")||password.equals("")||confirmPassword.equals(""))
                        {
                                Toast.makeText(getApplicationContext(), "Field 
              Vaccant", Toast.LENGTH_LONG).show();


                            return;
                        }
                        // check if both password matches
                        if(!password.equals(confirmPassword))
                        {
                            Toast.makeText(getApplicationContext(), "Password Does Not          
            Matches", Toast.LENGTH_LONG).show();
                             return;
                        }
                        else
                        {
                                // Save the Data in Database
                                loginDataBaseAdapter.insertEntry(userName, password);
                                Toast.makeText(getApplicationContext(), "Account 
               Successfully Created ", Toast.LENGTH_LONG).show();
                                  Intent menu=new 
               Intent(getApplicationContext(),Menu.class);
                              startActivity(menu);
                        }


                    }
                });
        }

        @Override
        protected void onDestroy() {
            // TODO Auto-generated method stub
            super.onDestroy();

            loginDataBaseAdapter.close();
        }

     }

1 个答案:

答案 0 :(得分:1)

这是错误。

Caused by: java.lang.OutOfMemoryError 08-11 19:06:12.073: E/AndroidRuntime(1156): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 08-11 19:06:12.073: 

您的应用中有非常大的图片,请查看官方guidelines