Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jackOptions for android library project

I have an application code in android studio, which I want to convert it to library project so that I can use it as library in other application.
The build.gradle of the library project is as follows

apply plugin: 'com.android.library'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
    //applicationId "com.example"
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"

    jackOptions {
        enabled true
    }
    multiDexEnabled true
}
dexOptions {

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

 }
 }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'

/* support libraries*/
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-annotations:23.1.0'

/* google play services libraries*/
compile 'com.google.android.gms:play-services-location:9.0.0'

}

I am using android studio 2.2.1 and jdk 1.8,
jdk 1.8 requires jackOptions

it says:
Error:Library projects cannot enable Jack. Jack is enabled in default config. if i disable jackOptions then my library is not working as due to jdk 1.8 it says jackOptions are necessary and getting following errors.

app:generateDebugSources 
app:mockableAndroidJar
app:prepareDebugUnitTestDependencies 
app:generateDebugAndroidTestSources
myapplication:generateDebugSources
myapplication:generateDebugAndroidTestSources
myapplication:mockableAndroidJar
myapplication:prepareDebugUnitTestDependencies
like image 851
nayana bhoj Avatar asked Nov 08 '22 07:11

nayana bhoj


1 Answers

Duplicated entry in the settings. Just remove the following lines from your build.gradle:

jackOptions {
        enabled true
}
like image 164
technik Avatar answered Nov 15 '22 04:11

technik