Android dependency 'io.reactivex.rxjava2:rxandroid' has different version - android

When sync project with gradle files, Android Studio shows this error:
Android dependency 'io.reactivex.rxjava2:rxandroid' has different version for the compile (2.0.1) and runtime (2.1.0) classpath. You should manually set the same version via DependencyResolution
I have try to solve it with:
resolutionStrategy.force 'io.reactivex.rxjava2:rxandroid:2.1.0'
But with the same result.
This problem occurs when I change 'compile' with 'implementation' in the libraries definition
This is how I define the rest of the rx libraries:
buildscript {
ext.retrofitVersion = '2.4.0'
ext.rxVersion = '2.2.1'
ext.rxAndroidVersion = '2.1.0'
ext.okhttpVersion = '3.8.1'
ext.rxKotlinVersion = '2.0.0'
...
repositories {
mavenCentral()
jcenter()
}
}
//Rx & Retrofit 2 **********************************
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") {
// exclude Retrofit’s OkHttp peer-dependency module and define your own module import
exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"
implementation "io.reactivex.rxjava2:rxjava:$rxVersion"
Any ideas how can I solve this problem?

Ok, finally I solved the problem following the #yayo-arellano solution. I was to replace "implementation" by "api".

Related

Room kapt error when upgrading kotlin or gradle

I have been having for a long time this problem: I cannot upgraded the gradle version and kotlin gradle plugin in my app in Android Studio, the only solution that I can think of is to start a project from scratch and move one by one every class.
My app uses Room and therefore kapt as annotation process. With this version of kotlin and gradle everything works perfectly:
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50'
my app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//Kapt is the annotation processor of kotlin, all the generated code Ex. #Room depends of it
apply plugin: 'kotlin-kapt'
kapt {
generateStubs = true
correctErrorTypes = true
mapDiagnosticLocations = true
javacOptions {
// Increase the max count of errors from annotation processors.
// Default is 100.
option("-Xmaxerrs", 700)
}
}
android {
signingConfigs {
Default {
...
}
}
compileSdkVersion 29
defaultConfig {
applicationId "com.android.expenses"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.Default
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
sourceSets {
// Adds exported schema location as test app assets.
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
buildTypes {
debug {
....
}
release {
....
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
//To avoid duplicate class clash
exclude group: 'com.google.guava', module: 'listenablefuture'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//Para parcelize y autobinding in kotlin
androidExtensions {
experimental = true
}
kotlinOptions {
jvmTarget = '1.8'
}
//De databinding, y kotlinx
/*dataBinding {
enabled = true
}*/
//Substitule to 3 line above with this
android.buildFeatures.dataBinding true
}
dependencies {
//version definition
def room_version = "2.2.5"
implementation fileTree(include: ['*.jar'], dir: 'libs')
//androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
//})
testImplementation 'junit:junit:4.12'
// Required for instrumented tests
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
//Architecture
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'joda-time:joda-time:2.7'
implementation 'org.joda:joda-money:0.10.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.neovisionaries:nv-i18n:1.15'
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ColorPicker
implementation 'com.jaredrummler:colorpicker:1.1.0'
//Image Cropper
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
// Google Sheet API y Google Drive
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
// Google Sheet API
implementation('com.google.apis:google-api-services-sheets:v4-rev504-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
// Google Drive Rest
implementation('com.google.apis:google-api-services-drive:v3-rev102-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
//Google Drive Android
implementation "com.google.android.gms:play-services-drive:$rootProject.playServices_version"
//Google Maps
implementation "com.google.android.gms:play-services-location:$rootProject.playServices_version"
implementation 'com.google.android.gms:play-services-maps:16.1.0'
//Google Maps Utils
implementation 'com.google.maps.android:android-maps-utils:0.5'
//Google Places
implementation "com.google.android.gms:play-services-places:$rootProject.playServices_version"
//MultiViewAdapter para mejores recyclerviews
implementation 'com.github.devahamed:multi-view-adapter:1.2.6'
implementation 'com.github.devahamed:multi-view-adapter-databinding:1.2.6'
//CardView
implementation 'androidx.cardview:cardview:1.0.0'
//PagerSlidingTabStrip
implementation 'com.jpardogo.materialtabstrip:library:1.1.1'
//Room
implementation "androidx.room:room-runtime:$room_version"
//annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - Kotlin Extensions and Coroutines support for Room
//implementation "androidx.room:room-ktx:$room_version"
// Test helpers
androidTestImplementation "androidx.room:room-testing:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// Lifecycle components
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.3.1'
kapt 'androidx.lifecycle:lifecycle-compiler:2.3.1'
//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
// RxJava support for Room
implementation 'androidx.room:room-rxjava2:2.0.0'
//Android Palette API
implementation 'androidx.palette:palette:1.0.0'
//Welcome Activity
implementation 'com.github.AppIntro:AppIntro:6.1.0'
//Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
//TableView
implementation 'com.evrencoskun.library:tableview:0.8.8'
//Anko Commons Library for easier development
implementation "org.jetbrains.anko:anko-commons:$anko_version"
//Search Dialog
implementation 'com.github.mirrajabi:search-dialog:1.2.4'
//FAB Button Speed Dial
implementation 'com.leinardi.android:speed-dial:3.2.0'
//WorkManager
implementation('androidx.work:work-runtime-ktx:2.0.1') {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
//PagingList
implementation 'androidx.paging:paging-runtime:2.1.0'
//Calendar
implementation 'com.github.prolificinteractive:material-calendarview:2.0.1'
//Image Compressing
implementation 'id.zelory:compressor:3.0.1'
//New Places: Old one is deprecated
implementation 'com.google.android.libraries.places:places:2.4.0'
// Koin for Android
implementation 'org.koin:koin-android:2.0.0-rc-2'
implementation 'org.koin:koin-android-viewmodel:2.0.0-rc-2'
// KTX
implementation 'androidx.core:core-ktx:1.3.2'
// Rx
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
// Moshi
implementation 'com.squareup.moshi:moshi:1.8.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.8.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.5.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.1'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//SQLCipher
implementation "net.zetetic:android-database-sqlcipher:4.4.0#aar"
....
}
repositories {
mavenCentral()
}
// For Firebase
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
I tried to update to the current newest version of each, although this problem exists in not so new versions
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
In order to make this change I did the following:
Update Java jdk to 11
Replace kotlin-android-extensions with 'kotlin-parcelize' and viewBinding = true
Remove androidExtensions: experimental=true
Replace the parcelize import with kotlinx.parcelize.Parcelize
Even all this, I still have this error
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
> java.lang.reflect.InvocationTargetException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
There are messages below app:kaptDebugKotlin but they are warnings of multiple constructors of non #Entity classes which shouldn't provoke the crash
This is really frustrating cause I don't know what else to do or how to get more information (I also did a run with --info and I only get the same output from kapt)
Thank you in advance for your time and help
UPDATE
Here is my top gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//ext.kotlin_version = '1.4.10'
//Working version
ext.kotlin_version = '1.3.50'
//Latest version
//ext.kotlin_version = '1.5.20'
//ext.kotlin_version = '1.3.41'
repositories {
mavenCentral()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
//jcenter()
}
dependencies {
// working version, if change modify distributionUrl in gradle-wrapper.properties
classpath 'com.android.tools.build:gradle:4.0.2'
// to upgrade
//classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
//De MaterialChipsInput y Search Dialog
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
archLifecycleVersion = '1.1.1'
anko_version='0.10.5'
support_version = '28.0.0'
playServices_version = '16.0.0'
}
Quick update, when I try to upgrade only the room version to 2.3.0 the error occurs:
[kapt] An exception occurred: java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
at androidx.room.log.RLog$CollectingMessager$writeTo$printMessage$1.<init>(RLog.kt)
at androidx.room.log.RLog$CollectingMessager.writeTo(RLog.kt:92)
at androidx.room.solver.TypeAdapterStore.findRowAdapter(TypeAdapterStore.kt:520)
at androidx.room.solver.TypeAdapterStore.findQueryResultAdapter(TypeAdapterStore.kt:459)
at androidx.room.solver.binderprovider.InstantQueryResultBinderProvider.provide(InstantQueryResultBinderProvider.kt:29)
at androidx.room.solver.TypeAdapterStore.findQueryResultBinder(TypeAdapterStore.kt:391)
at androidx.room.processor.DefaultMethodProcessorDelegate.findResultBinder(MethodProcessorDelegate.kt:140)
at androidx.room.processor.InternalQueryProcessor.getQueryMethod(QueryMethodProcessor.kt:204)
at androidx.room.processor.InternalQueryProcessor.processQuery(QueryMethodProcessor.kt:135)
at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:67)
at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:37)
at androidx.room.processor.Context.collectLogs(Context.kt:133)
at androidx.room.processor.QueryMethodProcessor.process(QueryMethodProcessor.kt:61)
at androidx.room.processor.DaoProcessor.process(DaoProcessor.kt:99)
at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:100)
at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:51)
at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:47)
at androidx.room.compiler.processing.JavacProcessingStepDelegate.process(XProcessingStep.kt:111)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:79)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:230)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:188)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:81)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:555)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:546)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$256(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Any idea why and is it related?
SOLUTION:
In case anyone is searching for something similar, I finally redid the project and the problem was related with moshi kapt. I update the library to 1.12.0 and everything works
In my case, I have faced the same issue while I have upgraded "kotlin-gradle-plugin: from 1.5.31 to 1.6.10".
I have solved this issue by Upgrading Gradle Version to the latest version by following official docs.
In android studio got to File>Project Structure>Project>Gradle Version here select the latest version of Gradel.
I think, This happens when we update "kotlin-gradle-plugin" and the other dependencies are not the latest version.
Also, Check your JDK version you can follow official docs.
Upgrade room to 2.4.0-beta02 will fix your problem. Because it fix mine.
We've added a new TypeConverter analyzer that takes nullability information in types into account. As this information is only available in KSP, it is turned on by default only in KSP. If it causes any issues, you can turn it off by passing room.useNullAwareTypeAnalysis=false to the annotation processor. If that happens, please a file bug as this flag will be removed in the future. With this new TypeConverter analyzer, it is suggested to only provide non-null receiving TypeConverters as the new analyzer has the ability to wrap them with a null check. Note that this has no impact for users using KAPT or Java as the annotation processors (unlike KSP), don't have nullability information in types. (Ia88f9, b/193437407)
https://developer.android.com/jetpack/androidx/releases/room#2.4.0-beta02
In your dependencies below the //Room comment add the following :
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
and make sure you are using latest room_version = [2.3.0]

Unable to find method 'com.android.tools.r8.Version.getVersionString()Ljava/lang/String;'

I have updated my android studio to 3.4.
I am getting error while making release build.
Unable to find method
'com.android.tools.r8.Version.getVersionString()Ljava/lang/String;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after
a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping
all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible
with the other plugins in the project or the version of Gradle
requested by the project.
In the case of corrupt Gradle processes, you can also try closing the
IDE and then killing all Java processes.
I have updated my dependencies in gradle
Here is my gradle file
dependencies {
//Retrofit networking libraries
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//Use for converting JsonObject to Plain Text in retrofit
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
//http logging interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// For circular progressbar design
implementation 'me.relex:circleindicator:1.2.2#aar'
//Crashlytics library dependency
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
//ViewModel concept used in
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:livedata-core:1.1.1'
//RangeSeekBar Design
implementation 'com.yahoo.mobile.client.android.util.rangeseekbar:rangeseekbar-library:0.1.0'
//Clevertap events
implementation 'com.clevertap.android:clevertap-android-sdk:3.2.0'
//For volley networking library implementation
implementation 'com.android.volley:volley:1.1.0'
//For token passing classes
implementation 'com.auth0.android:jwtdecode:1.1.1'
//Rooted device finding library
implementation 'com.scottyab:rootbeer-lib:0.0.7'
//Facebook integration
implementation 'com.facebook.android:facebook-android-sdk:4.35.0'
//New Relic interation library
implementation 'com.newrelic.agent.android:android-agent:5.9.0'
//Calender library
implementation project(':library')
//Channel level encryption library
implementation files('libs/bcprov-jdk15on-160.jar')
//Injection tool
annotationProcessor 'com.jakewharton:butterknife:6.1.0'
implementation 'com.jakewharton:butterknife:6.1.0'
/*annotationProcessor 'com.jakewharton:butterknife:10.1.0'
implementation 'com.jakewharton:butterknife:10.1.0'*/
//Image Loading library
implementation 'com.github.bumptech.glide:glide:3.7.0'
//Secure SQLite Database
implementation 'net.zetetic:android-database-sqlcipher:3.5.9#aar'
//Branch .io library
implementation('io.branch.sdk.android:library:2.+') {
exclude module: 'answers.shim'
}
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:design:26.0.2'
implementation 'com.google.android.gms:play-services:11.0.1'
implementation 'com.google.android.gms:play-services-maps:11.0.1'
implementation 'com.google.firebase:firebase-core:11.0.1'
implementation 'com.google.firebase:firebase-messaging:11.0.1'
implementation 'com.android.support:support-v4:26.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':mpointintegration')
}
I am not using kotlin.
I checked various resources like below but none worked
java.lang.NoSuchMethodError - Ljava/lang/String;)Ljava/lang/String;
Android Studio 3.0 - Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List'
also tried with
Re-download dependencies and sync project
&
Stop Gradle build processes (requires restart)
but none worked.
Project Level gradle File
// Top-level build file where you can add configuration options common
to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
maven { url "http://storage.googleapis.com/r8-releases/raw"}
}
dependencies {
classpath ('com.android.tools:r8:1.3.52' ) { transitive false }
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.9.0"
// NOTE: Do not place your application dependencies here; they
belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
// maven { url 'https://jitpack.io' }
google()
}
}
ext {
minSdkVersion = 15
targetSdkVersion = 26
compileSdkVersion = 26
buildToolsVersion = '26.0.2'
sourceCompatibilityVersion = JavaVersion.VERSION_1_8
targetCompatibilityVersion = JavaVersion.VERSION_1_8
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext.deps = [
// Test dependencies
junit : 'junit:junit:4.10',
festandroid: 'com.squareup:fest-android:1.0.7',
robolectric: 'org.robolectric:robolectric:2.2',
intellijannotations: 'com.intellij:annotations:12.0'
]
The issue is that you have a fixed version dependency on R8 1.3.52:
classpath ('com.android.tools:r8:1.3.52' ) { transitive false }
And the com.android.tools.r8.Version method
public String getVersionString()
is only present in the R8 1.4 versions and above.
I assume that you are using a fixed version of R8 due to a bug fix in that version. However that should also be fixed in the latest version, so I suggest that you remove the fixed R8 version dependency and use what is shipped with Android Studio.
I solved it. From android studio 3.4 R8 versioning is added in android studio.
So i did some changes in my build.gradle file and gradle.properties file
In my app level build.gradle file in release section I added one line
useProguard false
& in gradle.properties file
android.enableR8=true
so it will use R8 Versioning to create my APK.
Incase if you dont want to use R8 versioning and want to continue with proguard then make
android.enableR8=false //in gradle.properties file
Hope this will help someone

Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX

I'm using Android Studio 3.2 Beta5 to migrate my project to AndroidX. When I rebuild my app I got these errors:
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'
ERROR: [TAG] Failed to resolve variable '${junit.version}'
Full clean & rebuild did not work! Anyone know how to fix this?
gradle.properties
android.enableJetifier=true
android.useAndroidX=true
build.gradle
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta05'
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:5.3.1"
classpath 'io.fabric.tools:gradle:1.25.4'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.iceteaviet.fastfoodfinder"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0-rc01'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'io.realm:realm-android-library:5.3.1'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.0.2'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
implementation 'com.google.firebase:firebase-perf:16.0.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}
apply plugin: 'com.google.gms.google-services'
I fix this with two steps
1) File -> Invalidate Caches / restart...
2) Build -> Clean project
I got the same error after updating my build.gradle file with AndroidX Test dependencies. Turns out I forgot to remove the old junit dependency. So for me, the fix was simply to remove the following dependency:
dependencies {
...
testImplementation 'junit:junit:4.12'
}
Adding Java 8 support to build.gradle file fixed issue for me
android {
...
//Add the following configuration in order to target Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
It seems to be Glide the problem.
I had the same error and I just updated the Glide's dependencies to 4.8 and there is no build errors.
Kotlin :
// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
Java :
// Glide
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
Be sure to have enabled in your gradle.properties :
android.useAndroidX=true
android.enableJetifier=true
Source : https://github.com/bumptech/glide/issues/3124
Hope this will help you!
Fixed it by going to the main directory and typing flutter clean
Removing the testInstrumentationRunner worked for me:
defaultConfig {
...
...
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
If you're using Kotlin, the issue will popup if don't use the kapt version for any annotation processor you use in the project.
As #Vince mentioned the case with Glide, this could happen with Dagger2, Butterknife, etc.
If you're using both Java and Kotlin you'll need to keep both dependencies, as follows (were $glideVersion is a predefined version of Glide):
implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
If you're on a Kotlin only project, the kapt dependency should work alone.
EDIT
Another thing you should have in mind is if you're already using Androidx. Androidx is a great refactor but when migrating it can cause some of your dependencies to collapse. Mainstream libraries are already updated to Androidx, however, some of them are not and even won't.
If the issue doesn't go away with my provided solution above this edit, you can take a look at your dependencies and make sure they use Androidx as well.
EDIT 2
As #Ted mentioned, I researched back and he's right kapt does handle java files as well. kapt alone will do the trick, no need to keep both kapt and annotationProcessor dependencies.
Try removing this line:
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
from the buildscript / repositories section of your build.gradle file.
When I added that line, I got the error you described. When I removed it, no longer. That line should only be in the allprojects / repositories section.
Try set android.enableJetifier=false in gradle.properties. Then Invalidate Caches / Restart ... in Android Studio
The fix is in 4.2.0, use the higher version of google gms jar.
Try changing:
classpath 'com.google.gms:google-services:4.0.1'
by this version:
classpath 'com.google.gms:google-services:4.2.0'
Hope this works...
If you are using dagger or butterknife, please make sure to update it to the latest version. Or, if you have another injection library used in your project, you can try to check it if it support androidx or no.
I've found same error, the problem is on my dagger and butterknife. Have fixed it by updating it to newest version.
Android version: 4.10.2
I solved this issue with three simple steps:
First i added below this in pubspec.yml:
(with two spaces of identation)
module:
androidX: true
Adding this two lines below in gradle.properties, i have this in android/gradle.properties, in the project folder.
android.useAndroidX=true
android.enableJetifier=true
And after this i wrote with the terminal:
flutter clean
Maybe you will have to stop the device and run again.
I fixed this by updating the firebase dependencies to the latest.
I faced this error after adding butterknife to my project.
In order to resolve this error you should use Java8.
I would recommend this answer.
How I resolved it:
1.add following code in build.gradle (module: app)
android {
...
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
clean prject and run.
I fixed it by refreshing the cahche (Instead of invalidating it - which also clears the local history):
in gradle.properties file, comment the line org.gradle.caching=true.
Clean, Rebuild.
in gradle.properties file, un-comment the line
org.gradle.caching=true.
Clean, Rebuild.
Thats it!
Go to file and click on Invalidate caches and restart.
After it restarts then you increase the minimum SDK version in your app's build.gradle file.

Annotation processors must be explicitly declared now. - compiler-1.1.1.jar (android.arch.lifecycle:compiler:1.1.1)

I am trying to add below libraries into my app
ext {
roomLibraryVersion = '1.1.0'
lifeCycleVersion = '1.1.1'
}
//room data base
implementation "android.arch.persistence.room:runtime:$roomLibraryVersion"
implementation "android.arch.persistence.room:compiler:$roomLibraryVersion"
annotationProcessor "android.arch.persistence.room:compiler:$roomLibraryVersion"
//life cycle
implementation "android.arch.lifecycle:runtime:$lifeCycleVersion"
implementation "android.arch.lifecycle:compiler:$lifeCycleVersion"
implementation "android.arch.lifecycle:extensions:$lifeCycleVersion"
// rx android
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation "io.reactivex.rxjava2:rxjava:2.1.14"
implementation 'android.arch.persistence.room:rxjava2:1.1.0'
//paging
implementation 'android.arch.paging:runtime:1.0.0'
I am getting below exception while running the code. Can anybody please help me to solve this issue
Execution failed for task ':app:javaPreCompileDebug'.
> 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.
- compiler-1.1.1.jar (android.arch.lifecycle:compiler:1.1.1)
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.
Change:
implementation "android.arch.lifecycle:compiler:$lifeCycleVersion"
to:
annotationProcessor "android.arch.lifecycle:compiler:$lifeCycleVersion"
If you're using Kotlin, replace 'implementation' with 'kapt'
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
kapt "android.arch.lifecycle:compiler:$lifecycle_version"
And put this at the top of your app level Gradle file
apply plugin: 'kotlin-kapt'

DataBinding (libraries must use the exact same version specification)

Gradle:
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
=========================
ext {
support_version = '27.0.2'
dagger_version = '2.14.1'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
//support
implementation "com.android.support:appcompat-v7:$support_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//rx
implementation 'io.reactivex.rxjava2:rxjava:2.1.8'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
//test
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//Dagger 2
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
provided 'org.glassfish:javax.annotation:10.0-b28'
}
It's work well for me, but if I enable DataBinding:
dataBinding {
enabled = true
}
I got a warning com.android.support:appcompat-v7:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 21.0.3. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:support-v4:21.0.3 more... (Ctrl+F1)
and lost method checkSelfPermission in ContextCompat:
ContextCompat.checkSelfPermission(context, android.Manifest.permission.READ_SMS)
Unresolved reference: checkSelfPermission
Gradle file
Why enabling DataBinding leads to such an effect?
Why enabling DataBinding leads to such an effect?
Behind the scenes, dataBinding { enabled = true } adds some dependencies for runtime libraries that support the generated data binding code:
com.android.databinding:adapters
com.android.databinding:baseLibrary
com.android.databinding:library
Those dependencies, in turn, currently have a dependency on an old version of support-v4 (21.0.3). That, in turn, triggers the build error that you are seeing, as Google is trying to enforce that all Support Library artifacts are on the same version.
FWIW, I filed an issue to get this fixed in the data binding framework. I hope that it will be fixed sometime before the heat death of the universe.
The workaround is to add your own dependency on support-v4:
implementation "com.android.support:support-v4:$support_version"
This will cause Gradle to pull in your requested version, which is newer than the one that data binding is seeking, and so Gradle assumes that it will be OK. In truth, it might not be OK, but so far, in my work, I haven't run into any problems.
If you get Gradle Sync Error...
Android dependency 'com.android.support:support-v4' has different
version for the compile (21.0.3) and runtime (27.0.2) classpath. You
should manually set the same version via DependencyResolution
... try api com.android.support:support-v4:27.0.2 instead of implementation com.android.support:support-v4:$support_version.

Categories

Resources