LoginSignup
0
0

More than 3 years have passed since last update.

[Modern Android] Jetpack Compose その1

Posted at

モダーン アンドロイド
Jetpack Composeを試してみたい

その過程をメモします。

まず、メモしている時点では、開発者PreviewなのでStableチャンネルでは
利用できない。

設置する。

image.png

ZipFileでダウンロードして、圧縮されたデータを元に戻もどす。

image.png

Nextを押します。
image.png

Nextを押します。
image.png

Nextを押します。
どっちを選んでも問題ないです。
image.png

Finishを押します。
image.png

終わるまで待ちます。
image.png

Finishを押します。
image.png

始めよう

Create New Projectを選択する。
image.png

Empty Compose Activityを選択する。
image.png

Finishを押します。
image.png

Buildが終わるまで待ちます。
image.png

AVD

私はAPI30のデバイスを使います。
多分基本設置される。

image.png

Gradle


android {
    defaultConfig {
        ...
        minSdkVersion 21
    }

    buildFeatures {
        // Enables Jetpack Compose for this module
        compose true
    }
    ...

    // Set both the Java and Kotlin compilers to target Java 8.

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev09"
    }
}

全てのApp Build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.0"

    defaultConfig {
        applicationId "com.dreamwalker.jetpack_compose_101"
        minSdkVersion 29
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "${compose_version}"
        kotlinCompilerVersion '1.3.70-dev-withExperimentalGoogleExtensions-20200424'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation "androidx.ui:ui-layout:$compose_version"
    implementation "androidx.ui:ui-material:$compose_version"
    implementation "androidx.ui:ui-tooling:$compose_version"
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0