Unresolved reference: Observable in Android Studio 3.4 - android

Updated to Android Studio 3.4, with Gradle 5.1.1 and Kotlin 1.3.10 as minimum versions. Cannot run project anymore due to reactivex.Observable not being found. Has anyone found a solution?
Was using rxBinding lib, also tried using latest vesions RxJava 2.2.8 and RxAndroid 2.1.1 with no success.

Downgrading the build.gradle(project) from classpath 'com.android.tools.build:gradle:3.4.0' to classpath 'com.android.tools.build:gradle:3.2.1' might be help you

The issue is that you need to use RxJava 2.2.8 and if you check the RxAndroid gradle file they are using the RxJava version 2.2.6 :
https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle
If you force RxJava to use version 2.2.8 it will work.
Add to gradle:
implementation 'io.reactivex.rxjava2:rxjava:2.2.8

Yeah the workaround* for me was to downgrade from gradle 5.1.1 to 4.10.1 and also to the latest android gradle plugin prior to 3.4.0, which is 3.3.2.
I did this in gradle/wrapper/gradle-wrapper.properties by changing to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
I then also changed the following in my root build.gradle file:
'com.android.tools.build:gradle:3.4.0' to 'com.android.tools.build:gradle:3.3.2'

Along with the dependency of RxKotlin use this
api 'io.reactivex.rxjava2:rxjava:2.2.0'
Only works for Gradle 5.0 or above

The accepted answer ended up leading me to the solution: leaving the gradle-wrapper.properties intact and don't increase the gradle version at all. We'll see if a future lib update will solve it for gradle 3.4.

Related

Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'

I'm having a problem with running my android app:
Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
That is caused by 1.7.0:
implementation 'com.google.android.material:material:1.7.0'
You better stick to 1.6.0 till they fix this
implementation 'com.google.android.material:material:1.6.0'
In your build.gradle file where "dependencies" section is paste this:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
in this section. And remove old strings with same text and other number versions. (in my case:
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
). Have worked for me.
source: https://github.com/facebook/react-native/issues/33926
Upgraded android gradle plugin to 7.2.2 and the problem is solved. Try updating Android Studio too
Rationale
To expand on the existing answers, the release notes for Material Components for Android 1.7.0 mentions that they have updated the minimum requirements for your project (emphasis mine):
New minimum requirements for your app's project:
Update to Android Gradle Plugin (AGP) version 7.2.0
Update to Gradle version 7.3.3
Update to Java 8 (version 1.8)
Update to Android Studio Chipmunk, version 2021.2.1
This is also mentioned in their (updated) Getting Started guide (again, emphasis mine):
5. Gradle, AGP, and Android Studio
When using MDC-Android version 1.7.0-alpha02 and above, you will need to make sure your project is built with the following minimum requirements, in order to support the latest build features such as XML macro:
Gradle version 7.3.3
Android Gradle Plugin (AGP) version 7.2.0
Android Studio Chipmunk, version 2021.2.1
Updating the Android Gradle Plugin
You can update the Android Gradle plugin as follows:
Gradle plugins DSL
The plugin declaration can be found in the top-level build.gradle/build.gradle.kts file:
plugins {
// Or "com.android.library"
id("com.android.application") version "7.2.2" apply false
}
Buildscript classpath
Update the AGP classpath dependency (usually in the top-level build.gradle/build.gradle.kts file):
classpath("com.android.tools.build:gradle:7.2.2")
update your build.gradle file as below:
classpath 'com.android.tools.build:gradle:7.2.1'
It will fix the issues, remember v7.3.x wont fix the issue, so stick to 7.2.1 as of now.
For Flutter User with this issue this is how you solve it::
Goto : build.gradle
change "classpath 'com.andriod.tools.build:gradle:5.6.0'"
to
"classpath 'com.andriod.tools.build:gradle:<latest version>'"
in my case :: classpath 'com.android.tools.build:gradle:7.2.1'
then goto :: android/gradle/wrapper/gradle-wrapper.properties
then change
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.3-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-<latest>-all.zip
in my case distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
In build.gradle(:app),
Updating, compileSdk and targetSdk to 33 helped me(from 32).
In order to get over with this. Upgrade to the latest gradle version as well as latest Android Studio.
I was also facing this issue and I followed these steps :
Upgraded Android Studio to Android Studio Dolphin | 2021.3.1 Patch 1
gradle version to 7.3.1 in project build.gradle
kotlin version to 1.7.20 in project build.gradle
targetSdkVersion and compileSdkVersion to 33
latest version of dependencies in app's build.gradle
And the project is perfectly working fine now.
I resolved it by replacing implementation 'androidx.recyclerview:recyclerview:1.2.1' instead of implementation 'com.google.android.material:material:1.7.0' in build.gradle(:app)
Upgraded android gradle plugin >= 7.1.0 and the problem is solved.
classpath "com.android.tools.build:gradle:7.1.0"
After wasting 2 hours and ruining my mood solution was simply upgrading your android studio version, most probably you are using an older version like Arctic fox or something like that, upgrade to dolphin or something higher. Hope it help, and yes in dolphin version it will give error of 30.0.3 but don't worry it gives you an attached link to install 30.0.0 SDK in console itself, so chill and keep developing.
first, in the gradle build file, change the implementation from 1.7.0 to 1.6.0
Next, open the colors file and change the color of the tag (#) which has 7 digits to a 6 digit tag. Because usually the default color of tags on Android Studio is sometimes 7 digits or 6 digits
I solved this by :
Adding in build.gradle:
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
adding android:exported="true" in Manifest

API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'

When building gradle I'm getting this message:
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'
I'm using Android Studio 4.1 Canary 10 and gradle:4.1.0-alpha10
It seems like the Navigation Safe Args plugin uses getApplicationIdTextResource(), so it is most likely that the error message is caused by your usage of that plugin.
You'd want to star the existing issue to ask the Safe Args plugin to use the new replacement API.
Changing to androidx.navigation:navigation-*:2.4.0-alpha02 as described here allowed a build of my app under Arctic Fox without getting the getApplicationIdTestResource warning
From the application build.gradle file:
def nav_version = "2.4.0-alpha02"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
And in the build.gradle file:
def nav_version = "2.4.0-alpha02"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
few days i see the same issue. Then i go to ->
build.gradle file
My Dependencies before update
check the dependencies
I update the dependencies google services to 4.3.4
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
After update
Now its working fine.
This error was for NavigationComponent for me in Android Studio Cannery 13.
So I changed the nav_version to this and My issue was solved.
ext {
*************** nav_version = "2.4.0-alpha10" ************
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha13'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
and in app module build.gradle:
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
It will be solved, when 4.2.0 is stable.
From the existing issue:
Android Gradle Plugin deprecated the getApplicationIdTextResource()
API on the class BaseVariant in version 4.1.0 (see bug). The
replacement API (onVariantProperties) did not work properly for
feature libraries, so to avoid the deprecation warning, reflection was
used. That is only a short term solution, and when AGP 4.2.0 is stable
we should update to that version and remove the reflection immediately
So if you need Safe Args and do not need latest features of Gradle, keep Gradle version in Android Gradle Plugin version at 3.6.4. Once stable 4.2.0 released, update to the latest.
This error happened after i updated kotlin version to 1.7.
this was for NavigationComponent in Android Studio
So I changed the nav_version to this and My issue was solved : "2.4.0-beta02"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.4.0-beta02"
implementation "androidx.navigation:navigation-ui-ktx:2.4.0-beta02"
For me it was because of different Kotlin versions between IDE Kotlin plugin and project_name/build.gradle file
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
"Kotlin version that is used for building with Gradle (1.3.72) differs from the one bundled into the IDE plugin (1.4.31) "
Once I made it even it started to compile again.
In my case I was using 2.3.1 version of navigation-fragment.
I just updated it to 2.4.2 and it's helped me
So, What i have done is that I have upgraded all the gradle plugins as well as dependecies versions and then run, It worked for me
I had the same problem and it was solved like this:
So I go to -> build.gradle file
My dependencies before upgrade
check the dependencies
I update Google services dependencies to latest version
dependencies {
classpath 'com.android.tools.build:gradle:(latest version)'
classpath 'com.google.gms:google-services:(latest version)'
}
Android Studio 4.1 giving the following information and It will be removed in version 5.0 of Android Gradle Plugin.
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see TBD.
To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
As #ianhanniballake has pointed out, it seems likely that it's caused by the Navigation Safe Args plugin, see the existing issue, also referenced from his answer. The issue was marked as fixed on 9 November.
In terms of fixing the build error, upgrading Android Studio from 4.1.0 to 4.1.1 fixed it for me.
delete the .idea and .gradle files from the project .. it worked with me

Attempt to use #BindView for an already bound ID 0

Android Studio Build fails with:
Attempt to use #BindView for an already bound ID 0 on 'mConnectionMessage'
Fragment.java:53: error: Attempt to use #BindView for an already bound ID 0 on 'mConnectionMessage'.
ImageView mConnectionImage;
^
Here's the part of the code that causes the problem:
#BindView(R2.id.display_discovery_state_icon)
ImageView mConnectionImage;
Upgrade the version of butterknife to 10.2.1
Short Answer:
Under:
build.gradle
change:
classpath 'com.android.tools.build:gradle:3.6.0'
to:
classpath 'com.android.tools.build:gradle:3.5.3'
Long Answer:
Android Studio update is the root cause of the issue.
Here's the update:
"To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin from the current version 3.5.3 to version 3.6.0 and Gradle to version 5.6.4. Release notes"
which changes:
classpath 'com.android.tools.build:gradle:3.5.3'
to
classpath 'com.android.tools.build:gradle:3.6.0'
and
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
The problem can be reproducible merely by making the above changes manually (not necessarily running the update).
Note:
I could reproduce the problem and fix, both on windows and mac.
Are you using butternife?
In my case, I upgraded to version 10.2.1 (com.jakewharton:butterknife-gradle-plugin:10.2.1) and no longer received the message.
I'm using gradle 3.6.1.

Android Studio, Unable to migrate to AndroidX

I'm having the following error message when trying to do refactor -> migrate to AndroidX
The gradle plugin version in your project build.gradle file needs to
be set to at least com.android.tools.build:gradle:3.2.0 in order to
migrate to AndroidX
Although I have version higher specified in build.gradle...
app/android/build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
I have another app/android/app/build.gradle.
I solved it by changing version to 3.4.1 and back to 3.4.2.
now error is gone..
in my case,
apply
classpath("com.android.tools.build:gradle:4.0.1")
instead of
classpath("com.android.tools.build:gradle:${version.gralde}") -> even version.gralde is 4.0.1
:thinking :) maybe android studio can't identity the plugin version if it references to an external value
Only change gradle version of a project may be not enough. Please also check gadle versions of the dependies. Make sure every gradle version of a depency is beyond 3.2.0. Have a try, please.

ButterKnife not working with Jack?

I just started a very simple project and tried to use both ButterKnife and Jack compiler, but it seems they do not cope with each other well.
Gradle plugin version: 2.2.0-alpha5
in my module build.gradle I added:
compile 'com.jakewharton:butterknife:8.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1'
And the error message is:
Error:Execution failed for task ':app:transformJackWithJackForDebug'.
java.lang.AssertionError: java.lang.IllegalArgumentException
Did I miss something or it's just they are not compatible?
Version 8.3.0 has just recently been released with support for Jack.
compile 'com.jakewharton:butterknife:8.3.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.3.0'
Try remove apply plugin: 'android-apt' in your app gradle.
As in the readme, it says:
Note: If you are using the new Jack compiler with version 2.2.0 or newer you do not need the 'android-apt' plugin and can instead replace apt with annotationProcessor when declaring the compiler dependency.
Thanks to #isnotmenow 's tip, I tried to change ButterKnife version to 8.1.0 and it works well.
But both 8.2.0 and 8.2.1 complain exceptions, I have post an an issue on the project page.
Here's a Jake Wharton's answer from similar StackOverflow post:
If you are using Jack:
Omit the 'android-apt' plugin completely.
Use annotationProcessor for the dependency (instead of apt).
I believe you have to be using version 2.2.0 of the Android Gradle
plugin though instead of 2.1.x (currently the latest is 2.2.0-alpha5).
The Butter Knife documentation will be updated for the next release
(8.2.0) to include this information.
From: Butterknife 8.1.0 not working with JDK 1.8 in Android Studio 2.1.2
Check also: http://github.com/JakeWharton/butterknife/issues/616
Hope it will help

Categories

Resources