I have Android Room Persistence library in project(version 1.0.0) and set compile options to 1.8. When project build finishes, i get this warning:
Warning:Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'
Everything works fine, but this warning annoys me. How to remove it?
Adding this dependency dosn't remove warning and i don't use another architecture components.
"android.arch.lifecycle:common-java8:1.0.0"
(Note: this answer is relevant to Kotlin based gradle projects that use the 'kotlin-kapt' plugin (kotlin annotation processor plugin), but should also be useful to Java based projects.)
This warning seems to be fixed in the latest version of the Room library.
I replaced:
kapt "android.arch.persistence.room:compiler:1.0.0"
with
kapt "android.arch.persistence.room:compiler:1.1.0-alpha1"
and the warning went away.
BTW, for Kotlin projects, the warning message varies with the Kotlin version.
With Kotlin 1.1.0 it's:
warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'
but with Kotlin 1.2.21 it's:
warning: Supported source version 'RELEASE_7' from annotation processor 'org.jetbrains.kotlin.kapt3.ProcessorWrapper' less than -source '1.8'
The fix was the same in both cases.
Everything works fine, but this warning annoys me. How to remove it?
Well, You need to disable lint check temporary (Not recommended), by adding these lines into build.gradle:-
android {
lintOptions {
tasks.lint.enabled = false
}
...
}
Adding "android.arch.lifecycle:common-java8:1.0.0" will remove warnings for lifecycle not for room.
By the way, this is just a warning not an error. Ignore it until Google decides to support Java 8 like they did in lifecycle library.
Updating room version from 1.0.0 to 1.1.0 gets rid of the warning.
So just have these following dependencies.
dependencies {
def room_version = "1.1.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
}
replaced:
"android.arch.persistence.room:compiler:1.0.0"
with
"android.arch.persistence.room:compiler:1.1.1"
i have the same issue, but i fixed it by
replace
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
to
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
Related
All I wanted to do in my Android Native app using Jetpack Compose was to use some of the newer versions of some of the software. I guess I should have known better, because this has turned into the usual dependency nightmare. I have wasted all afternoon trying to get this to compile and run.
I’ll start with the error message, and work backwards:
> Task :app:compileDebugKotlin FAILED
> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
> e: This version (1.2.0-alpha05) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.7.10 which is not known to be compatible. Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
First, I have no idea why the compileDebugKotlin thinks I am targeting JVM 1.8 instead of 17. My JAVA_HOME is set to Java 17, my IntelliJ Project Structure JDK is set to 17, and my app:build.gradle has the following:
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
I do not see 1.8 being set anywhere.
The next issue is the Compose Compiler version that the error message is showing, 1.2.0-alpha05. I am setting the following in my root build.gradle file:
buildscript {
ext {
compose_version = '1.3.0'
…
And then referring to it in my app:build.gradle file:
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
I have no idea where it’s coming up with 1.2.0-alpha05 as the version.
The next issue is that it thinks I'm using Kotlin 1.7.10. I have set the Kotlin version to 1.6.10 in the IntelliJ preferences for Kotlin compiler, as well as 17 for the JVM. I tried the following in build.gradle, but it seems to be ignored, it is making no difference:
kotlin {
version("1.6.10")
}
In a nutshell, I have no idea where any of these version numbers are coming from, and how to set them so that they reflect the reality that I thought I was configuring correctly. I have cleared the IntelliJ cache and restarted numerous times.
the two task shown in the error have different functions during a build
compileDebugJavaWithJavac is responsible for generating the bytecode for the Java Code and making it available for further processing. which in your case is targeted to java 17 but compileDebugKotlin is responsible for making bytecode for kotlin code in your case it is targeted to 1.8 ,that is not supported so you should add
kotlinOptions {
jvmTarget = '17'
}
composeCompiler is not Compatible with all versions of Kotlin. Each compose compiler has corresponding compatible Kotlin Version (Compose to Kotlin Compatibility Map). what you shown is compose_version which do not represent Compose Compiler, they are declared in
composeOptions {
kotlinCompilerExtensionVersion = "1.x.x"
}
What is the basic core difference between:
kotlin-kapt
annotationProcessor()
Also, what's the working behavior of these in Kotlin/Java?
I researched a lot about this topic but I'm a little bit confused. So, I need to learn more to clear my concepts.
kapt: Default annotation processor for Kotlin projects, useful to reference generated code at compile time in a kotlin project. In order to use it you should use the kotlin-kapt plugin. It also takes care of java classes
plugins {
kotlin("kapt") version "1.7.10"
}
and the related dependency:
dependencies {
kapt("groupId:artifactId:version")
}
annotationProcessor: gradle directive to specify your own annotationProcessor or a third party one. For example, in the old android projects was common to use Butterknife library that has its own annotation processor:
dependencies {
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
}
In general, an annotation processor is useful to generate code automatically from annotations (for butternife, for example #BindView) and this is true both for kapt and for a random third-party annotation processor.
while generating apk getting this error i have already tried upadting the pugins also as it was recommended
Annotation processors must be explicitly declared now.
The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- icepick-processor-3.2.0.jar (frankiesardo:icepick-processor:3.2.0)
- auto-service-1.0-rc2.jar (com.google.auto.service:auto-service:1.0-rc2)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
You should explicitly add annotation processors in gradle. Putting the following in your gradle dependencies should fix it:
annotationProcessor 'frankiesardo:icepick-processor:3.2.0'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
I am using Gradle to build an Android Studio project. I am using auto-value in one of my modules but for some reason, any version of auto-value higher than 1.5.3 causes a compilation failure.
My dependency in build.gradle for the module looks like this:
annotationProcessor 'com.google.auto.value:auto-value:1.5.3'
If I just change that 1.5.3 to 1.6.5, I get the following error when building (syncing works fine):
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- auto-value-1.5.3.jar (com.google.auto.value:auto-value:1.5.3)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
I even tried using the recommended instructions on the documentation:
api "com.google.auto.value:auto-value-annotations:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
Any clue what to do here?
I'm trying to add ViewModel and LiveData to a Kotlin app. I have the following dependencies added to my module's build.gradle:
implementation "android.arch.lifecycle:extensions:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
testImplementation "android.arch.core:core-testing:1.1.1"
I'm given the following error:
Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.1) classpath. You should manually set the same version via DependencyResolution
Removing the first line (extensions) fixes the issue, indicating that the error is coming from there, but I can't figure out why.
As #RedBassett mentions Support libraries depends on this lightweight import (runtime library) as explained at android developers documentation.
This is, android.arch.lifecycle:runtime:1.0.0 is spreading up in the dependency tree as a result of an internal api (transitive) import so in my case I only had to include extensions library as "api" instead of "implementation" so that it will override its version to the highest (1.1.1).
In conclusion, change
implementation "android.arch.lifecycle:extensions:1.1.1"
to
api "android.arch.lifecycle:extensions:1.1.1"
In your main build.gradle file
allprojects {
...
configurations {
all {
resolutionStrategy {
force "android.arch.lifecycle:runtime:1.1.1"
}
}
}
}
This will enforce version 1.1.1
Apparently support-v4 was causing the conflict. In the case of this question, the Gradle dependency task wasn't working correctly, but for anyone else who runs into this issue:
./gradlew :app:dependencies will show the sub-dependencies used by your dependencies. Search the output of this command (changing app for your module name) for the dependency causing the conflict.
#RedBassett is right. However I was still having some problem excluding android.arch.lifecycle related sub dependencies.
In my case the conflict was caused in com.android.support:appcompat-v7:27.1.1.
This is how my gradle dependency looks like after excluding it.
implementation ('com.android.support:appcompat-v7:27.1.1') {
exclude group: 'android.arch.lifecycle'
}
api "android.arch.lifecycle:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
Also, you will have to add this exclude in every imported module.
I searched for all dependencies with ./gradlew :app:dependencies as #RedBassett mentioned. I noticed the incompatible version of android.arch.core:runtime that Gradle was complaining about was stemming from my version of com.android.support:appcompat-v7, so I just updated that version to the latest and everything worked.