Browse Source

configure android target

main
James Fenn 1 year ago
parent
commit
73210a9e8a
4 changed files with 69 additions and 4 deletions
  1. +4
    -0
      example-android/src/main/java/me/jfenn/gitrest/example/android/MainActivity.kt
  2. +50
    -4
      gitrest/build.gradle
  3. +9
    -0
      gitrest/consumer-rules.pro
  4. +6
    -0
      gitrest/src/androidMain/AndroidManifest.xml

+ 4
- 0
example-android/src/main/java/me/jfenn/gitrest/example/android/MainActivity.kt View File

@@ -0,0 +1,4 @@
package me.jfenn.gitrest.example.android

class MainActivity {
}

+ 50
- 4
gitrest/build.gradle View File

@@ -1,10 +1,40 @@
apply plugin: "com.android.library"
apply plugin: "kotlin-multiplatform"
apply plugin: "kotlinx-serialization"

def libraryVersion = "0.0.1"
def libraryVersionCode = 1

apply plugin: 'maven-publish'
group 'gitrest'
version '0.0.1'
version libraryVersion

android {
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode libraryVersionCode
versionName libraryVersion

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

sourceSets.main {
manifest.srcFile 'src/androidMain/AndroidManifest.xml'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

// temporary solution for https://youtrack.jetbrains.com/issue/KT-34389
project.plugins.apply(org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin)

kotlin {
@@ -29,11 +59,13 @@ kotlin {

jvm()

android()

sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
compileOnly kotlin('stdlib-common')
compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4'
compileOnly "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
compileOnly "io.ktor:ktor-client-core:$ktor_version"
compileOnly "io.ktor:ktor-client-json:$ktor_version"
@@ -50,7 +82,6 @@ kotlin {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
// TODO: ktor dependency for android
implementation "io.ktor:ktor-client-apache:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
@@ -62,6 +93,21 @@ kotlin {
implementation kotlin('test-junit')
}
}
androidMain {
dependencies {
implementation kotlin('stdlib-jdk7')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-client-android:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
}
}
androidTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
jsMain {
dependencies {
implementation kotlin('stdlib-js')


+ 9
- 0
gitrest/consumer-rules.pro View File

@@ -0,0 +1,9 @@
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.SerializationKt
-keep,includedescriptorclasses class com.yourcompany.yourpackage.**$$serializer { *; } # <-- change package name to your app's
-keepclassmembers class me.jfenn.gitrest.** { # <-- change package name to your app's
*** Companion;
}
-keepclasseswithmembers class me.jfenn.gitrest.** { # <-- change package name to your app's
kotlinx.serialization.KSerializer serializer(...);
}

+ 6
- 0
gitrest/src/androidMain/AndroidManifest.xml View File

@@ -0,0 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.jfenn.gitrest">

<uses-permission android:name="android.permission.INTERNET" />

</manifest>

Loading…
Cancel
Save