Reputation: 43
Gradle compiles fine with the following build.gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
sourceSets {
debug {
jniLibs.srcDirs = ['src/main/jniLibs-dbg']
res.srcDirs = ['src/main/res-dbg', 'src/main/res-common']
}
release {
jniLibs.srcDirs = ['src/main/jniLibs-rel']
res.srcDirs = ['src/main/res-rel', 'src/main/res-common']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
debugCompile files('libs/debug.jar')
releaseCompile files('libs/nonDebug.jar')
}
But, when I add productFlavors, compilation fails:
productFlavors {
flavor1{
}
flavor2{
}
}
The flavors are empty intentionally. I just want to see whether compilation succeeds. Later I will add resources per flavour. The console log indicates that the assembleDebug task fails because it can't find the class files which are inside debug.jar
This is the error I see:
What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Any idea?
Upvotes: 1
Views: 990
Reputation: 1005
The problem is
apply plugin: 'com.android.library
The key part is to set publishNonDefault to true in library build.gradle, Then you must define dependencies as suggested by user guide.
publishNonDefault true
productFlavors {
flavor1{}
flavor2{}
}
Also you are applying the flavors to the library so you also need to define on project gradle which flavour library you are going to use in the project
for e.g.
market1Compile project(path: ':lib', configuration: 'flavor1Release')
market2Compile project(path: ':lib', configuration: 'flavor2Release')
For the more detail please check the following link
Multi flavor app based on multi flavor library in Android Gradle
Let me know if you found any issues on that i will help on that also
Upvotes: 0
Reputation: 75778
Whats your Logcat Throws
Note: Some input files use or override a deprecated API.
At First upgrade your buildToolsVersion & compileSdkVersion .
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
You can change your minSdkVersion 8
level , Use 15
& set targetSdkVersion 23
.
Again for
Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
You may visit here
Failure on build with Gradle on command line with an android studio project : Xlint error
Upvotes: 1