Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kmp/androidApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
58 changes: 58 additions & 0 deletions kmp/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "com.example.kmp.snippets"
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
applicationId = "com.example.kmp.snippets"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

buildFeatures {
compose = true
}
}

dependencies {
val composeBom = project.dependencies.platform(libs.androidx.compose.bom)
implementation(composeBom)
implementation(project(":kmp:shared"))

implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.ui.util)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.lifecycle.viewModelCompose)
}
21 changes: 21 additions & 0 deletions kmp/androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions kmp/androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.kmp.snippets

import androidx.compose.runtime.Composable
import androidx.lifecycle.viewmodel.compose.viewModel

// [START android_kmp_viewmodel_screen]
// androidApp/ui/MainScreen.kt

@Composable
fun MainScreen(
viewModel: MainViewModel = viewModel(
factory = mainViewModelFactory,
),
) {
// observe the viewModel state
}
// [END android_kmp_viewmodel_screen]
14 changes: 6 additions & 8 deletions kmp/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ plugins {
}

kotlin {

// Target declarations - add or remove as needed below. These define
// which platforms this KMP module supports.
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
androidLibrary {
namespace = "com.example.kmp.snippets"
compileSdk = 36
minSdk = 24
namespace = "com.example.kmp.snippets.shared"
compileSdk = libs.versions.compileSdk.get().toInt()
minSdk = libs.versions.minSdk.get().toInt()

withHostTestBuilder {
}
Expand All @@ -24,6 +23,8 @@ kotlin {
}
}

jvmToolchain(17)

// For iOS targets, this is also where you should
// configure native binary output. For more information, see:
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
Expand Down Expand Up @@ -64,9 +65,7 @@ kotlin {

androidMain {
dependencies {
// Add Android-specific dependencies here. Note that this source set depends on
// commonMain by default and will correctly pull the Android artifacts of any KMP
// dependencies declared in commonMain.

}
}

Expand All @@ -88,5 +87,4 @@ kotlin {
}
}
}

}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ include(
":identity:credentialmanager",
":xr",
":watchfacepush:validator",
":kmp:shared",
":kmp:androidApp",
":kmp:shared"
)