마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

앱이중지되었습니다라고 뜨네요

0 추천

네비게이션뷰공부하는 학생입니다

코드에는 오류가 없는데도 앱이중지되었다하니 답답해서 질문을올리네요

activity_main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="#ec1f1f"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:menu="@+menu/menu_drawer"
        app:headerLayout="@layout/navigation_header"
        />

</android.support.v4.widget.DrawerLayout>

navigation_header.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:background="@color/primary_dark_material_dark">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="HEADER"
        android:textSize="40sp"
        android:textColor="@android:color/white"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"/>


</RelativeLayoutLayout>

menu_drawer.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_dashboard"
            android:icon="@drawable/ic_dashboard_black_24dp"
            android:title="Dashboard" />
        <item
            android:id="@+id/nav_explore"
            android:icon="@drawable/ic_explore_black_24dp"
            android:title="Explore" />
    </group>

    <item android:title="Sub menu">
            <menu>
            <item
                android:icon="@drawable/ic_event_black_24dp"
                android:title="Event" />
            <item
                android:icon="@drawable/ic_home_black_24dp"
                android:title="Home" />
            </menu>
    </item>
</menu>

 

시니시스 (140 포인트) 님이 2015년 11월 15일 질문
코드 자체에는 오류가 없어도 실행하면 오류가 발생하는 경우도 많습니다.
아마 종료되면서 하단의 로그캣에 빨간색 텍스트가 출력될겁니다.
대부분 상단에 있는 부분이 오류 주 원인인데 그것도 같이 올리셔야 다른 분들도 무슨 오류인가 알 수있을거같네요. 참고로 오류났을 때 어느 java소스의 몇 번째 줄에 에러가 났는지도 다 출력됩니다.

2개의 답변

0 추천
종료 되었을 때는 코드만 올리것보다 종료될 때 Logcat에 표시되는 오류로그를 함께 올려주시는 것이

더 빨리 해결하는데 도움을 드릴 수 있습니다.
Gradler (109,780 포인트) 님이 2015년 11월 16일 답변
0 추천
프로그래밍에 대한 이해가 부족하신 듯 한데 프로그램은 실행하기전까지는 모든 오류를 절대 알 수 없는 법입니다. 가령 프로그램 중간의 임의의 시점에 참조를 제거했는데 이를 참조한다면 에러지요.

그런데 언제 사용자가 참조 제거를 수행할지 그리고 언제 그것을 참조하게 될지 실행전에 미래를 알 수는 없는겁니다. 그렇기 때문에 예외처리라는게 있는 것이구요.

실제로 가장 많이 일어나는 오류가 이러한 허상참조의 경우입니다. 다른 분들 말씀처럼 오류 내용도 힘께 올려주세요.
Jinthree (8,980 포인트) 님이 2015년 11월 16일 답변
...