I am learning flutter, and while playing around with flutter's Geolocator 3.0.0 package. I came across an issue that wouldn't let me compile the app as soon as I add the reference to this package in pubspec.yaml file. A quick google search showed me the right github issue. The fix mentioned in the github issue (migrating app to support AndroidX - by updating compileSdkVersion in build.gradle file to 28, and adding android.useAndroidX=true and android.enableJetifier=true in gradle.properties) does work.
Main question: I am not sure if this (migrating project to support AndroidX) will need to be done for all flutter projects explicitly or is there a way to ensure all new flutter projects support AndroidX.
PS:I come from C# background, and I know nearly nothing about android / iOS app development.
You need to explicitly migrate a Flutter app to Android X by using Migrate to AndroidX... button located under Refactor tab of Android Studio. Manual migration is not recommended. If a plugin requires Android X, you need to perform this migration.
For the related article on Flutter.io, see: https://flutter.io/docs/development/packages-and-plugins/androidx-compatibility
Re your main question:
' I am not sure if this (migrating project to support AndroidX) will need to be done for all flutter explicitly or is there a way to ensure all new flutter projects support AndroidX'
I have never found the 'Refactor/Migrate to AndroidX' to work. Not even on new projects. I'm not sure it does anything at all. I always had to do manually even after just creating a new project. I follow the manual instructions but also delete any old versions of gradle in c:/....gradle/wrapper/dists/gradle-???. The current one, and only one to have available is gradle-5.1.1-all.
Related
My gradle build completes successfully, but I get:
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.5.31` that
might work differently than in the requested version `1.6.10`.
All of my build.gradle.kts scripts refer to using version 1.5.31. The only association my project has with version 1.6.10 is that Android Studio has the Kotlin version 1.6.10 plugin added. If I try to disable that plugin, I get a message that several other plugins will be disabled. If I accept that, android studio crashes and will not start up again. It won't start up again even if you reinstall android studio again. The solution is to find the file named "disabled-plugins.txt" and delete that file. It's in your AppData folder and in a JetBrains subdirectory. It turns out that it's one or more of those other disabled plugins that prevents Android Studio from starting up again.
The question I have is how do I fix this version mismatch issue. I can't delete the plugin from Android Studio for the reasons I mentioned above. If I try to update my project to using version 1.6.10 I get literally 100's of unresolved dependencies. And it seems from opinionated investigation that 1.6.10 still have too many issues for general use.
By the way, when I look at the gradle window for the project I can see where the dependencies come from. Usually when I look at the gradle window I just see sub project folders that I can drill into for more information, but for this project, it has an additional folder name dependencies. I don't know how they get into my project. But when I look at their version numbers that's where the 1.6.10 mismatch happens.
So, I think I understand why the warning message is valid, I'm at a lost on what I need to do to correct this situation. For the moment, I'm just ignoring the warning, and so far I'm not finding any issues in proceeding that way. But that's means I'm proceeding, without an understanding of what's going on here! Sometimes that's okay and at other times that's a bad judgment The error message itself seems inverted. I would think that 1.6.10 is the embedded kotlin and kotlin-dsl since it an android studio plugin, but the error message seems to say it in the opposite way. So anyway, if someone can bring some clarity as to what's going on, and how I'm thinking wrongly about this problem would be greatly appreciated.
I'll accept the following as the answer to what's going on about the unsupported kotlin version:
https://github.com/gradle/gradle/issues/13020
So, for the moment, I'll go on like this is just a nuisance warning and ignore that.
What I just did was to re-create my Android Studio from a blank brand new project. I copied and pasted stuff from the previous project into the new project. I copied the source and build.script.kts files, so essentially everything is a copy of the disabandoned project. This new project didn't give me the WARNING message anymore. And in additional, I'm now able to upgrade my project to using kotlin 1.6.10, which I previously couldn't do because of the literally 100's of dependencies resolution issues. Whatever, that issue went away, and a lot of others things started working as expected once I recreated the project. I can't say what got my project into that weird state. Deleting the .gradle and .idea folders, wouldn't fix the problem. I didn't try deleting the JetBrains cache, I wish I would have tried that.
I created flutter project before androidx releasing. App always give warning message Your app isn't using AndroidX, but i migrated app to androidx with applying all steps. I tried every method, but does not work. I opened android part of flutter project in android studio and then migrate androidx, i added android.useAndroidX=true
android.enableJetifier=true line,changed targetsdversion to 28, gradle versions. But when i run flutter project, this warning appear on console.I guess everything okey, but warning does not disappear. I am waiting your helps.
I would give you a workaround if thats all is not working. Umm Okay Create a new flutter project with AndroidX enabled in android studio and then copy libs , assets , modify pubspecs , and all correct the imports. Change Manifest if you did.
I'm new to Android, Was learning from youtube from following playlist
https://www.youtube.com/watch?v=d1T0ptCAs8A&list=PLraJmOvF9eeGyVClKdBaVU6O_XqQjNboS&index=5
In 4th video it was teaching to add Firebase, but it was old method as I got some new option on Firebase(Firebase was saying It needs only classpath 'com.google.gms:google-services:4.2.0')
suddenly after adding this line in build.graddel in project I saw that my previously working code have some errors
I tried Invalidate cashes and restart, cleaned projects and rebuild.
It seems you are mixing support library and androidx
either use androidx(recommended) or support library
follow https://developer.android.com/jetpack/androidx/migrate guide and after this make sure to make appropriate changes in layout xml files also.
Remove the dependencies with androidx starting. Because androidx is a different library than support library. You should only include one of them.
Why does Google have this note? [ref]
What is the harm in adding reference to the library in the SDK directory? I have done it and my app worked just fine.
I think maybe it could will change name in some sdk updates, so if you referece to your copy nothing can go wrong.
instead reference it on gradle to avoid this problem (Gradle work for us to avoid dependecy problem :)).
Yes, you can use it directly from there. I used to do it too till i realized what the problem could be.
If you are making no changes to the library it should work fine. But if you plan to add some build files or configuration etc you should copy it to the project. (I had some for my ant builds) If you dont have any, at the time of updating the library from SDK manager you lose everything you changed or configured. Apparently it deletes all unidentified or manually added stuff when updating the library.
With Android studio it is much simpler and you just add a dependency with required version to your build.gradle file.
This error appears when creating a new Android Application module in Android Studio using Fixed Tabs + Swipes for navigation.
It says:
The following dependencies were not resolvable. See your build.gradle
file for details. - com.android.support:appcompat-v7:18.0.0
I'm targeting Android 4.0+ devices. Why is the compatibility library involved? One workaround is to install this library using the Android SDK manager, but I'm concerned my app will actually use this compatibility library when there is no reason to. The ActionBar and fixed tab navigation should be built-in to the Android 4.0+ framework right?
This happened to me with IntelliJ Idea 13 Ultimate when creating new Gradle Module. I was working on the app that supports Froyo. I had to manually add support libraries to the SDK. After that I was able to build just fine. Here is the screenshot of Project Structure settings for SDK that I have:
As you can see, support for v4, v7 and v13 which were added manually. Those will be associated with Android API 19 Platform (in my case). When you create next new Gradle Module, you will still need to go to Project Structure to select the SDK under Project, but you will not need to add support libs again. Hope this helps.
I installed the compatibility library anyways. Something I didn't realize is that you can't create your first module by using File -> New Module. You have to use File -> Project Structure -> New Module for your first module. It's really unintuitive. After I did this, then everything worked.