Didn't find class "java.lang.Math8" on path: DexPathList - android

After migrating the Gradle version to 7.2, I get this error when running the application.
I noticed that it's pointing to Java 8 date/time feature, LocalDate.
My project already has coreLibraryDesugaringEnabled = true enabled.

After lots of searches without any result, I noticed only a simple solution as updating the coreLibraryDesugaring version will solve the problem. upgrading from 1.1.1 to 1.1.5.
Hope this saves you some time!

Can confirm that Amir's answer solved this for me. Under dependencies, bump to this: coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

Related

Superclass androidx.core.app.f of androidx.activity.ComponentActivity is declared final

I wanted to update the version of the application in the Play Store, but in the tests I started getting this error.
Superclass androidx.core.app.f of androidx.activity.ComponentActivity is declared final
According to the google issues tracker this is new, maybe someone has a solution to this problem.
I added
-keep class androidx.core.app.** { *; }
In the proguard rules to solve the issue.
Edit: minus sign (-) needs to be before the line
On 27.07.2022 Google team members posted that the bug has been fixed.
and on 09.08.2022 they added some explanation that you can find in this link.
In two words:
In pre-launch testing app-crawler apk and the app apk generated different ‘keep rules’ for shrunk.
This will cause ‘no such method’ or ‘superclass will be declared final’.
Did you upgrade some libraries in your build.gradle?
Coroutines maybe?
We have this exception reported too and it has the same stack trace as an older exception we had before, so possibly equally related to the Kotlin coroutines lib version:
java.lang.VerifyError: Verifier rejected class. Code working fine in debug mode, but not throwing this error in release mode
You try update implementation 'com.google.android.gms' in build.gradle to lastest version
I had the same issue with Flutter. I remove Firebase from build.gradle
// implementation platform('com.google.firebase:firebase-bom:29.0.4')
also downgrading firebase to 29.0.2 is working too.
I added this line into gradle.properties
android.enableR8.fullMode=true
I hope it will help you too
For builds made before August 2022
If your APK/App Boundle was created before August 2022, the issue might be related to an internal issue by Google.
See this issue tracker: https://issuetracker.google.com/issues/237785592?pli=1
For me it was enough to build a new release on my machine (increasing version number at least by 1!) and upload it... Afterwards, the problem was gone.

Cannot resolve symbol repeatOnLifecycle in Android

I'm following this article to collect flows in UI. But I couldn't resolve repeatOnLifeCycle API in my code. I have added the below dependency, though.
lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
Please help
It's not
lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
but
androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
I hope this gradle config can help you.
def lifecycle_version = "2.4.0"
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
With this set, i resolve "repeatOnLifecycle" with this import:
import androidx.lifecycle.repeatOnLifecycle
I also had a similar issue. For me, adding the following in the dependencies section of the build.gradle file (the App Module one and not the Project one) helped to resolve the issue:
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03"
I also removed the import androidx.lifecycle.Lifecycle that was already there in the problematic file and got Android Studio to import the right one just in case the old one was wrong.
Found the latest version number to use(i.e. the "2.4.0-alpha03" part) from the following link but I think Android Studio would have later given a hint on the latest version to upgrade to anyway even if I hadn't done this:
https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-runtime-ktx/2.2.0-alpha01
Note: These APIs are available in the lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01 library or later.
lifecycle-runtime-ktx
for me changing gradle from offline to online somehow solved the problem :/

RxSearchView not supporting androidx SearchView?

I've migrated my project to androidx. When i use RxSearchView it results in an error
RxSearchView.queryTextChanges(searchView).
Type mismatch.
Required:
android.widget.SearchView
Found:
androidx.appcompat.widget.SearchView
I was facing this problem recently and was able to fix it by using this explicit dependency: implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0-alpha2'.
You can find this dependency and some other ones at Github RxBinding.
I hope I was not too late and I hope this helps!
Edit
I know I responded this not long ago but something messed up the library. 3.0.0-alpha is no longer the latest release and has been replaced with version 3.0.0 of which I no longer find RxSearchView anywhere, not even on the alpha version.
Edit 2
Since I never found RxSearchView again, I had to implement an OnQueryTextListener myself, following a pretty cool tutorial I found here. It uses Kotlin's new coroutines and works as fine as RxSearchview.
If you update your dependency to the rxbinding3, version 3.0.0 by adding the following line in your app's build.gradle:
implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0'
Then you should be fine by simply using the new API adapted to the Kotlin style:
Replace your code where it has
RxSearchView.queryTextChangeEvents(searchView)
to
searchView.queryTextChangeEvents()
Also keep in mind that the return value typed as SearchViewQueryTextEvent uses property access, so things like it.queryText() should be changed to it.queryText.

appcompat-v7:28.0.0-rc02 doesn't work with design:28.0.0-rc01(should be rc02, but we can't)

com.android.support:appcompat-v7:28.0.0-rc02
com.android.support:design:28.0.0-rc01 -> should be rc02, but there's no rc02 actually.
error:
app/build.gradle:74: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
Found versions 28.0.0-rc02, 28.0.0-rc01. Examples include com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01 [GradleCompatible]
I know it's a warning, we have turned to warn as the errors in CI in order to avoid the potential dead crashes, well, any solution except turn off option for CI?
issue
UPDATE
Design library version 28.0.0-cr02 published.
OLD ANSWER
According to this link
https://mvnrepository.com/artifact/com.android.support/design?repo=google
design:28.0.0-rc02 not yet published.
So all you can do for now is use the previous version for appcompat and wait until design library new version28.0.0-cr02 release.
So for now use this :
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
I don't know why... But they(sdk devs) behaving like Microsoft..
"Ohh..It compiles, lets ship it".
They just launch and don't care about bugs.. after updating to latest libs every time, first thing i get is..
"Layout editor preview errors.".
i hope it will be easy next time. :/
Keep track of the library here, until its published, use rc01 for other ones.
https://mvnrepository.com/artifact/com.android.support/design?repo=google
That's why I use stable versions always
If you are developing an app, you don't want to face these type of errors.
At the time of answering the current most stable version is 27.1.1 and second 28.0.0-rc02.
I suggest use 27.1.1 until 28 stable version release.
implementation 'com.android.support:appcompat-v7:27.1.1'
Sync again
No need of Invalidate/ Restart, Just restart would be okay. Or closing project and reopening from recent would be faster then restart.
Track the support library release.
Replace your
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
with
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
Looks like this should no longer be an issue. Looking at the link below, i think that whatever hiccups were encountered by OP are no longer relevant.
https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0-rc02
About the error message "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)." The solution is outlined here (the answer by João Paulo Paiva).
To rid yourself of the error message, you have to basically include each package name mentioned in the warning - com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01
Essentially, manually add the following lines to your build.gradle
implementation com.android.support:animated-vector-drawable:28.0.0-rc02
implementation com.android.support:cardview-v7:28.0.0-rc02
You may encounter more such warnings - the solution is to keep subsequently adding the libraries/dependencies mentioned (and updating the version to 28.0.0-rc02 as well) until the warnings go away. I had this issue, and after the first lot, I didn't get any more, but YMMV!
1.Go to project/.idea/libraries folder on your file system and see which libraries are different.
2.You will have to manually include these libraries with the same version in your build.gradle file.
3.Then, sync your project
In Your Case:-
Add This Dependency :-
implements 'com.android.support:cardview-v7:28.0.0-rc02'
Add all dependency with Latest version which shows in error message.
I close this ticket, the problem has been solved that Google has updated design library to 28.0.0-rc02 .

Android Databinding build fail after Gradle plugin update with migration to annotationProcessor

To support Instant Run in my version of Android Studio, I needed to upgrade my Gradle plugin from version 2.2.3 to 2.3.3
I'm aware I'm supposed to migrate to annoationProcessor and I believe I've followed that guide correctly
after doing so, the Android DataBinding code generation fails
The migration guide linked earlier states that all I need is to
Make sure you are on the Android Gradle 2.2 plugin or newer
Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format
This should be all that's needed to successfully build the project. Yet it doesn't build.
Build output
Gradle build finished with 101 error(s) and 23 warning(s) in 12s 481ms
All of the errors follow the same pattern:
C:\Users...\FooAdapter.java
error: package com.example.app.databinding does not exist
error: cannot find symbol class ItemFooBinding
An interesting message can be found in the build console:
Warning:The following options were not recognized by any processor: '[android.databinding.minApi, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir, android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.isTestVariant]'
I would like to point out that...
I presume I don't have an error in some XML file, binding expression or a naming issue. The same set of sources and XML build when I switch back to the Git branch with the old gradle plugin version (and all of the other source files up-to-date)
I did increase the limit of output build errors as discussed here, although this doesn't seem to be relevant right now, since as you can see, I currently have "only" 101 errors. :)
Additional info
The following diffs show how I've modified my gradle files:
build.gradle DiffChecker link
app/build.gradle DiffChecker link
Also, as a quick overview, here is the list of some of the "more interesting" plugins & libraries used by the project:
Kotlin
Android DataBinding
Realm
Retrofit
Dagger
ButterKnife (I know...)
Multidex Support Library
Does anyone have a clue what could be the issue? Any help or idea will be greatly apprecitated!
I had exactly the same warning. This line in gradle solved the issue:
kapt "com.android.databinding:compiler:3.0.1"
Hopefully, it will help somebody
Update:
3.0.1 is Android Plugin Version.
When you see innumerable build errors mentioning databinding as in this case, the problem usually lies somewhere else. Databinding just gets stopped in its tracks by unrelated build problems and complains exceedingly loudly. The only way to deal with it is to locate the build errors that are not tied to databinding. Once they are fixed, databinding can do its thing again and be silent. Unfortunately you often have to repeat this approach several times until you have found all non-databinding issues. It's an arduous task for sure, but unfortunately there is nothing else you can do until Google manages to provide a saner build environment.
This is the reason why you are advised to increase the build error limit beyond 100 - you would not see the actual errors causing your problems, because they commonly do not show up early in the list.
I will chance a guess - Dagger 2 is a common source of triggering this problem, which could be related to your annotationProcessor change; so look out for Dagger errors. But your issues could be caused by other things, like other annotation processors as you mentioned - you wouldn't know for sure until you diligently dig through your build errors.
It seems it all comes down to my project using Kotlin. Actually we have it mixed: some classes use plain old Java while others are written in Kotlin. An incomplete migration. :)
I assume that without Kotlin, replacing apt with annotationProcessor would be enough and I wouldn't have ran into this issue at all.
Solution
Annotations need to be processed by both annotationProcessor and kapt, which seems to be Kotlin's own annotation processor.
For each Gradle dependency that uses annotations, you should have both of the following in your app-level build.gradle:
annotationProcessor 'com.example.my.library:x.y.z
kapt 'com.example.my.library:x.y.z

Categories

Resources