인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

eomuksoyummy's profile image
eomuksoyummy

asked

[For beginners] Learn Android Kotlin by creating 8 apps

Databinding explained

layout 태그로 감쌀 때 앱 실행 중단 됨 오류

Resolved

Written on

·

256

0

강의 위치 : 주사위 만들기 첫 번째 강의 <layout> 태그로 

감싸는 부분

 

에러 내용 : activity_main.xml 에서,  layout태그로 감싸지 않았을 때는 정상적으로 

앱 실행이 되는데, 감싸기만 하면 앱이 계속 중단되는 문제 발생합니다. 왜 그런지 알려주시면 정말 감사하겠습니다.

// 문제의 코드 : 앱이 제대로 실행되지 않고 바로 종료되어버림

<?xml version="1.0" encoding="utf-8"?>

<layout>

    <androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <Button
            android:id="@+id/testBtnId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>

// 정상적으로 실행되는 코드
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/testBtnId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
firebasekotlinandroid

Answer 2

0

bokchi님의 프로필 이미지
bokchi
Instructor

또한 에러 내용도 공유해주시면 살펴보겠습니다

eomuksoyummy님의 프로필 이미지
eomuksoyummy
Questioner

감사합니다. 같은 내용의 새로운 질문으로 다시 올렸습니다!

0

bokchi님의 프로필 이미지
bokchi
Instructor

혹시 build.gradle에 아래의 부분 추가하셨나요?

 

buildFeatures {
dataBinding true
}

 

만약 그렇다면 아래의 코드 3개를 모두 복사해서 공유해주세요.

 

MainActivity.kt

activity_main.xml

build.gradle

eomuksoyummy's profile image
eomuksoyummy

asked

Ask a question