Android: Issues enabling Java 8 features using a shared library.
NickName:jwBurnside Ask DateTime:2016-12-01T09:46:23

Android: Issues enabling Java 8 features using a shared library.

I'm trying to take advantage of some Java 8 features to my Android project by following the documentation: https://developer.android.com/guide/platform/j8-jack.html

android {
  ...
  defaultConfig {
    ...
    jackOptions {
      enabled true
    }
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

I'm using a shared library module. When I add jackOptions to my main module, it syncs and compiles with no issues. However, when the configuration is added to my serviceLibrary module, sync fails with: Error:Cannot add task ':serviceLibrary:assembleDebug' as a task with that name already exists.

My two build files are fairly similar in regards to the configuration:

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        jackOptions {
            enabled true
        }
        applicationId "com.my.app"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 83
        versionName "2.0.8"
        vectorDrawables.useSupportLibrary = true

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
...

so this error is not making a lot of sense to me. Any help would be appreciated.

Copyright Notice:Content Author:「jwBurnside」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40901305/android-issues-enabling-java-8-features-using-a-shared-library

More about “Android: Issues enabling Java 8 features using a shared library.” related questions

Android: Issues enabling Java 8 features using a shared library.

I'm trying to take advantage of some Java 8 features to my Android project by following the documentation: https://developer.android.com/guide/platform/j8-jack.html android { ... defaultConfig...

Show Detail

Enabling debug symbols in shared library using GCC

I am creating a shared library using gcc and suspect that there may be some memory leaks from the shared library. To debug, I need to enable debug symbols when creating the shared library. To buil...

Show Detail

Enabling debug symbols in shared library using GCC

I am creating a shared library using gcc and suspect that there may be some memory leaks from the shared library. To debug, I need to enable debug symbols when creating the shared library. To buil...

Show Detail

How to enable Java 8 language features in Android studio

Now release with Android Studio 2.4 Preview 4, it is now supported Java 8 language features. Jack is no longer required, and need to disable Jack to use the improved Java 8 support built into the d...

Show Detail

Is Java 8 features available for Xamarin.Android in Java binding project?

I have an android library project that uses Java 8 features, i.e. via compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } When bindi...

Show Detail

Are Java-8 features really API independant on Android?

My application is using Gradle v7.5.1 (plugin v7.2.2) and I'm using some Java8 features in my code. According to https://developer.android.com/studio/write/java8-support,I shouldn't have any proble...

Show Detail

Enabling Sharepoint Features With Powershell

I am new to PowerShell and have been asked to modify a script that is used to activate features on a site. The script has some latency issues between the two feature activations, so I decided to m...

Show Detail

Unable to use some of the c++ features of OpenCV in Android

I am developing an Android application that involves some image processing. I am using Open CV. I integrated the open CV adding new module for Java and integrated for the native c++ as well. I can ...

Show Detail

Using Java 8 with android api 22

I'm using android studio 3.0.0 Beta 5 and according to this link I should be able to use some Java 8 features for any SDK version. But instead, I'm getting this exception for the targeted SDK 22:

Show Detail

Java 8 and Android

I'm working on a project split in 2: the library for the network stuff, written in pure Java (so it can be reused for a desktop version), and the Android app that only contains the GUI. The Androi...

Show Detail