Error : Ambiguous method call. Both findViewById (int) in AppCompactActivity and Activity - android

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

Related

"The specified Android SDK Build Tools version (26.0.0) is ignored..."

In Android Studio 3, I'm seeing this issue:
The specified Android SDK Build Tools version (26.0.0) is ignored, as
it is below the minimum supported version (26.0.2) for Android Gradle
Plugin 3.0.0.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.0'" from
your build.gradle file, as each version of the Android Gradle Plugin
now has a default version of the build tools.
The problem is that because these are third-party/vendor modules that have buildToolsVersion '26.0.0', I can't modify their build.gradle without forking each submodule.
Is there a way to set a global buildToolsVersion that will override all the sub build.gradles?
Here if you are referring to my previous answers Here is an Update.
1. Compile would be removed from the dependencies after 2018.
a new version build Gradle is available.
Use the above-noted stuff it will help you to resolve the errors. It is needed for the developers who are working after March 2018. Also, maven update might be needed. All above answers will not work on the Android Studio 3.1. Hence Above code block is needed to be changed if you are using 3.1. See also I replaced compile by implementation.
Open app/build.gradle file
Change buildToolsVersion to buildToolsVersion "26.0.2"
change compile 'com.android.support:appcompat to compile 'com.android.support:appcompat-v7:26.0.2'
Solution to this problem is simple
Go to build.gradle (module.app) file
It will help us to rebuild gradle for the project, to make it sync again.
Update to Android Studio 3.0.1 which treats these as warnings.
Android 3.0 was treating such warnings as errors and hence causing the gradle sync operation to fail.
Set the buildToolsVersion '26.0.2' then change classpath 'com.android.tools.build:gradle:3.0.1'.
Make sure you set compileSdkVersion to 26 whiles targetSdkVersion is also set 26.
It is also appropriate to sent set compile 'com.android.support:appcompat-v7:26.0.2'.
just clean and make project / rebuilt fixed my issue give a try :-)
invalidate cache in android studio will resolve this issue. Go to file-> click on invalidate cache/restart option.
Many times as API's are updated. We forgot to update SDK Managers. For accessing recent API's one should always have highest API Level updated if possible should also have other regularly used lower level APIs to accommodate backward compatibility.
Go to build.gradle (module.app) file
change compileSdkVersion
buildToolsVersion
targetSdkVersion, all should have the highest level of API.

Android Studio Error when building apk file [duplicate]

When trying to build OpenStreetMapView from git://github.com/osmdroid/osmdroid, I get this error:
failed to find target with hash string android-23: D:\Users\myusername\AppData\Local\Android
How can I fix this? Previous questions similar to this suggest checking that android 23 is not installed, but in my case, it is.
Below is some pertinent info:
ANDROID_HOME is D:\Users\myusername\AppData\Local\Android\sdk
D:\Users\myusername\AppData\Local\Android\sdk\platforms\ contains the directory \android-23\, (as well as android-19, android-21, android-22, android-MNC)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.osmdroid.example"
minSdkVersion 8
targetSdkVersion 23
versionCode 16
versionName "4.4-SNAPSHOT"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'android.support:compatibility-v4:23+'
compile project(':osmdroid-android')
//compile 'org.osmdroid:osmdroid-third-party:4.4-SNAPSHOT'
}
I tried changing targetSdkVersion and compileSdkVersion to 22. This causes the error message to change to "android-22" instead of "android-23".
SDK Manager:
In my case, clearing caché didn't work.
On SDK Manager, be sure to check the box on "show package descriptions"; then you should also select the "Google APIs" for the version you are willing to install.
Install it and then you should be ok
In Android Studio File -> Invalidate Caches/Restart solved the issue for me.
The answer to this question.
Gradle gets stupid from time to time and wiping out the cache is the only solution that I've found. You'll find a hidden .gradle folder under your user home folder and another one wherever the checkout location is for osmdroid.
I fixed the issue for me by opening the Android SDK Manager and installing the build tools for all 23.x.x versions.
See the screenshot.
Update: Does not apply to the Android Studio released after this answer (April 2016)
Note: I think this might be a bug in Android Studio.
Go to Project Structure
Select App Module
Under the first tab "Properties" change the Compile SDK Version to API XX from Google API xx (e.g. API 23 instead of Google API 23)
Press OK
Wait for the completion of on going process, in my case I did not get an error at this point.
Now revert Compiled Sdk Version back to Google API xx.
If this not work, then:
With Google API (Google API xx instead of API xx), lower the build tool version (e.g. Google API 23 and build tool version 23.0.1)
Press Ok and wait for completion of on going process
Revert back your build tool version to what it was before you changed
Press Ok
Wait for the completion of process.
Done!
Following these reccomended directions seemed to work:
Hint: Open the SDK manager by running: /path/to/android/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
There are 2 solutions to this issue:
1) Download the relevant Android SDK via Tools -> Android -> SDK Manager -> SDK Tools (ensure you have 'Show Package Details') checked. Your case would be Android 6.0 (Marshmallow / API level 21)
2) Alternatively, open your build.gradle file and update the following attributes :
compileSdkVersion
buildToolsVersion
targetSdkVersion
either to the most recent version of the Android API that you have installed / another installed version you'd like to use (although I'd always recommend going with the latest version for the usual reasons: bug fixes etc.)
If you're following step 2 it's also important that you remember to update the Android support library version if your app is using it. This can be found in the dependencies section of your build file and looks something like this:
compile 'com.android.support:appcompat-v7:27.0.2'
(replace 27.0.2 with the most recent support library version for the API level you intend to use with your app)
Had the same issue with another number, this worked for me:
Click the error message at top "Gradle project sync failed" where the text says ´Open message view´
In the "Message Gradle Sync" window on the bottom left corner, click the provided solution "Install missing ... "
Repeat 1 and 2 if necessary
23:08 Gradle sync failed: Failed to find target with hash string 'android-26' in: C:\Users\vik\AppData\Local\Android\Sdk
Android SDK providing a solution in the bottom left corner
For me the problem was in that I wrote compileSdkVersion '23' instead of 23. The quotes were the problem.
It worked for me by changing compileSdkVersion to 24 and targetSdkVersion to 24 and change compile to com.android.support:appcompat-v7:24.1.0
This poblem is solved for me after Run as administrator the Andorid Studio
Open the Android SDK Manager and Update with latest.
Nothing worked for me. I changed SDK path to new SDK location and reinstalled SDK.Its working perfectly.
Tools > Android > SDK Manager.
I had this issue when using windows. It turned out that the SDK location in my profiles was the issue. So I had to relocate my SDK folder to documents and then it worked.
Mine was complaining about 26. I looked in my folders and found a folder for 27, but not 26. So I modified my build.gradle file, replacing 26 with 27. compileSdkVersion, targetSdkVersion, and implementation (changed those numbers to v:7:27.02). That changed my error message. Then I added buildToolsVersion "27.0.3" to the android bracket section right under compileSdkVersion.
Now the make project button works with 0 messages.
Next up, how to actually select a module in my configuration so I can run this.
Download the specific Android release from the link specified in the build console.
The problem is caused because the code you are running was created in an older API level, And your present SDK Manager doesn't support running them.
So do try the following;
1.Install the SDK Manager that support API level 23.
Go to >SDK Manager, >Android SDK , then select API 23 and install.
2.second alternative is to update your build.grade app module to change
compileSdkVersion,compile,and other numbers to your currently supported API level.
Note:please ensure to check the API and Revision numbers and change them exactly. otherwise Your project won't synchronize
Ensure the IDE recognizes that you have the package. It didn't on mine even after downloading 28, so I uninstalled then reinstalled it after realizing it wasn't showing up under File-Project Structure-Modules-App as a choice for SDK.
On top of that, you may want to change your build path to match.
Slightly related, the latest updates seem able to compile when I forced an update all the way to 28 for CompileSDK, and not just up to the new API 26 min requirement from Google Play. This is related to dependencies though, and might not affect yours
AndroidSDK > SDK platforms > and install API Level 23

Cannot resolve symbol 'Theme' in styles.xml (Android Studio)

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.

failed to find target with hash string android-23

When trying to build OpenStreetMapView from git://github.com/osmdroid/osmdroid, I get this error:
failed to find target with hash string android-23: D:\Users\myusername\AppData\Local\Android
How can I fix this? Previous questions similar to this suggest checking that android 23 is not installed, but in my case, it is.
Below is some pertinent info:
ANDROID_HOME is D:\Users\myusername\AppData\Local\Android\sdk
D:\Users\myusername\AppData\Local\Android\sdk\platforms\ contains the directory \android-23\, (as well as android-19, android-21, android-22, android-MNC)
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.osmdroid.example"
minSdkVersion 8
targetSdkVersion 23
versionCode 16
versionName "4.4-SNAPSHOT"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'android.support:compatibility-v4:23+'
compile project(':osmdroid-android')
//compile 'org.osmdroid:osmdroid-third-party:4.4-SNAPSHOT'
}
I tried changing targetSdkVersion and compileSdkVersion to 22. This causes the error message to change to "android-22" instead of "android-23".
SDK Manager:
In my case, clearing caché didn't work.
On SDK Manager, be sure to check the box on "show package descriptions"; then you should also select the "Google APIs" for the version you are willing to install.
Install it and then you should be ok
In Android Studio File -> Invalidate Caches/Restart solved the issue for me.
The answer to this question.
Gradle gets stupid from time to time and wiping out the cache is the only solution that I've found. You'll find a hidden .gradle folder under your user home folder and another one wherever the checkout location is for osmdroid.
I fixed the issue for me by opening the Android SDK Manager and installing the build tools for all 23.x.x versions.
See the screenshot.
Update: Does not apply to the Android Studio released after this answer (April 2016)
Note: I think this might be a bug in Android Studio.
Go to Project Structure
Select App Module
Under the first tab "Properties" change the Compile SDK Version to API XX from Google API xx (e.g. API 23 instead of Google API 23)
Press OK
Wait for the completion of on going process, in my case I did not get an error at this point.
Now revert Compiled Sdk Version back to Google API xx.
If this not work, then:
With Google API (Google API xx instead of API xx), lower the build tool version (e.g. Google API 23 and build tool version 23.0.1)
Press Ok and wait for completion of on going process
Revert back your build tool version to what it was before you changed
Press Ok
Wait for the completion of process.
Done!
Following these reccomended directions seemed to work:
Hint: Open the SDK manager by running: /path/to/android/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
There are 2 solutions to this issue:
1) Download the relevant Android SDK via Tools -> Android -> SDK Manager -> SDK Tools (ensure you have 'Show Package Details') checked. Your case would be Android 6.0 (Marshmallow / API level 21)
2) Alternatively, open your build.gradle file and update the following attributes :
compileSdkVersion
buildToolsVersion
targetSdkVersion
either to the most recent version of the Android API that you have installed / another installed version you'd like to use (although I'd always recommend going with the latest version for the usual reasons: bug fixes etc.)
If you're following step 2 it's also important that you remember to update the Android support library version if your app is using it. This can be found in the dependencies section of your build file and looks something like this:
compile 'com.android.support:appcompat-v7:27.0.2'
(replace 27.0.2 with the most recent support library version for the API level you intend to use with your app)
Had the same issue with another number, this worked for me:
Click the error message at top "Gradle project sync failed" where the text says ´Open message view´
In the "Message Gradle Sync" window on the bottom left corner, click the provided solution "Install missing ... "
Repeat 1 and 2 if necessary
23:08 Gradle sync failed: Failed to find target with hash string 'android-26' in: C:\Users\vik\AppData\Local\Android\Sdk
Android SDK providing a solution in the bottom left corner
For me the problem was in that I wrote compileSdkVersion '23' instead of 23. The quotes were the problem.
It worked for me by changing compileSdkVersion to 24 and targetSdkVersion to 24 and change compile to com.android.support:appcompat-v7:24.1.0
This poblem is solved for me after Run as administrator the Andorid Studio
Open the Android SDK Manager and Update with latest.
Nothing worked for me. I changed SDK path to new SDK location and reinstalled SDK.Its working perfectly.
Tools > Android > SDK Manager.
I had this issue when using windows. It turned out that the SDK location in my profiles was the issue. So I had to relocate my SDK folder to documents and then it worked.
Mine was complaining about 26. I looked in my folders and found a folder for 27, but not 26. So I modified my build.gradle file, replacing 26 with 27. compileSdkVersion, targetSdkVersion, and implementation (changed those numbers to v:7:27.02). That changed my error message. Then I added buildToolsVersion "27.0.3" to the android bracket section right under compileSdkVersion.
Now the make project button works with 0 messages.
Next up, how to actually select a module in my configuration so I can run this.
Download the specific Android release from the link specified in the build console.
The problem is caused because the code you are running was created in an older API level, And your present SDK Manager doesn't support running them.
So do try the following;
1.Install the SDK Manager that support API level 23.
Go to >SDK Manager, >Android SDK , then select API 23 and install.
2.second alternative is to update your build.grade app module to change
compileSdkVersion,compile,and other numbers to your currently supported API level.
Note:please ensure to check the API and Revision numbers and change them exactly. otherwise Your project won't synchronize
Ensure the IDE recognizes that you have the package. It didn't on mine even after downloading 28, so I uninstalled then reinstalled it after realizing it wasn't showing up under File-Project Structure-Modules-App as a choice for SDK.
On top of that, you may want to change your build path to match.
Slightly related, the latest updates seem able to compile when I forced an update all the way to 28 for CompileSDK, and not just up to the new API 26 min requirement from Google Play. This is related to dependencies though, and might not affect yours
AndroidSDK > SDK platforms > and install API Level 23

Android Studio problems since the last update to 0.8 version

I'm following the Google I/O conference and just a week before they announced that Android Studio 0.8 is available for downloading. Before that I used 0.6 and I was developing an application. Now I'm having both 0.6 and 0.8 on my Ubuntu. I added all the update from SDK for Android Watch and TV and all the Material Design stuffs. And today when I opened my project in the 0.8 version, after a few updates of some things, I'm receiving an error
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:appcompat-v7:21.0.0-rc1
If someone has any idea what is this all about - share please. I tried to pull my project from my repository in GitHub, but without any result. Thank you.
It looks like you have declared a dependency on version 21 of appcompat-v7 in your build.gradle.
At this time, the preview of the Android L support libraries only works with apps that declare the L preview as their min SDK.
Either revert to a previous version of the support library (I believe the latest is com.android.support:appcompat-v7:19.1.0) or update your project to support a minimum of 'L'.
just try this:
android {
android {
compileSdkVersion 20 //or whatever you want
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14 //or whatever you want
targetSdkVersion 20 //or whatever you want
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
}
}
and if you have another module in your project, check manifest files in those modules too.
I had a similar issue like that before. After I updated to 0.8.1, it showed an error below when compiling my previous projects.
"uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:appcompat-v7:21.0.0-rc1".
This is how I fixed it.
In your project, find build.gradle file in app folder and open it.
At dependencies section, change the value of compile 'com.android.support:appcompat-v7'. For example, in my case, it was compile 'com.android.support:appcompat-v7:+', and I changed it to compile 'com.android.support:appcompat-v7:20.+'. Of course, you could change it to compile 'com.android.support:appcompat-v7:19.+' if you like.
I hope it would help. Let me know if you are still stuck on it.
I had similar problems. Although I'm not sure exactly what caused the problem or which step fixed the issue, I did the following and ultimately got things working again:
I closed down Android Studio
I ran SDK Manager and and checked that everything was up to date. I have the following installed:
Android SDK tools Rev. 23
Android SDK Platform-tools Rev. 20
Android SDK Build-tools Rev. 20
Android L (API 20, L preview)
Android 4.4W (API 20)
Android 4.4.2 (API 19)
I restarted Android Studio and started a new (blank) project to test and ran it -> Success!
I found the process pretty finickity, so your mileage might vary. Let me know how you go.
I had the same error. I found the solution.
dependencies {
compile ('com.android.support:support-v13:20.0.0'){
force = true
}
compile ('com.android.support:support-v4:20.0.0'){
force = true
}
compile ('com.android.support:appcompat-v7:20.0.0'){
force = true
}
}
I think that instead of 20.0.0, you can specify a different version if you use less than 20 targetSdkVersion.
I had the same issue.
I made the following changes to the dependencies section in build.grade file located in the app folder.
'com.android.support:appcompat-v7:20.0.0' to 'com.android.support:appcompat-v7:20.+'

Categories

Resources