How to use jackOptions for android library project

I have an application code in an Android studio that I want to convert to a library project so that I can use it as a library in another application.
The build.gradle project from the library 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

He says:
Error: library projects cannot enable Jack. Jack is included in the default configuration. if I disable jackOptions, then my library does not work due to jdk 1.8, it says jackOptions are necessary and get the following errors.

 app:generateDebugSources app:mockableAndroidJar app:prepareDebugUnitTestDependencies app:generateDebugAndroidTestSources myapplication:generateDebugSources myapplication:generateDebugAndroidTestSources myapplication:mockableAndroidJar myapplication:prepareDebugUnitTestDependencies 
+5
source share
2 answers

Duplicate entry in settings. Just remove the following lines from the build.gradle file:

 jackOptions { enabled true } 
+1
source

Thanks to Olivier M. , you have a working way: Is there a way to use the Java 8 features with the Android library project .

Import Part:

 // Java8 not fully supported in library projects yet, https://code.google.com/p/android/issues/detail?id=211386 // this is a temporary workaround to get at least lambdas compiling gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar" } } 
0
source

Source: https://habr.com/ru/post/1258397/


All Articles