Is there a recommended way to create androidMain a...
# multiplatform
s
Is there a recommended way to create androidMain and androidTest modules?
k
there's a lot more to it than that. you also need to apply the android gradle plugin, add your android block, associate it with the kotlin source sets, and add an AndroidManifest.xml
s
Yes i did that
It works as expected, i'm able to generate aar
but IDE doesn't highlight any errors for missing definitions
k
can you paste your sourceSets block?
s
Copy code
android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName '1.0'
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        debug {
        }
        release {
            minifyEnabled false
        }
    }
    sourceSets {
        main {
            manifest.srcFile 'src/androidMain/AndroidManifest.xml'// See notes #4
            java.srcDirs = ['src/androidMain/kotlin']
            res.srcDirs = ['src/androidMain/resources']
        }
        androidTest {
            java.srcDirs = ['src/androidTest/kotlin']
            res.srcDirs = ['src/androidTest/resources']
        }
    }

    dependencies {
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
    }
}
If it helps, here it the link for the entire file https://github.com/Ethan1983/MultiplatformLib/blob/master/build.gradle
k
this all looks correct
did you rerun your gradle import?
s
yeah
i was looking for the official way to create androidMain and androidTest
right now if i create, it is just a directory
k
if so, perhaps restart IDEA. it can get confused when you "migrate" a target like this
s
I suspect that IDE doesn't highlight errors because its not seen as a module
Okay, let me try restarting too
k
that has actually fixed issues for me in the past when doing this
s
no luck, that didn't help, it doesn't mark it as a module
k
huh
s
module vs directory
Does your setup show it as a module? Are you using Android Studio or IntelliJ?
k
mine looks the same, but it works - IDEA
s
same as in androidMain shows as a directory?
k
yes
and it doesn't show as a module on the module settings dialog
s
Okay, do you remember how you created those?
@Kris Wong What version of JDK are you using?
k
8
s
Thanks
🍻 1