After Update android studio dolphin my old projects xml preview not showing views. Is anyone facing same issue? And have done solution then please share it here.
It's run perfectly fine but preview not working.
What I did tried?
File -> Invalidate Cashes / Restart
Delete build , idea , gradle folder
Restart PC and android studio
but none of that solved my problem.
In my case, I have upgraded the project AGP (Android Gradle Plugin) and then restart the android studio.
Problem Solved.
I'm suffering from same issue/bug. What I did so far?
Attempt 1
File -> Sync Project with gradle files
File -> Invalid catch and Restart.
Delete build folder idea and .gradle folder.
Restart Android studio and restarted my pc as well.
This will do solve in one of the my project which is only 5 screen project. But not solved in my other old projects which are more than 5 year old.
Attempt 2
Tried all step from attempt 1 Also tried what siregar2103 answered
File -> Repair IDE but still have same problem ,But Repair IDE did solve my other project issue/bug.
Attempt 3
All from Attempt 1 and 2 but not solve in my main project so I decided to upgrade my years old project to latest one.
I did upgrade my Gradle from 4.1.3 to 7.3.0
Update all dependency to latest one but I face many error while doing that.
Hilt error and other errors too. Which I'm going to mention below.
For Hilt I did removed all old Hilt related library and and below
kapt "com.google.dagger:dagger-compiler:2.42"
kapt "com.google.dagger:hilt-android-compiler:2.43.2"
implementation "com.google.dagger:dagger:2.42"
implementation "com.google.dagger:hilt-android:2.43.2"
implementation 'androidx.hilt:hilt-work:1.0.0'
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation "androidx.navigation:navigation-compose:2.5.1"
In build.gradle file (not .app level)
id 'com.google.dagger.hilt.android' version '2.43.2' apply false
Important note: I did add implementation "androidx.navigation:navigation-compose:2.5.1" dependency because I got
java.lang.IllegalArgumentException: CreationExtras must have a value
by SAVED_STATE_REGISTRY_OWNER_KEY error in runtime.
Other Error which I faced is
Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException:
lateinit property _buildFeatureValues has not been initialized
For this I did build gradle using command line and it give me full error which I didn't get when I directly build don't know why? But It's through error related flat dir and aar file so I did removed flat dir code and change aar file implementation code now It's started to build and my app started to install.
Now still some of my file not rendering and that because of I'm using custom attr from style so I'm trying to figuring out why it's happening and I'll update this answer when I find solution for that.
So using above my 60% xml files preview start showing in my old projects. For 40% screen I have to change my default theme to custom theme in preview of xml so it can start rendering.
Repair IDE
Upgrade your code to latest Android Gradle Plugin
This 2 step should solve your problem. And build using command line for more error related details.
Have you try to using Repair IDE? It works for me
I ran into a similar issue when upgrading to Dolphin. I was able to solve this by changing the preview's theme from App.Starting [default] to my app's theme.
Try to update the gradle and sync files. It work for me.
The XML file in your project may contain an error. The reason may be a font issue or a file not linking correctly with your XML layout.
This is for your reference on how to find errors.
Hope you find it useful.
Check what Layout Inspectors you have enabled in Android Studio and try to let only the API 29-30 inspector active.
In my case if in xml custom views have used that my preview screen not show views if I remove or comment custom views in xml layout after that the preview screen show other view perfectly
I know removing custom layouts not solution.
for 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.
In my case, I have upgraded Android Gradle Plugin when update is popUp and then restart the android studio.
My Problem Solved.
I am looking as well for a soluition till now.
From what i see, it has something to do with
AGP or Cardview (Layouts). Many code snipeets relate to this issue.
I am trying to update the AGP version, but it seems, that the enveronmet is more broken than that.
I get as well an empty Field for the gradle version and plugin under settings.
For anyone can not fix this issue, i'm just need to update gradle version and buildtool
buildSrc/src/main/kotlin/Dependencies.kt
object BuildPlugins {
object Versions {
const val buildToolVersion = "7.3.0" //lower version seem not work
and change to 7.4 in gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
Related
I have a problem: My android studio is analyzing infinitely:
I have tried:
uninstalling Android Studio
Invalidate cashes / Restart
restart my computer.
build.gradle (Project)
build.gradle (Module)
Main Activity (Analyzing text top right corner)
What can I do?
You just need to Upgrade the latest kotlin version.
Upgrade the dependency in the project's build.gradle file.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
Upgrade the dependency in the app's build.gradle file.
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
Finally, I fully deleted my android studio with all connected files using this answers and then reinstalled its new stable (the same 4.2.1. version). The problem was solved.
I was also facing the same issues.
I Follow below step:
Close Project
Delete all “.idea” & ".gradle” folder
Want to solve this problem, you need to download the kotlin plugin with the version 202-1.5.0-release-764-AS8194.7 at this website https://plugins.jetbrains.com/plugin/6954-kotlin/versions, then install it.
I am able to run the project successfully. but unable to resolve this issue which is showing "kotlin Not Configured". I tried every solution for that but its always showing in the currently active file.
Please help.
Delete the .gradle and .idea file and restart the project. This seem to work for me.
Click on Tools -> Kotlin -> Configure Kotlin in Project
then choose the configurator, any one from:
Java with Gradle
Android with Gradle
try to upgrade the kotlin version in build.gradle file
ext.kotlin_version = '1.3.72'
also in the build.gradle app module file make sure implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
in the dependencies section ,
if you see at any time update the gradle option , do so
Furthermore, if you find a line
implementation "androidx.core:core-ktx:+"
in your build.gradle, you may see the warning message:
Avoid using + in version numbers, can lead to unpredictable and anrepeatable builds.
Click on "Replace with specific version", then the current installed version replaces the "+". (For example, "1.3.2")
In my case the "kotlin not configured" message and a lot of "errors" in the kotlin file disappeared.
Simply hitting "Sync Project with Gradle Files" did the job for me.
In my case, it can fix by keep the version of kotlin-gradle-plugin up to date. Check the version here: https://kotlinlang.org/docs/gradle.html#plugin-and-versions
File for configuration Location
Project -> build.gradle
//example: update this dependence:
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
}
I faced the same issue after updating to latest android electric eel. So those of you who had a kotlin project which working fine and after update failed to sync gradle files or build projects with error
"Kotlin not configured".
I think this answer might help. I'm not sure if this is the right way to do but this was a life saver for me since I was working with an old project with older dependencies and kotlin version
Just click on the gradle offline toggle and try syncing the project and building it in offline mode. That's it !!!
No need to change any version or other changes. I hope this helps and save your time.
Cannot resolve symbol 'androidx.constraintlayout.widget.ConstraintLayout'
I made an empty activity in Android Studio, ahead of nothing added, in activity_main.xml, there were so many red lines,and the prompt was: Cannot resolve symbol'
while, these code was generated by Android Studio, I tried file->invalidate cashes/restart... and installed all the SDK tools but Google series. The error was still there.
Gradle was successful, and JDK was installed.
Has anyone a solution ?
Make sure constraint layout is updated to latest version:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
This is because your project support android legacy version, check this out in build.gradle, search for this key:
implementation 'com.android.support:appcompat-v7:28.0.0'
If confirmed, you should use the compatible version instead of the androidx version.
That is android.support.constraint.ConstraintLayout.
BTW, are you trying to follow the https://developer.android.com/guide demo? This tutorial sucks.
I am currently in the process of developing an Instant app, for which I have restructured my monolithic app into feature modules.
Everything was up and running till Android Studio canary 3, but after an update to Android Studio Canary 4 my project fails to build with the following error:
A problem was found with the configuration of task ':minimoBase:dataBindingExportBuildInfoDebugAndroidTest'.
> Directory '/Users/nayak.vishal/projectData/minimo_instant_app_project/putica-client-android-
native/minimoBase/build/intermediates/data-binding-info/androidTest/debug'
specified for property 'xmlOutFolder' does not exist.
The following procedure worked as a workaround for this issue:
Execute the following build commands on the gradle command line
1) gradlew clean
2) gradlew :appModule:assembleDebug
here appModule is the name of the app module for building the installable apk
the build is successful and the debug apk generated in the output folder can be installed successfully
3) gradlew :instantAppModule:assembleDebug
here instantAppModule is the name of the instant app module
the build is successful and the instant app apks can be installed and launched via deep link
Once the above command line builds are successful, building via Android Studio Canary 4 also stops throwing the build error.
I got similar error when I turn on data-binding for library module. When I turn it off and move all classes that require data-binding to app module, it works. So I guess there is a problem that DataBinding doesn't work on Library module any more ( Gradle 2.x fine with this).
dataBinding {
enabled = false
}
I am using com.android.tools.build:gradle:3.0.0-alpha5 and Android Studio 3.0 Preview Canary5
UPDATE
Although the original answer worked, I really want to turn on data-binding on my library module, where I implement some base classes using binding technique. I move them back to library module and upgrade kotlin version to the latest one 1.1.3-2. Suddenly it works also. I am not sure which one is the better but both ways work for me.
UPDATE 2
I am using com.android.tools.build:gradle:3.0.0-alpha9 and kotlin 1.1.3-2 at this time and suddenly the problem re-appear.
Now I think the problem doesn't come from Kotlin. My library module turned dataBiding { enabled=true}, but it doesn't have any layout file. I tried to create a fake layout file wrapped by <layout> tag and it works
<?xml version="1.0" encoding="utf-8"?>
<layout>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</layout>
In your gradle.properties file , add the following line
android.enableAapt2=false
Recent versions of AS3.0 switched to using AAPT2 by default.
You can disable AAPT2 in your gradle.propertіes fіle with above mentioned line of code, and continue developing on AS3 canary 4.
This was an issue for me when I had a "base" feature module without any layouts (all my actual layouts are in separate features)
Adding a dummy layout XML file in the base feature (e.g. as base/src/res/layout/dummy.xml) meant the missing directory was created and the app compiled.
(this is using com.android.tools.build:gradle:3.0.0-alpha6)
I've had the same problem, seems like a bug in Canary 4.
For now, as a workaround, I downgraded to Android Studio 3.0.0 Canary 3 (This is an archive of all Android Studio releases) and also downgraded the Android Gradle plugin to 3.0.0-alpha3:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
...
}
Updated:
Just check the Canary version after update. For that see Android Studio version just above the toolbar (File..Edit..View..line) where name at end like "Canary X".-> X is number like 3,4,5,etc.
For example suppose updated version(X) is 5.
Try to change that classpath in build.gradle(applicationName) to 3.0.0-alpha5 and sync(/Try) again:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
}
Means that updated version(X):-
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alphaX'
}
I'm working With Android Studio 8.9
I've got a build.gradle with the following dependency defined:
compile ('my.program.commons:my-program-commons:0.0.2-SNAPSHOT#jar')
This dependency is stored in a private Sonatype nexus repository.
When I make changes in the my.program.commons code, I upload to nexus.
The problem is that when I then try to compile against the new SNAPSHOT android studio will fail to pick up changes.
When run from the command line gradle will build succesfully - but Android Studio will not recognize the new files.
If i do a version tick - say from 0.0.2-SNAPSHOT to 0.0.3-SNAPSHOT Android Studio will understand the new version and download and everything works out fine.
I don't want to have to do a minor version tick on every single change.
In my case, use changing = true not work for me. But configure cache changing modules solve my problem. Sample code below, add in build.gradle file:
configurations.all {
// Don't cache changing modules at all.
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
See: https://docs.gradle.org/current/userguide/dependency_management.html
You can also put a flag called "changing" that will trigger Gradle to always pull the latest, for example:
compile ('my.program.commons:my-program-commons:0.0.2-SNAPSHOT#jar') {
changing = true;
}
You need to configure the cache duration, by default gradle won't look for updates for 24 hours:
http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:controlling_caching
In my case, removing the whole <project_root>/.idea/libraries directory, was the only solution that worked. AndroidStudio stores some cached dependencies configurations there. Removing the directory makes it refetch all of them one more time.
You can write some script/task that will automate this removal and run it as part of the Gradle clean task.