RxSearchView not supporting androidx SearchView? - android

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.

Related

Android Mapbox Search-UI: Duplicated class MapboxCommonLogger

I added the mapbox-search-ui dependency to my app/build.gradle following the instruchtis here: https://docs.mapbox.com/android/search/guides/search/
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0"
implementation "com.mapbox.navigation:android:2.7.0"
implementation "com.mapbox.search:mapbox-search-android-ui:1.0.0-beta.38"
The build then fails with "Duplicated class found"
Duplicate class com.mapbox.common.MapboxCommonLogger found in modules jetified-base-10.7.0-runtime (com.mapbox.maps:base:10.7.0) and jetified-common-23.1.0-rc.1-runtime (com.mapbox.common:common:23.1.0-rc.1)
Build is fine without the mapbox-search-android-ui package.
I tried to determine and exclude the faulty package but without success.
Any suggestions warmly welcome
EDIT
The issue also happens when i just want to add the core search library:
implementation "com.mapbox.search:mapbox-search-android:1.0.0-beta.38"
So i assume that the issue is caused by using the "old" mapbox sdk version 9.5.0. When i switch to the current 10.9.0 version i don't get the duplicate classes error. But then i would need to migrate my whole code to 10.9.0 which means a lot of effort...
EDIT 2
As of an answer to a corresponding issue i openend on their guthub page the devs told me that the search SDK currently not works with Mapbox v9, but they maybe consider to add backward compatibility.
see https://github.com/mapbox/mapbox-search-android/issues/93

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 :/

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 .

there is something wrong with my appcompat version

I don't really understand why my appcompat version is not accepted
Please help
click to see image
This is a warning, your app will still run.
One or more of your transitive dependencies is requesting different version of of the Android Support Library that you are not requesting directly yourself, resulting in this conflict. You will need to run a Gradle dependency report and find out what is causing the problem, then manually request those artifacts yourself with your desired version (presently, 27.0.1).
I think in your case facebook is using old version, you should try updating facebook dependency version to latest.
You can see this answer as well.
You have probabelly some libraries that use older versions of some others support libraries (not especially AppCompat), so you have to override them manually in the gradle to get rid of this warning.
You have to repeat this until the warning disapear :
When you see the hint, copy and past the library and update the version number : for example if in the hint you have
"blablabla... example include blablabla...
com.android.support:support-core-ui:26.0.1"
Add this to the dependencies section of the build.gradle script :
implementation 'com.android.support:support-core-ui:27.1.1'

Warning:Using incompatible plugins for the annotation processing: android-apt

I have seen this post dotted around on the site, but the answer always appears to be the same "Remove apply plugin android-apt" but i have never and will never (because it's deprecated) use android-apt in my project? I've not included it anywhere nor applied it as a plugin in any files.
Is it possible for third party libs to add it to my gradle build file during the build process? How can i prevent this? It's causing things like ButterKnife to fail when using the new annotationProcessor
OK, i found my own answer! It turns out the issue was my realm plugin was too old, and internally still used android-apt (Realm.io) upgrading that to the latest version (3.0.0 at time of writing) resolved the issue immediately.

Categories

Resources