update build to allow using compose in AS 4.1 stable version

This commit is contained in:
John O'Reilly 2021-04-01 17:19:10 +01:00
parent ab658a7131
commit 0b4b61f060
6 changed files with 12 additions and 29 deletions

View file

@ -32,9 +32,11 @@ beyond this then I'd definitely recommend checking out [KaMPKit](https://github.
### Building
You need to use Android Studio Canary version (**note: Java 11 is now the minimum version required**). Have tested on XCode v11 and v12. When opening
You need to use Android Studio Canary version (**note: Java 11 is now the minimum version required**). Have tested with XCode v11 and v12. When opening
iOS/watchOS/macOS projects remember to open `.xcworkspace` file (and not `.xcodeproj` one). To exercise web client run `./gradlew :web:browserDevelopmentRun`.
**UPDATE**: now also works in stable version of Android Studio.
### Jetpack Compose for Desktop client
This client is available in `compose-desktop` module. Note that you need to use appropriate version of JVM when running (works for example with Java 11)

View file

@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME
plugins {
id("com.android.application")
kotlin("android")
@ -15,14 +17,6 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = Versions.compose
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
@ -52,10 +46,12 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
}
dependencies {
add(PLUGIN_CLASSPATH_CONFIGURATION_NAME, "androidx.compose.compiler:compiler:${Versions.compose}")
implementation("androidx.compose.runtime:runtime:${Versions.compose}")
implementation("com.google.android.material:material:1.3.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0-alpha01")
//implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:")
implementation("androidx.activity:activity-compose:1.3.0-alpha05")

View file

@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@ -28,7 +29,7 @@ fun ISSPositionScreen() {
peopleInSpaceViewModel.issPosition.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
}
val issPosition = locationFlowLifecycleAware.collectAsState(IssPosition(0.0, 0.0))
val issPosition by locationFlowLifecycleAware.collectAsState(IssPosition(0.0, 0.0))
val context = LocalContext.current
val map = remember { MapView(context) }
@ -45,7 +46,7 @@ fun ISSPositionScreen() {
val mapController = map.controller
mapController.setZoom(5.0)
val issPositionPoint = GeoPoint(issPosition.value.latitude, issPosition.value.longitude)
val issPositionPoint = GeoPoint(issPosition.latitude, issPosition.longitude)
mapController.setCenter(issPositionPoint)
map.overlays.clear()

View file

@ -4,9 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import co.touchlab.kermit.Kermit
import com.surrus.common.remote.Assignment
import com.surrus.common.remote.IssPosition
import com.surrus.common.repository.PeopleInSpaceRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.stateIn

View file

@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.0-alpha11")
classpath("com.android.tools.build:gradle:4.1.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.kotlin}")
classpath("com.squareup.sqldelight:gradle-plugin:${Versions.sqlDelight}")

View file

@ -25,20 +25,6 @@ android {
}
}
// workaround for https://youtrack.jetbrains.com/issue/KT-43944
android {
configurations {
create("androidTestApi")
create("androidTestDebugApi")
create("androidTestReleaseApi")
create("testApi")
create("testDebugApi")
create("testReleaseApi")
}
}
kotlin {
val sdkName: String? = System.getenv("SDK_NAME")