Reputation: 115
While enabling jack I get following error
Error:Jar transformation: class files coming from an unsupported Java version Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'. com.android.build.api.transform.TransformException: com.android.builder.core.JackToolchain$ToolchainException: Jack compilation exception
My build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "pl.develhopper.jaxygenaddclientlib"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
jackOptions { // DEPRECATED
enabled true
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.2'
compile 'javax.xml.bind:jaxb-api:2.3.0'
testCompile 'junit:junit:4.12'
}
Doe anyone has an error like this? Where does it come from?
Upvotes: 0
Views: 732
Reputation: 28238
Jack is deprecated. If you want to use Java 8 you should update Android Studio to 3.0, mostly because you don't need Jack to use Java 8 with Android Studio 3.0
Jack is flawed, I couldn't even get it to compile when I used it. In my experience, the entire thing is buggy. Android Studio 3.0 comes with Java 8 support without Jack, meaning you don't need to deal with it.
if you already are using Android Studio 3, you can just remove the jack code in general. It isn't needed. If you are on a lower version, upgrade and then remove the jack code.
And if you read this:
Android Studio provides built-in support for using certain Java 8 language features and third-party libraries that use them. As shown in figure 1, the default toolchain implements the new language features by performing bytecode transformations, called desugar, on the output of the javac compiler. Jack is no longer supported, and you should first disable Jack to use the Java 8 support built into the default toolchain.
you'll see that AS 3 (the version referenced at the start of the site, not included in this answer for brevity) has support for Java 8 without jack. And since jack is deprecated and (in my experience) bugged, upgrading is your best option to get Java 8
Upvotes: 1