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.
Related
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
I am using androidx.core.app.NotificationChannel and androidx.core.app.NotificationChannelCompat to resovle the android compatible problem according to (Androidx API reference)[https://developer.android.google.cn/reference/androidx/core/app/NotificationChannelCompat].
But even I add implementation "androidx.core:core:1.3.1 in my build.gradle file, Android Studio prompts me can not resovle symbole NotificationChannelCompat.
Why? I do not want use SDK version conditional statements to fill my source code.
It'll resolve NotificationChannelCompat if you change:
implementation "androidx.core:core:1.3.2"
to
implementation "androidx.core:core:1.5.0-alpha04"
Latest versions: https://developer.android.com/jetpack/androidx/releases/core
Here is the commit, it was missing :-) https://android-review.googlesource.com/c/platform/frameworks/support/+/1360061
I have following gradle dependencies in my Android build.gradle file.
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
Declared versions are the current latest stable versions of these libraries(android support library). But Android Studio displays following warning on them.
A newer version of exists than 23.2.1 is available:
24.0.0-alpha1
24.0.0-alpha1 seems to be the newly released developer preview and I don't want to take them as a stable version of libraries. I can suppress or disable this inspection and get rid of the warnings. But doing so will avoid valid future warnings as well.
How can git rid of this warning for the developer previews?. The warning should appear only if valid new stable version of the library exists.
I use Android studio 1.5.1Thanks in advance
Guys from Google has already fixed it, so all that you need to do now is to wait for the next update.
This problem has already been reported here:
https://code.google.com/p/android/issues/detail?id=203321
Today I install Android Studio in my new Pc, I tried to start a new project but I couldn´t because I have this error when I try to compile some new library of Material Design as CardView or RecyclerView, I was reading about this problem and I tried to do everything, I installed all SDK, I change the library versions a lot times, but I cant resolve this =(.
This is the picture of my error:
Please, any help will be greatfully. I can´t program if I dont resolve this.
Import with compile 'com.android.support:recyclerview-v7:22.2.1' , this should work with API 22.
Click on Sync now in the warning on top of the code window.
If it doesn't work, try Build -> Rebuild Project. Seems that your gradle file doesn't refresh automatically
If it doesn't work check in the SDK Manager that you have install all the SDK pachages needed for those libraries and rebuild again.
Add card view lib from Open module settings-> app -> dependencies-> + -> Library dependency. It will be perfect . this happens you have updated version 22 installed in your sdk and not the previous version 21 .
or use
compile 'com.android.support:cardview-v7:22.2.1'
just use
compile 'com.android.support:recyclerview-v7:22.2.1'
as the popup says the library you try to import doesn't work with android version 22
and to make sure you don't import outdated libraries like this import them that way.
1-
2-
3-
Gradle project sync failed.
After update the android SDK I got this error:
Error:Failed to find: com.google.android.gms:play-services:5.2.8
I have checked that the sdk location which is updated is used by Android Studio
I've got Google Repository installed and Android Support Repository too all up to date.
Also I have a ANDROID_HOME local variable pointing to the sdk I'm actually using
try using com.google.android.gms:play-services:5.2.08 instead of 5.2.8.
you can also look for the right version number in your services directory:
.. /android-studio/sdk/extras/google/m2repository/com/google/android/gms/play-services/
Check your sdk extras packages, you need to install:
Google Play services
Google Repository
For me, the thing was that I didn't have the second one installed and then "---:5+" worked
as described here:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start
You can now use
compile 'com.google.android.gms:play-services:6.1.11'
I use
compile 'com.google.android.gms:play-services:6.1.+'
Even though it warns against it. If things go flakey after an update I'll revert back to the current version.
I had the same problem. I solved using:
compile 'com.google.android.gms:play-services:7.0.0'
Suggesting using Open File> Project Structure, click the "add (+)",
searching for "play-service" to select the currently available version.
Something like this image:
http://i.stack.imgur.com/9Pv7j.jpg