Since today, Android Studio can't find the AppCompat themes in styles.xml, but for example AppCompatActivity in code does get recognized. My Android Studio version is 2.2.2, Build #AI-145.3360264
I already tried upgrading to the latest build tools, compile sdk (25) version etc. but it didn't fix the problem.
At the moment I have installed the following (from sdk manager):
android api: 19 and 23
sdk platform tools: 25.0.1
sdk tools: 25.2.3
build-tools: 23.0.2 and 25.0.1
support repository: 40
google repository: 39
and a few others, that shouldn't be necessary to list here.
build.gradle of app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.1'
defaultConfig {
applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/RootTools.jar')
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:support-v13:23.+'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.android.support:cardview-v7:23.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'de.hdodenhof:circleimageview:2.1.0'
}
Another solution that worked for me with Android Studio 3.1.2:
delete these from build.gradle if you have them:
'com.android.support:appcompat-v7:27.1.1'
'com.android.support:design:27.1.1'
then sync,
then undo delete,
then sync again.
I encountered this after updating to Android Studio 3.1.
None of the other answers listed here worked for me, however when I switched my appcompat support lib version to the latest 28.0.0-alpha1 then back to 27.1.0 that it was on before, it worked.
Seems the new version of Android Studio lost connection to where the library was synced to and just needed to have it reset.
No need to change anything.
Just press small button on top "Sync Project with Gradle Files"
EDIT: As #Alexey noted, bug still appears in Android Studio v3.1.4
This worked for me:
Click File > Close Project
Reopen the project from Studio's dialog.
That's because of feature called "build cache" that is enabled by default in build Android Plugin since 2.3.0.
It creates files in build cache outside of project folder (in my case -- in \Users\%username%\.android\build-cache)
Theese files are intended to be common between your projects.
And then Android Studio is unable to navigate in theese files.
That's all.
If you want to disable Build Cache, add android.enableBuildCache=false to gradle.properties file. Then restart Android Studio.
more info here:
https://developer.android.com/studio/build/build-cache.html#disable_build_cache
I have had the same problem. The only solution that worked for me was to manually delete the support libraries in file system and sync the project to let Android Studio download them again.
Steps:
Go to your project folder in File system
Go to .idea\libraries
Delete all the Gradle__com_android_support_****.xml files
Open Android Studio
Select File > Sync with File System
Once that is done, Select File > Sync Project with Gradle Files
Build Project
And now your error should be gone!!!
you can hit file -> invalidate Caches / Restart ... if it doesn't fix the issue you can close the project (file-> close project) and import it (file -> new -> import project.
I switched support lib to version 27.1.1 and problem has been solved. Seems like some bug in 27.1.0
I went through the same problem when I upgraded to alpha-2.
I looked at this link: http://tools.android.com/recent, but the only thing that worked well was:
Change this:
Classpath 'com.android.tools.build:gradle:2.3.0-alpha2'
For this:
Classpath 'com.android.tools.build:gradle:2.2.3'
In your build.gradle (Project)
Only this worked for me
Close project (File> Close Project)
Import / Re-Open project again (NOT from Recent)
Error should be resolved now.
If that fails, try below-
Open build.gradle, remove appcompact-v7 dependency and sync project.
Add appcompact-v7 dependency and sync.
I encountered same problem like this.Just the difference is I was using Studio 2.2.3. This is what solved my problem:
In my project level gradle I had:
classpath 'com.android.tools.build:gradle:2.3.0-alpha2' (which was a result of updating studio)
which I replaced with:
classpath 'com.android.tools.build:gradle:2.2.3'
I think you should look for a compatible classpath for your gradle configuration.
I was having the same issue after linking Firebase to my app. Updating the build.gradle in the app module did the trick, updated to:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.8.0'
I had also the same problem when I upgraded my android studio from 2.2.2 to 2.3 Canary Version.
Although the new beta version of 2.3 is released yet it is using the gradle plugin of 2.2.3 which is of stable version.
So just change the classpath dependency in buildscript of build.gradle project level from alpha to 2.2.3 and sync it. It'll resolve the issue or change to the more appropriate version with respect to your channel version.
More on gradle watch this Gradle Recipes for android Ken Kousen - Gradle Summit 2016
https://www.youtube.com/watch?v=4L6wHTVmxGA
In newer versions of Android Studio, we are asked to use 'AppCompat'. Some users uncheck that and still use the Theme.AppCompat. That makes up this error. Same happened with me.
Solution is to add this line in your build.gradle (app).
compile 'com.android.support:appcompat-v7:26.1.0'
#Daniel Wilson made a comment in one of the answers that solved this issue for me. I wanted to add add as an answer to draw more attention to this solution.
Updating compileSdkVersion and targetSdkVersion from 26 to 27 (and then of course updating the dependencies) eliminated the errors for me.
Mine was fixed by deleting the .gradle file from the folder and re-importing the project in Android Studio
I also faced the problem with Android Studio 3.1 , syncing does not help me.
Then I switched back to
`'com.android.support:design:27.1.0'` from : `'com.android.support:design:27.1.1'`
and added android.enableBuildCache=false to gradle.properties to disable build cache
This is weird, I encounter this problem as below:
Android Studio is 3.1.2
support lib version is 27.0.0
I solve this by below:
change support lib version to 27.1.0, and "Sync Project with Gradle Files", then this error disappear
change support lib version to 27.0.0,and "Sync Project with Gradle Files", then this error not appear again
Deleted .idea and .gradle from project folder.
Then sync with gradle files, it worked.
I ran into the same problem when updating the Android Studio software.
What I did was this:
Go to the Gradle Settings as follows (this path is for Mac, but should be similar on Windows):
Android Studio -> Preferences -> Build, Execution, Deployment ->
Gradle.
Then pick "Use default gradle wrapper (recommended)".
If you already have that option chosen then your problem must lie somewhere else.
I changed my gradle version from
classpath 'com.android.tools.build:gradle:2.3.0'
to
classpath 'com.android.tools.build:gradle:2.2.3'
and it works now!
In Android Studio 3.1.3, the simple work around:
"Sync Project with Gradle Files"
If none of these methods mentioned by other contributors does not work for you..
Then please simply ignore this...
Even flutter officials also said to ignore these errors..
Caution*** Only ignore after trying all the methods.If above methods solve your errors then fine otherwise you can ignore these..
This type of errors happen after installing latest version of flutter sdk,gradle ,android studio and other plugins -packages
If you are using latest version then you have to ignore these errors.
I am facing a issue after run existing android studio project. Please check error below and let me know how to resolve that.
Error:(54) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
Thanks in advance
Try to use accroding gradle plugin. I've got the problem with plugin 2.3-beta1 and Studio 2.2.3, when changed to plugin 2.2.3 - everything worked like a charm
Please change compileSdkVersion and buildToolsVersion in your gradle file according to your android studio existing running project.
Our compile SDK version must match the support library's major
version.
If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK.
Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.
You can either change it manually in your build.gradle, or you can use
the GUI by opening up the project properties and going to the
"dependencies" tab.
Or Press Ctrl + Shift + Alt + S to get to the project structure page. Go to the properties tab and change version to 23.0.0 or whatever latest in the build tool area and rebuild your project.
If that doesn't work, go to gradle:app and then
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
Edit version as shown above and sync gradle.
Ran into same issue as OP, March 2017 Android Studio 2.3.
My build was working fine for months, and this issue came up right after adding a new line to gradle build file. Ultimately making some changes in Gradle and re-sync'ing fixed the issue, but my Gradle ended up being exactly the same as when the issue first came up, strangely.
My original Gradle build dependencies:
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:gridlayout-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.google.android.gms:play-services-location:10.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.4'
Then, I simply added a new line:
compile 'org.scribe:scribe:1.3.5'
This is when the issue appeared, same as OP.
I saw red errors in my styles.xml and wondered "wtf?".
Cleaning and re-building had no affect.
Going back to the Gradle build file, I commented-out that new line. ISSUE RESOLVED! So obviously there was something going on.
For fun, I put that line, uncommented, at the top of this compile list. NO ISSUE!
For fun yet again, I put that line back again to the bottom of the list (like how originally added it). NO ISSUE.... weird!
How Gradle sync'ing responds doesn't seem to be 100% consistent. I did no other changes to my project. All I can say is try toggling and re-ordering things in the compile list.
After upgrading from the last Android Studio 2.0 preview to Preview 5 I'm having trouble with the imports from the android.support.wearable package.
Both the main app and Wear app builds and run just fine, but the editor in Android Studio complains that it can't resolve the these imports
import android.support.wearable.activity.WearableActivity;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
In the Wear module's build.gradle I have the following dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.google.android.support:wearable:1.3.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
}
As I understand from http://developer.android.com/training/wearables/apps/always-on.html#EnableAmbient this should work when using the provided statement. And it has worked well until the Android Studio upgrade. Am I missing something?
Update:
This isn't just a problem with the Wear library, it's general for what seems to be any external dependency. (Topic originally was Unable to resolve package android.support.wearable in Android Studio 2.0 Preview 5.)
It seems like the problem can occur at any time, but in practice it happens mostly whenever I do lotsa changes in a class (maybe changes to the imports?). Just now it suddenly was unable to resolve the imports of Play Services and Facebook ads (while still working for other dependencies).
I accidentally found a workaround of the problem: If I open and build the project in Android Studio 1.5 which I also have installed, all the imports are fixed. Going back to Android Studio 2.0 I can continue programming without the imports becoming unresolvable for a long while.
For anyone googling the problem, the error message in Android Studio is the usual Cannot resolve symbol '[package]'.
I had this problem even before with AS 1.5, the easiest way for me to fix it was to use the Terminal inside Android Studio and execute:
./gradlew assembleDebug
This will work if you're not using flavors if not just use the name of the flavor, for e.g:
./gradlew assembleFlavorNameDebug
that should work too as a workaround without leaving your current instance of AS, and then the compiler recognizes your imports if everything is setup properly.
For more references please look: http://tools.android.com/build/gradleplugin
https://stackoverflow.com/a/21307568/799162
So before I say anything, I am a total noob to android, but I am way to curious to figure out how to run this open source application that was built for a hackathon. ( https://github.com/android-fanatic/CosmosBrowserAndroid )
They dont have an APK, so I couldn't try it, but I really want to try it out. But every time I try to import the application into android studios, I get this message:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:
The project 'CosmosBrowserAndroid-master' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
And thus, I can't try the application out. Could anyone give me a step by step solution?
Unzip the github project to a folder. Open Android Studio. Go to File->Import Project. Then choose the specific project you want to import and then click Next->Finish. It will build the Gradle automatically and'll be ready for you to use.
P.S: In some versions of Android Studio a certain error occurs-
error:package android.support.v4.app does not exist.
To fix it go to Gradle Scripts->build.gradle(Module:app) and the add the dependecies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Then start an emulator and run your app
For more information:
https://developer.android.com/tools/building/building-studio.html
I'm a newbie to Android Studio IDE. I used to implement Android application, using Eclipse IDE. As a beginner in Android Studio, I tried this lesson from YouTube to include a external jar file to my project and use it. But unfortunately I'm unable to use that library even though the Gradle or Android build doesn't throw any error/exception when compile and run.
I've seen related questions from SO too. As an example, I've tried out things that discuss in this question.
In the build.gradle file, I used
compile files('libs/jsoup-1.7.3.jar')
and next time used
compile fileTree(dir: 'libs', include: '*.jar')
Neither work for me. After editing that build.gradle file, I used Sync Project With Gradle Files tools and also command line clean
gradlew clean
too. No error/exceptions, but when I try to write Docu... in my MainActivity class it doesn't show the import option org.jsoup.nodes, but show other imports options. What could be the mistake I've done.
There were some bug in 0.4.2 related to dependencies management, do upgrade your studio to 0.4.3 will solve your problem .