hello i want to use androidx library but it's not showing for me and i tried Refactor->Migrate to androidx and it didn't work too
can i get help please..
https://i.stack.imgur.com/xHNJ9.png
Make sure all those dependencies are added to your project. Then still face your problem go to the android studio file->invalid caches and restart.
https://i.stack.imgur.com/cXzGu.png
I want to use androidx library but it's not showing for me and I tried Refactor->Migrate to androidx and it didn't work too
Looking at below picture: https://i.stack.imgur.com/cXzGu.png
You can't use androidx for TextInputEditText because that widget is a property of Google material design. That means, the intellisense autocomplete dialog is showing you the exact and correct code. Check here and see the artifact mapping list of android support library to androidx or android jetpack
But before then, according to this post it reads:
With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting
Refactor > Migrate to AndroidX from the menu bar.
The refactor command makes use of two flags. By default, both of them are set to true in your gradle.properties file:
android.useAndroidX=true
The above ☝️ will allow Android plugin to make use of the appropriate AndroidX library instead of Android Support Library.
android.enableJetifier=true
The above ☝️ Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries.
In conclusion, if above lines of codes are not in your gradle.properties file then you can add them and sync gradle
Note: The built-in Android Studio migration might not handle everything. Depending on your build configuration you may need to update your build scripts and Proguard mappings manually. For example, if you maintain your dependency configuration in a separate build file, use the mapping files mentioned below to review and update your dependencies to the corresponding AndroidX packages.
Related
As the title mentions, I am using buildSrc and Kotlin for Gradle Dependency management in a modularized android project as per the following tutorial:
https://caster.io/lessons/gradle-dependency-management-using-kotlin-and-buildsrc-for-buildgradle-autocomplete-in-android-studio
it's working all fine but the question is how can I be notified if there are any libraries that have an update on their version? (i am not getting the notification on the library where it gets marked showing that there is an update)
is there another way of doing this?
There are a few approaches you can take here:
Leave out the dependencies in build.gradle. Currently, there is no hint shown in Android Studio if you extract out them into variables. So you can just use strings here.
Use Gradle-versions-plugin to check for dependency updates. You can read more about this here.
I'm trying to use Coordinator Layout in my xml file and found that it's corresponding libraries doesn't exists.
So i tried to include this in my gradle build file
implementation 'com.android.support:design:28.0.0'
but it's giving the error
Supplied String module notation 'androidx.' is invalid. Example notations: > 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
Then i found all support libraries is deprecated and one need to use androidx library.
How to include this library in my gradle file ?
***My main intention is to use Coordinator Layout in my UI
Click on "Refactor" on the android studio menu bar.
Select "Migrate to Androidx..."
Job Done.
You are correct in saying that the support libraries have been deprecated. The new standard is AndroidX. Here is a link that shows the current mappings from the old support libraries to AndroidX.
Specifically for CoordinatorLayout, it has gone from com.android.support:coordinatorlayout to androidx.coordinatorlayout:coordinatorlayout
Furthermore, I suggest reading this page about migrating to AndroidX. It offers a lot of information and will make your transition to AndroidX much smoother.
I have Android App that uses support library versions 27.1.2. I want to consume a library written using Android X (api 28).
There are few issues with name spacing of the library versions.
Example ...
The library has a Dialog that I want to use with the api
Dialog.show(androidx.fragment.app.FragmentActivity activity);
However all my activities are using
android.support.v4.app.FragmentActivity
and the compiler does not like this.
Currently it is not an option to upgrade my project to latest version, so please no upgrade answers, unless this is the only solution.
Is there a way to resolve this incompatibility issue?
Thanks in advance.
This is not possible. To use any library that depends on AndroidX, your project must migrate your whole project to AndroidX.
Note that the reverse is supported - you can use libraries built with Support Library in projects that use AndroidX (that's the purpose of the android.enableJetifier=true flag).
AndroidX[About]
Consumer support -> Producer androidX - not compatible.
You should migrate your consumer to use AndroidX. Android Studio menu -> Refactor -> Migrate to AndroidX...
Consumer androidX -> Producer support - compatible.
Consumer's gradle.properties in addition to use androidX should enable Jetifier[About] which converts support to androidX
android.useAndroidX=true
android.enableJetifier=true
[Mix AndroidX and support in a multi-module project]
There is a way
Jetifier tool migrates support-library-dependent libraries to rely on the equivalent AndroidX packages instead. But when you put -r flag, it makes him to the exactly reverse process.
From developer.android.com
If you pass the -r flag, the utility runs in reverse mode. In this
mode, the utility converts AndroidX APIs to the support library
equivalents, instead of the other way around. Reverse mode is useful,
for example, if you are developing libraries that use AndroidX APIs,
but also need to distribute versions that use the support library.
Anyway, I will suggest to use it only in a very critical needs.
I have a question regrading RxJava2 support in WhorlWind.
I am converting a project which uses Whorlwind from Rx1 -> Rx2. My current Whorlwind version in my root project gradle is 1.0.1, which according to their github CHANGELOG.MD is the only version.
https://github.com/square/whorlwind/commit/769ad313154df46ce07638dc79bd46ae14e5fbfb
As you can see, the commit above has made the changes to support rxjava2 however I am not able to find a version number to update in my gradle. There must be some key concept I'm missing because how I understand it, the Whorlwind library on my machine will remain at the RxJava1 build until I update the gradle to bring in some new Whorlwind library.
Thanks
I ran into the same issue with that library, what I did to move forward was to use the library the same way that the sample app that they have uses it. By adding the library to your project and referencing the library from there.
See their build.gradle here:
https://github.com/square/whorlwind/blob/master/whorlwind-sample/build.gradle
https://github.com/square/whorlwind/commit/47961437c611abc4ec88c900cdb6621ef6662b1c
In the gradle.properties, Square lists a snapshot of a newer version that supports Rx2. I'm not sure why they don't list it in the ChangeLog or ReadMe
When I once built some simple project, Eclipse automatically generated appcompat_v7 library project in my workspace and include it in dependency list for my original project. Meanwhile, I downloaded new support library (via SDK manager) few times. Then I tried to built again the same project, but this time in dependency section, I manually removed appcompat_v7 and added project generated by successful built of Android-SDK\extras\android\support\v7\appcompat library project. This time I faced few build errors in original project, most of them being unable to find resources that match name "TextAppearance.AppCompat. ..." as parent style of some style tag in res\values\styles.xml (of original project). What am I missing ?
Eclipse handles appcompat with many problems. You always must:
Have a copy of appcompat library loaded into your workspace to import it in your project as library
Use the same support library version in your project and in the appcompat library. If you update the support library, update it manually in the appcompat and your project. Right button click over appcompat/project, Android Tools -> Add Support Library.
If you have style compile problems with appcompat library, use compileSdkVersion = 23, targetSdkVersion = 22
Finally, I will recommend to migrate to Android Studio too, much easier and much cleaner.
Later, I made a copy of Android-SDK\extras\android\support\v7\appcompat library project into my workspace (check box when making "new Android project form existing code") and original project compiles well. I considered as better practice not to copy appcompat, but rather to work through reference to it. That way I would have valid link to new version, when I upgrade support library over time. However it appeared as better move to make a copy.