I'm currently playing around with the dynamic features. I'm not able to run any UI tests.
My app has three modules as shown on the diagram:
- app - the usual module
- dynamicFeatureA - the dynamic feature module. It must depend on app. That's a requirement when implementing dynamic features
- shared - a module containing some shared logic and 3rd party libraries. All my testing / mocking libraries are here as well
Down below you will find the build.gradle files for each of the modules.
app
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 26
targetSdkVersion 29
versionCode 7
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable = false
}
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
applicationIdSuffix ".dev"
}
prod {
dimension "environment"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dynamicFeatures = [':dynamicFeatureA']
}
dependencies {
implementation project(':shared')
// Firebase
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-auth-ktx'
api 'com.google.android.play:core:1.9.0'
}
shared
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 26
targetSdkVersion 29
versionCode 7
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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'
}
}
dependencies {
// Retrofit + OkHttp
api 'com.squareup.retrofit2:retrofit:2.6.2'
api 'com.squareup.retrofit2:converter-gson:2.1.0'
api 'com.squareup.okhttp3:logging-interceptor:4.2.1'
// Tests
api("junit:junit:4.13.1")
api 'androidx.test.ext:junit:1.1.2'
api 'androidx.test.espresso:espresso-core:3.3.0'
api "androidx.arch.core:core-testing:2.1.0"
api "io.mockk:mockk:1.10.4"
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
api "io.mockk:mockk-android:1.10.4"
api 'com.squareup.okhttp3:mockwebserver:4.2.2'
api 'androidx.test.uiautomator:uiautomator:2.2.0'
api 'androidx.test.ext:junit:1.1.2'
api 'androidx.test:runner:1.3.0'
api 'androidx.test:rules:1.3.0'
api 'androidx.test:core:1.3.0'
api 'androidx.test.ext:truth:1.3.0'
// Kotlin
api "org.jetbrains.kotlin:kotlin-stdlib:1.4.10"
api 'androidx.core:core-ktx:1.3.2'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
api 'androidx.appcompat:appcompat:1.2.0'
api 'com.google.android.material:material:1.2.1'
api "androidx.constraintlayout:constraintlayout:2.0.4"
}
dynamicFeatureA
plugins {
id 'com.android.dynamic-feature'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 26
targetSdkVersion 29
versionCode 7
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
applicationIdSuffix ".dev"
}
prod {
dimension "environment"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(":app")
implementation project(":shared")
}
When trying to run my UI tests I get the following errors
Android resource linking failed
/.gradle/caches/transforms-2/files-2.1/d3cf80163c3f5e54a1f3dc792b3bfaac/jetified-core-1.9.0/AndroidManifest.xml:13:5-226: AAPT: error: resource style/Theme.PlayCore.Transparent (aka com.test.test.dev.test:style/Theme.PlayCore.Transparent) not found.
/.gradle/caches/transforms-2/files-2.1/2bbe030940076efec6cce94c1a3439fe/jetified-play-services-basement-17.0.0/AndroidManifest.xml:23:9-25:69: AAPT: error: resource integer/google_play_services_version (aka com.test.test.dev.test:integer/google_play_services_version) not found.