Last night, I upgrade my android studio from 3.0.1 to 3.1, and rebuild my project, and I got the error as show below.
CHECKED LIST:
compileSdkVersion 27
buildToolsVersion '27.0.3'
classpath 'com.android.tools.build:gradle:3.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
As mentioned in this question:
Close project.
Remove it from the projects list (left side in the default Android Studio window).
Open existing project -> choose the project folder.
Basically, close & re-open the project.. worked for me (after even invalidating cache didn't work).
Related issues from issuetracker: 77211616, 77938563, 73536373
Even though my first answer works, it's actually a hassle because the issue keeps on reoccurring, especially after I switch branches (for different development or code reviews). So, I read further and found this answer:
Switch your support lib version - either to a newer ver (27.1.1 stable as of now), or to an older version & back to current.
It's an alternative and seems to work.
Related issues from issuetracker: 77211616, 77938563, 73536373
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
My app, which was working before, suddenly started crashing in my LaunchActivity with: Please configure your build for VectorDrawableCompat. This is happening with Gradle 7.0.2, which doesn't make sense since other posts regarding this issue are from 3 years ago and recommend updating to gradle 2.0+ (which is much older) and also using the latest android support library (which is a non-issue now with androidx). They also recommend setting vectorDrawables.useSupportLibrary = true which has already been the case in my app. So those posts weren't relevant to my issue.
minSdkVersion 21
targetSdkVersion 31
vectorDrawables.useSupportLibrary = true
classpath 'com.android.tools.build:gradle:7.0.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
Oddly this started happening on my master after I switched to a different branch and then returned to my master branch after a month. However, the master branch shouldn't have changed at all and it must have been working before, because I cut a production release from it that previous month, and the production release wasn't crashing.
Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at androidx.appcompat.widget.ResourceManagerInternal.checkVectorDrawableSetup(ResourceManagerInternal.java:495)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:140)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:480)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:93)
at androidx.appcompat.app.AppCompatDelegateImpl.attachToWindow(AppCompatDelegateImpl.java:797)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureWindow(AppCompatDelegateImpl.java:773)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreate(AppCompatDelegateImpl.java:501)
at androidx.appcompat.app.AppCompatActivity$2.onContextAvailable(AppCompatActivity.java:131)
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:297)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:273)
at com.somewearlabs.sw.ui.LaunchActivity.onCreate(LaunchActivity.kt:14)
at android.app.Activity.performCreate(Activity.java:7963)
at android.app.Activity.performCreate(Activity.java:7952)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
I finally fixed the issue. When I was inspecting the crash in Android Studio, clicking on the file/line number link (eg. "ResourceManagerInternal.java:495") opened up two options for the class, one in appcompat library version 1.2.0 and also 1.3.0. There must have been two versions used in my dependencies, even though in the build.gradle files for all of my projects explicitly stated androidx.appcompat:appcompat:1.2.0. Using a breakpoint showed that the line in 1.3.0 was getting called when launching the app.
Then I did File > Invalidate Caches and Restart.
I thought that ensuring that only one version of appcompat being used in the project might fix things, so I switched all the build.gradle files from using androidx.appcompat:appcompat 1.2.0 to 1.3.0. After resyncing/building, the crash went away. I don't know why this crash started happening in the first place - if anyone could shed some light on this - but I needed to update the appcompat dependency anyway so it worked out.
I am getting the error: "Ambiguous method call" on initializing Toolbar using Android Studio 3.0 RC1. I have extended my Activity with AppCompatActivity and compiling my application using 'compileSdkVersion 26'.
Attaching a screenshot of the error.
If you recently updated your project to API, Try doing
File -> Invalidate Caches / Restart
then
File -> Sync Project with Gradle Files
this resolve for me.
Upgrade to appcompat 27 solved this for me
For me, it was the compileSdkVersion which was different than the support libraries used
You have
import android.support.v7.app.AppCompatActivity
import android.app.Activity
both in your code.
Remove import android.app.Activity as I can see, it's not required for you.
For me changing build tool version to 27.0.2 worked, given that all your other dependencies are API 27 as well.
buildToolsVersion '27.0.2'
I have recently upgraded to build tools version 27.0.2 and faced the same problem. But noticed that I had the compileSdk version set to 25. Changing compileSdk to 27 resolved the issue.
"File - Invalidate Caches / Restart" Solved my problem.
For me none of the given solutions worked, however I had this issue because I had both 25 and 27 android sdk installed on my computer. As soon as I removed the sdk 25, the problem disappeared.
This can suddenly appear when running a code analyzer like FindBugs-IDEA. A quick way to clear the warning is to temporarily change the buildToolsVersion in your app/build.gradle then change it back again.
For example, follow these steps:
Open your app/build.gradle file.
Change buildToolsVersion to '26.0.1' then sync project (press the 'Sync Now' button when it appears at the top)
Change the buildToolsVersion back to whatever you had before.
Press the 'Sync Now' button
This should clear the error.
Maybe you have difference between compileSdkVersion and targetSdkVersion
I ran into the same issue with Android Studio 3.0.0 build 171.4408382. Building via Gradle on the command line worked just fine, but the IDE presented me with the above mentioned error. I have tried to use API level 26 with appcompat v26.1.0 and API level 27 with appcompat v27.0.1, but neither combination worked.
My "solution" was to downgrade compileSdkVersion and targetSdkVersion to API level 25 and the appcompat library to version 25.4.0.
For all of the mentioned version combinations I used Gradle plugin v3.0.0 and the Android build tool v27.0.1.
In my case, I removed the constraint layout dependency in the build.gradle (app) file and it solved the issue.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.1.0'
//implementation 'com.android.support.constraint:constraint-layout:2.0.4'
}
if answers does not resolve your problem , you can reset your android studio.
I solved with reset my android studio.
For reset: https://stackoverflow.com/a/19397632/3129822
First make sure that you have no transitive dependencies that are using older support libraries. Run the following command and make sure that no older support libraries are in use.
gradlew :app:dependencies
Make sure that your gradle file is updated with latest dependencies. eg: compileSdkVersion 27, targetSdkVersion 27, buildToolsVersion 27.0.3. etc. It would also benefit to make sure that non of your app flavors have been using a custom targetSdkVersion.
Ctrl + click on the findViewById method. It will show you the 2(perhaps more?) conflicting methods. In my case the conflict was between the findViewById method from API 23 and API 27. Therefore I had to remove the SDK and sources for Android version 23. Once I removed it and did Invalidate Caches/Restart it solved my problem.
My compileSDK version was lower than the targetSDK version so all I had to do was match them and sync project and the error was resolved.
Removing "Android Fast Networking" library solved my problem
I've had the same issue
Mine was related to the compileSdkVersion number from build.gradle app.
Changed to the latest and it worked for me.
Upgrading your targetSdkVersion or buildToolsVersion might resolve the problem.
No need to Invalidate Caches / Restart if this is a new project.
I was working with a new project and in gradle files did not have version numbers set in them, there was "N" across minsdkversion and targetsdkversion, changing to desired sdk version solved the problem
Upgrading both appcompat to 27 and compleSdkVersion to 30 works for me.Just upgrade those in gradle build.
Just upgrade your minSdkVersion 26 Its works for me.
When we create a Android project with minimum SDK lower than 16 and after that we want to add new activity using 'New/Activity/Gallery' we see the indication 'Selected activity templates has minimum SDK level of 16'. So we need to modify 'minSdkVersion' in build.gradle file which leads us to 'Sync Now' process.
If we must build and maintain an app with min SDK lower then 16, we have to change 'constraint layout' to another layout. However when we do this the constraint layout dependency still remains in the dependencies section in the 'build.gradle' file. This caused me the error.
In summary, this is applicable when we need to build a android project with minimum SDK version lower than 16.
When we add a new activity, we change the minSdkVersion in the build.gradle above '16' then click of 'Sync Now'. After that we can choose one of activity template and create a new activity.
Now we change 'constraint layout' in the xml file corresponds to the new activity we created to for example 'linear layout' or 'relative layout'
At this point we make sure delete the dependency which refers to constraint layout in the 'build.gradle' and then click the 'Sync Now' again.
I think the best practice to avoid this error message is to make Android project with minimum SDK 16 and above.
These steps worked for me on Android Studio for Mac (Arctic Fox v11):
In 'build.gradle' file (for module), change appcompat implementation version to something invalid (e.g. Change 'com.android.support:appcompat-v7:25.1.0' to 'com.android.support:appcompat-v7:25')
Click 'Gradle sync now' and let it finish. This should generate lots of errors
Correct the verison back to original (e.g. 'com.android.support:appcompat-v7:25.1.0'). Click 'Gradle sync now' and let it finish
Original issue with findViewId should disappear
I just started learning android coding and I keep getting this error:
Add these support library in build.gradle and also make sure the version of the support library(goto sdk manager and get the version number of sdk platform and place it in below dependancy because version of support library and sdk platform should be matched)
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
Try any of the following
Click refresh button on the preview pane
Sync Project with Gradle files
Click Tools > Android > Sync Project with Gradle Files
Rebuild Project
Click Build > Rebuild Project
This seems to come up periodically with Android Studio and it happened again today on an install I haven't used in a while. There may be more than one solution, but as of today June 08, 2016, I made sure two things are set:
1) Make sure you're on SDK/API 23 (or lower if necessary) vs the N preview, and
2) change the theme to "App theme". You may have to choose "Manifest Theme" in the left column before you can see "App Theme" show up as an option in the right column.
3) hit the refresh button (looks like two arrows in a circle)
Referring to a post above, both the support.appCompat and support.design libraries should be automatically added as dependencies to the gradle file, but you can double check them if necessary (and get the newest ones if the versions have changed).
You should see both of these:
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
Why Google and Jet Brains can't keep this from happening I don't know, but as of today, it cleared the problem right away.
I'm using Android Studio 0.2.3 and when opened an activity layout normally, the preview should appear on the right side, so that I can switch between Text and Design mode, which should again show the preview of the layout.
But no preview is shown not on the right side neither when I'm in text mode nor in the design mode. I just get the error rendering problems...
When I compile everything and install the app on my device, it works without any errors. For developing and experimenting with the layout, it would still be nice if I could get the preview to work.
I have also tried to switch between different devices in the studio, but no success.
Does anyone know how solve this?
Change your android version on your designer preview into your current version depend on your Manifest. rendering problem caused your designer preview used higher API level than your current android API level.
Adjust with your current API Level. If the API level isn't in the list, you'll need to install it via the SDK Manager.
In new update android studio 2.2 facing rendering issue then follow this steps.
I fixed it - in styles.xml file I changed
"Theme.AppCompat.Light.DarkActionBar"
to
"Base.Theme.AppCompat.Light.DarkActionBar"
It's some kind of hack I came across a long time ago to solve similar rendering problems in previous Android Studio versions.
Open AndroidManifest.xml
Change:android:theme="#style/AppTheme"to something like:android:theme="#style/Theme.AppCompat.Light"
Hit "refresh" button in the "Previev" tab.
I was able to fix this in Android Studio 0.2.0 by changing API from API 18: Android 4.3 to API 17: Android 4.2.2
This is under the Android icon menu in the top right of the design window.
This was a solution from http://www.hankcs.com/program/mobiledev/idea-this-version-of-the-rendering-library-is-more-recent-than-your-version-of-intellij-idea-please-update-intellij-idea.html.This required a Google translation into English since it was in another language.
Hope it helps.
In the Latest Android Studio 3.1.3, Dependency:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
or
Even in latest by 27th of Aug 18 ie
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
facing similar issue
Change it to
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1
This will solve your problem of Preview.
UPDATE
Still, in beta01 there is a preview problem for latest appcompact v7 library
make the above change as changing it to alpha01 for solving rendering problem
When I set that android:autofillHints="" /> in .xml file, I met the issue, Android Studio rendering problems, so I set that android:autofillHints="testHint" />, this issue is gone.
I have solved the Problem by changing style.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
this was an awesom solution.
it still happens in Android Studio 1.5.1. on Ubuntu and you can solve it simply changing a setting from Gradle:
1) on app/build.gradle dependencies change from:
compile 'com.android.support:design:23.2.0'
to:
compile 'com.android.support:design:23.1.0'
2) rebuild project
3) refresh view
Best regards,
/Angel
I had the same problem, current update, but rendering failed because I need to update.
Try changing the update version you are on. The default is Stable, but there are 3 more options, Canary being the newest and potentially least stable. I chose to check for updates from the Dev Channel, which is a little more stable than Canary build. It fixed the problem and seems to work fine.
To change the version, Check for Updates, then click the Updates link on the popup that says you already have the latest version.
In build.gradle below dependencies add:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.+"
}
}
}
}
This worked for me, I found it on stack, addressed as the "Theme Error solution":
Theme Error - how to fix?
Rendering didn't work for me too. I had <null> value on the right side of the android icon. I ran
sudo apt-get install gradle
I restarted Android studio then and <null> value changed to 23.
Voila, it renders now! :)
Just download minimum prefered SDK from SDK Manager, then build. Works for me.
Make sure your designer version and targetSdkVersion both is same.
Example : If your targetSdkVersion is 22 then change your designer version also 22, so this problem do not occur.
Best Solution is go to
File -> Sync Project With Gradle Files
I hope this helped
All you had to do is go to styles.xml file and replace your parent theme from
Theme.AppCompat.Light.DarkActionBar
to
Base.Theme.AppCompat.Light.DarkActionBar
Open your activity_main.xml .
Switch to Design view if you are in text view.
Look for the android version,with the android robo icon.
Change the android version.
Problem solved.
this issue is probably derived from the connection of the laptop to software products like AnyConnect. Killing the remote connection works for me.