Navigation editor failed to initialize - android

Suddenly, Android Studio started to prompt that to use the Navigation of Android Jetpack is necessary to install a module android.arch.navigation:navigation-fragment:+.. That is the whole module name.
Two problems. One, I already have it installed, version 1.0.0alpha-06 and second, if I attempt to install it will simply say it could not install.
The main issue here is that five minutes before this happened I DID use the visual editor of this, but it suddenly went like this.
I've already tried to clean the cache, invalidate and restart, but it decided to remain like this. Ideas?

If you are using kotlin then add -ktx for kotlin support
implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06"
Consider this dependency too:
implementation "android.arch.navigation:navigation-ui:1.0.0-alpha06"
Another thing: consider using support library with version 27.1.1 or use the 28.0.0

Related

Android Studio (Dolphin | 2021.3.1) & (Electric Eel | 2022.1.1) does not show layout preview

I'm using Android Studio Dolphin | 2021.3.1 & Electric Eel | 2022.1.1
After updating Android studio chipmunk | 2021.2.1 to Android studio Dolphin | 2021.3.1 my all project design preview and layout preview not showing.
If anyone solved this issue please help me.
I have tried all possible ways but didn't find any solution for this.
Below are points that I have tried
Invalidate caches.
Restart IDE.
Repair IDE.
Update Gradle plugin version to 7.3.0 from setting project structure (No working)
Check the Below screenshot so everyone gets an idea of what I have issue faced.
Thanks in advance.
For me, some layouts are working fine but in some layouts, I am getting the below error which used to work in earlier versions of Android Studio.
The same issue I faced in Android (Electric Eel | 2022.1.1). Still, this Issue continues.
I was able to fix this by changing the preview's theme from App.Starting [default] to my app's theme from the Design Tab
After alot of searching and testing, I upgraded my gradle version and its work for me.
Just goto File -> Project Structure or press Ctrl + Alt + Shift + S and then upgrate the gradle version as shown in the image below and then invalidate cache and restart the Android Studio and its working
As shown in the image I upgrade my gradle.
Apparently, there are many people reporting the exact same issue to Google but no concrete solution has been given so far:
Issues with Layout Preview in AS since Dolphin
Layout rendering inside AS stops on most of layout after upgrade to 2021.3.1 RC 1 (worked on Chipmunk)
NPE in AarResourceRepositoryCache.createCachingData (AS Dolphin+)
Dolphin continuously refuses to show Design Layouts
Layout editor preview almost always broken
Layout previews have stopped working
I tried most of the suggestions from the other answers, but the only thing that has worked for me so far was upgrading to Flamingo (2022.2.1 Canary 10) or downgrading to Chipmunk (2021.2.1 Patch 2).
These solutions are obviously far from ideal, but until Google decides to fix this in either Dolphin or Electric Eel, I believe that's what we're stuck with.
In my case, I found two situations.
1. Include
the android studio can't show the XML if it contains the "include" tag.
My project has more than 100+ XML files that have the include, and none of them can show the preview. Otherwise, it was fine.
Setting the app theme doesn't work for this case.
2. Setting app theme
On top of the preview screen, you can select the app theme. (If you can't find it, try enlarging the android window itself. Then the hidden app theme menu will be revealed.)
Then, try setting some theme, such as "AppTheme" or "BaseTheme", etc. Then, for some cases, this will show you the preview.
I tried to update gradle but not work with me.
so after that i changed them from
Theme.MaterialComponents.DayNight.NoActionBar
to
Theme.Material3.DayNight.NoActionBar
work with me
if this solution does not work with you
add this line to root group view in layout
android:theme="#style/Theme.MaterialComponents.Light.DarkActionBar.Bridge"
another solution
down material version to this version
material_version = '1.6.1'
I hope that helps you.
I have same issue as above just solved by doing below things
Setting - SDK tools and check for Android Emulator Update
just Update it and Rebuild project and Done
No need to downgrade API versions.
Note - if not work after it just try to invalidate cach and restart
Option 2
after doing above task try to just update or select app theme from above preview design
To solve temporary this issue. Change theme for preview using "AppTheme". This is work for me. For detail see the attachment file image
Use material:1.8.0-alpha01 dependency. alpha02 has issue showing preview.
New solution:
I just tried the latest canary build of Android Studio Flamingo and it seems that the layout preview is now fixed! At least it works for me again without any problems, with MDC 1.8.0-alpha03 and the latest gradle plugin and gradle version.
Old solution:
It appears to be a bug in Dolphin in connection with API 33, but for me at least the layout preview toolbar is shown. In case the preview toolbar is somehow accessible, the following workaround solves the disappeared preview (at least for me):
Select API 32 in the layout toolbar instead of the preselected API 33.
Then the preview is shown to me as it should and I do not have to downgrade anything and can use the latest gradle version.
Change the AGP Version and Increase Gradle version if you have not in Project structure > Project to latest version the click apply and wait for gradle to complete. After completing, Just Invalidate Cache and restart. It worked for me.
Starting with Android Studio Chipmunk, if you're seeing java.lang.NoSuchFieldError: view_tree_saved_state_registry_owner or java.lang.ClassNotFoundException: androidx.savedstate.R$id in the issues panel, make sure to include a debugImplementation dependency to androidx.lifecycle:lifecycle-viewmodel-savedstate in your module.
If you're seeing java.lang.NoSuchFieldError: view_tree_lifecycle_owner in the issues panel, make sure to include a debugImplementation dependency to androidx.lifecycle:lifecycle-runtime in your module.
If you're seeing java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer or java.lang.NoClassDefFoundError: androidx/customview/poolingcontainer/PoolingContainerListener in the issues panel, make sure to include a debugImplementation dependency to androidx.customview:customview-poolingcontainer in your module.
Issue tracker : https://issuetracker.google.com/issues/247058594
Workaround Solution : File - Project Structure -
I have also encountered this issue. Switching Android Gradle Plugin to 7.3.0 for all projects and 7.4 for gradle solve this problem.
Try to remove/modify any drawable resource files that you are using as style/background in your layout. It may cause Render problem/Touch size/Touch Target too small. In my case I was using such resource files, after modifying those, the layout is visible to me. Thanks.
I had the same issue and solved it by ignoring some errors in the issue panel
Not this specific issue, this is for example sake
Don't use alpha version. Use this
implementation 'com.google.android.material:material:1.7.0'
In my case solve this issue I do following steps
First I just update Gradle plugin version to 7.3.0 from setting project structure (No working)
after that I also update com.google.gms:google-services version to 4.3.14
now every things work fine.
I was using custom views, styles and fonts from a library and ran into this when upgrading to Dolphin. I fixed the issue by upgrading the libraries compile SDK to 33. Upgraded gradle to 7.3 and upgraded androidx.appcompat:appcompat to 1.4+
Once you do that, invalidate caches and rebuild and it should work.
Google is aware of this issue https://issuetracker.google.com/issues?q=dolphin%20layout%20preview
Downgrading to Chipmunk until a patch is released will also fix the issue if you can't or wont upgrade.
Try to upgrade your gradle version to latest (whatever it may be). Mine Worked
If all these solutions are not working then you can try below option as well.
Disable lottieAnimation in the xml file, and reBuild the app, then it is working fine now.
For you that because of others dependencies cannot update the Android Gradle Plugin:
You'll have to wait a little bit, the devs are already aware. There should eventually be a version to correct this.
For now what you can do to keep working is downgrading the Android Studio Version to Chipmunk | 2021.2.1 (or older)
Maybe it's not going to fix your problem. But it may helps someone who gets into the same trouble as I had. I have an extended layout, the exception says it's not able to initial this class, and pointing to a singleton property variable.
private SingletonProperty property = SingletonProperty.getInstance();
Turns out it's not possible to have a singleton field in a layout class(which it's okay before Android Studio Dolphin). Everything works fine after I move it into several methods. Don't forget to build your project after this.
For me, disabling assertions fixed the issue.
I found the fix here: https://issuetracker.google.com/issues/255525863
To disable assertions, add -da to Custom VM Options:
In case that Android Studio won't start after applying the new options,
the custom VM options file is located at:
macOS:
~/Library/Application Support/Google/AndroidStudio2021.3/studio.vmoptions
I had the same problem if you are using custom views in your layout, checkout this answer https://stackoverflow.com/a/66337620/14599955.
Open Layout Validation tab from right side or search it from toolbar search menu
now see the issue in my case is inside MaterialAutoCompleteTextView
after investigating issue is
android:fontFamily="More Fonts..." font is not point to right one
I also had the problem of the layout page not appearing and it was not solved in any way until I made a copy of it and deleted the entire layout one by one to find out which view had the problem. It is interesting that the copy of the layout was intact and worked exactly.
Frankly guys tried everything as suggested in mentioned answers, but doesn't seems to work for me, might be a recent Android Studio bug.
Sharing something what worked for me (workaround, not a fix)
I accidentally clicked the LayoutValidation tab as mentioned in screenshot, and for now using it to preview my design while updating XML code. Preview gets updated as you make changes.
But yes this might not be helpful if want to make changes using design.
I'm on Android Studio Electric Eel and I managed to fix the issue after a whole day of trying by replacing com.google.android.material:material version 1.8.0 with 1.7.0.
Even though 1.8.0 is now 'stable' it was the one causing the issue.
Downgrade to Android Studio Chipmunk (2021.2.1) Patch 2
https://developer.android.com/studio/archive
It will work after that.
The only way that rendering of XML is going to work is by clearing out all the errors from the issue panels, which in your case from the photo are 4 errors. This worked for me

Unsupported kotlin version

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.

Does AndroidX need be supported explicitly

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.

Build fails in Android Studio after adding library

I've been using Android Studio 1.0.2 for a while now and have had no problems. I have a fairly simple app that uses Fragments. Originally I was using the built-in Fragment framework as my target devices will be 4.0.2 upwards. However, due to bugs in the Framework on earlier devices I decided to move to using the Fragment support library (why anyone would not use this over the built-in - well, that's another question...)
I added the library, com.android.support:support-v4:21.0.0, to my build.gradle, thus:
dependencies {
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.amazonaws:aws-android-sdk-core:2.1.5'
compile 'com.amazonaws:aws-android-sdk-s3:2.1.5'
compile 'com.android.support:appcompat-v7:21.0.3'
}
(I already had appcompat-v7 in the list).
All good so far. After converting the fragment manager calls and imports I did a build and got this:
Error:Execution failed for task
':app:prepareComAndroidSupportAppcompatV72103Library'. Failed to
create parent directory
'D:\current-projects\android_studio_projects\WallPaintings\app\build'
when creating directory
'D:\current-projects\android_studio_projects\WallPaintings\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3'
I performed a synchronise and then I did an Invalidate Cache and restart. I then performed another build and got the same result.
Then, after some reading on SO, I discovered you have to perform a "Synch Project with Gradle files". I did this and it worked - compiles up, builds the APK, etc. Fantastic.
However, from that point on, every time I do a Clean or a Rebuild I end up with the same error until I perform the gradle synch.
What is the problem? I can't see what I've done wrong. There is ample disk space and the directory where it attempts to create the things is read/write.
Or is this yet another piece of black-box magic / dark arts that one needs to learn in order to use Android Studio (come back Eclipse - all is forgiven!!)
Well, I restarted Studio numerous times and tried other possible solutions but nothing worked - it stubbornly kept getting the same error so I gave up and just went back to working on my app, resigned to having to do a Synch Gradle after a Clean.
Then yesterday it started no longer reporting the error on a clean.
Black magic.
I was never a great fan of Eclipse, but the more I use Android Studio the more I realise this isn't a 1.0 - it's still very much a Beta.
Closing this question as it has been "solved" - all by itself!

Android Studio (0.8.1) cant use go to declaration/implementation

I cant seem to use go to declaration or implementation for any classes and methods that are outside of either the current class/file. It will work for classes that are from the android library but nothing that I created or that I import from another library. This is taking a huge toll on productivity... Anyone run into this? Have a solution? Ideas for a fix?
Also highlighting seems to be an issue as well, this might be related. It seems lighter then it used to be, like Annotations are not being highlighted. Maybe its a parser issue?
If you are using gradle to build your application, then make sure gradle project sync is not failing. If gradle project sync fails, then basic IDE functionality may not work properly e.g. goto type declaration (ctrl+shift+b) and implementation (ctrl+alt+b or ctrl+click). Android studio also does a wonderful job of notifying you when something fails.

Categories

Resources