2025년, 코딩은 선택이 아닌 필수!

2025년 모든 학교에서 코딩이 시작 됩니다. 먼저 준비하는 사람만이 기술을 선도해 갑니다~

앱프로그래밍/안드로이드-자바

01-1. 처음 만드는 앱 프로그램

파아란기쁨1 2021. 12. 2. 15:30
반응형

1. 프로젝트 생성

- New Project -> Empty Activity 선택

New Project -> Empty Activity 선택

- Name : Hello, Language : Java, SDK :  API 21 선택

2. 소스코드와 화면

3. 화면 디자인 및 편집

- res -> layout -> activity_main.xml 선택 후 Design 클릭

- Infer Constraints

: ConstraintLayout 은 위젯이 연결되어 있지 않으면 오류 발생하는데 이런 경우 위젯들을 자동으로 정렬해 주는 기능이다.

- 폼에 버튼을 2개 정도 올려 놓은 후 Infer Constraints로 정렬

 

4. 실행 하기

One or more issues found when checking AAR metadata values:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-27).
Dependency: androidx.appcompat:appcompat:1.4.0.

이런 오류를 만나면 다음과 같이 해결하자.

1. Gradle Scripts -> build.gradle(Module) 에서 

implementation 'androidx.appcompat:appcompat:1.4.0'

implementation 'androidx.appcompat:appcompat:1.3.0'

으로 변경 하여 Sync now 클릭하여 적용 후 실행

 

2. Tools -> SDK Manage 클릭하여 Android 12.0(s) 인스톨 후 Gradle Scripts -> build.gradle(Module) 에서 

android {
    compileSdk 30

    defaultConfig {
        applicationId "com.example.hello"
        minSdk 21
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

의 compileSdk 와 targetSdk 를 31로 변경 후 실행

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.hello"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

 

- 실행결과

반응형