I create a library module with two flavors. Each flavor implements a FlavourActivity.java
in a different way. In my app I'm what to import my library module as a dependency, but I want to specify which flavor I'm going to import.
My problem is that I'm able to add the dependency in my app gradle file, but I cannot access the FlavourActivity.java
. Somehow my app does not have access to it, although it has imported the library.
Structure
My structure is the following:
app/
├── src/
│ ├── Activity.java
Library/
├── lottieYes/
│ ├── FlavourActivity.java
├── lottieNo/
│ ├── FlavourActivity.java
Android Plugin Version: 3.4.0 Gradle Version: 5.1.0
Recources
My app gradle file is the following:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.asousa.testing.moduleflavour"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project(path: ':mylibrary', configuration: 'lottieYes')
}
My library gradle file is the following:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
publishNonDefault true
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
flavorDimensions "lottie"
productFlavors {
lottieYes {
dimension "lottie"
}
lottieNo {
dimension "lottie"
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
configurations {
lottieYes
lottieNo
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
lottieYesImplementation 'com.airbnb.android:lottie:2.5.6'
}
I already read the following articles:
I also checked the following question, but it not solve my issue since with the latest gradle version it does not work.
But none of them helped me. Does someone had a similar issue?