I just installed Android Studio for a new class and I can't even run a HelloWorld program. There are no third party dependencies as I literally just installed Android Studio, SDK version 16, the latest support repository, latest build tools, and created a Nexus 5 AVD running 4.1.2 (16). I keep getting
"Error:(24,13) Failed to resolve: com.android.support.appcompat-v7:16.+"
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "edu.usna.mobileos.hellooooworld"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:16.+' // line giving me the error
}
I've tried many other solutions I've found online, but none have worked so far. I need to work with API version 16 (Android 4.1.2) in this class, so using a newer API isn't an option.
It happens because the 'com.android.support:appcompat-v7:16.+' doesn't exist.
Use the latest version and pay attention using the + because it is not a good option.In this way you will not be able to replicate the build in the future.
I need to work with API version 16 (Android 4.1.2) in this class, so using a newer API isn't an option.
Don't confuse minSdk and the compileSdk.
The compileSdkVersion is your way to tell Gradle what version of the Android SDK to compile your app with.
If compileSdkVersion sets the newest APIs available to you, minSdkVersion is the lower bound for your app. The minSdkVersion is one of the signals the Google Play Store uses to determine which of a user’s devices an app can be installed on.
More info here.
You can use one of these versions.
Check your sdk for updated version:
//it requires compileSdkVersion 23
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.0'
//it requires compileSdkVersion 22
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
//it requires compileSdkVersion 21
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.0'
Also there are very old version:
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
Inside Android Studio click the icon below to open the SDK Manager:
From there you should see something like this:
You want to update and/or install Android Support Library. You also may need to update the version your build.gradle file is pointing to. For example, the version I have is 23.1.0, so my reference would look like this:
compile 'com.android.support:appcompat-v7:23.1.+' // line giving me the error
Related
I tried to add a CardView in my app so I added the following dependency in my gradle
compile 'com.android.support:cardview-v7:22.2.1'
I realised that an error is caused because I have given the wrong version number. After taking a look at the official google docs I came to know that Android Support Repository is used to hold appcompat libraries.
As you can see the Support repository that I have installed is version 33. But if I change my gradle to version 33 it is still showing error.
How can I check what version of AppCompatLibrary I have in android studio?
EDIT:
build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.spintum.preexam"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
// compile fileTree (dir:'libs',include:'achartengine-*.jar')
//compile fileTree('libs/achartengine-1.1.0.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:percent:22.2.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:cardview-v7:+'
//compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32#aar'
}
Check your SDK folder and see which is the highest existing number:
e.g
B:\android-sdk\extras\android\m2repository\com\android\support\appcompat-v7
There will be a folder for each installed version. At the time of writing, 24 is the latest version.
Update:
Now Google use their own Maven repository, this no longer works.
Instead, check this site for the available versions.
https://maven.google.com/
It is not about the installed version of the Android Support Repository.
The version that should be in the Gradle Build Files should be the number highest version corresponding to your
compileSdkVersion
in your AppLevel Gradle Build File.(by default it is the app module).
Example:
If you are using compileSdkVersion 23 , then you should check your following directory for the highest 23.x.x folder.
\ YOUR-SDK-PATH
\extras\android\m2repository\com\android\support\cardview-v7
Suppose that your highest number starting from 23 is 23.4.0 , then you should use this version number(23.4.0 replacing the 33.0.0) for your Gradle Build File(Not the verison of Android Support Repository Installed).
It means you have to use the Android Support Repository Libraries according to your compileSdkVersion.
The easist way is to use + which means the newest one (of the API level) on your machine, then you do not need to check the SDK folder anymore. e.g.,
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:support-v4:21.+'
However, there is an warning void using 21.+ ....".
I'm trying to make an app using the android support library, so if I start a new project with a basic activity, then add the android support library using the dependencies menu, I get this error:
This support library should not use a different version (24) than the `compileSdkVersion` (23)
This is what my gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.moore.criminalintent"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:24.0.0'
}
I've not touched any other settings apart from creating the project and adding the dependency. Any help in resolving this would be greatly appreciated.
Since you are using the support libraries v24.
compile 'com.android.support:support-v4:24.0.0'
You have to compile with API 24. Use:
compileSdkVersion 24
Change compile 'com.android.support:support-v4:24.0.0' to compile 'com.android.support:support-v4:23+' (and optionally provide a sub version. The plus means the latest version of 23.something will be used).
This error is caused because you are compiling against API version 23 (android M), so you cannot use the support library version 24. Version 24 of the support library is for the recently released Android N developer preview, from my understanding.
Alternatively, you could of coarse increase your compile SDK version to 24.
If your using compile SDK version 24 than you should use it as
compile 'com.android.support:support-v4:24.0.0'
today I upgraded my studio, and every latest sdkBuild version.
now my build.gradle(app) configuration looks like this:
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc1"
defaultConfig {
applicationId "com.mydesign.rockstar.androidndemo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
now it says a newer version of com.android.support:appcompat-v7 than 23.2.0 is available: 24.0.0-alpha1 as well as for design: 23.2.0
its not working correctly, and my app crashing. toolbar error, style error, everything is not properly working. Please help me understand what the actual problem is?
its working fine now, bcz i m just downloaded android support repository rev.28 and change both appcombat and design library to latest version. now its
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
this is latest version till now
what i learn is always use stable version of dependency. and this is what you can find it here
I am following a guide on using the Recycler View, I having trouble with the part of declaring the dependency and installing the RecyclerView into Android Studio.
I added the RecyclerView to my xml file and declared the dependency in build.gradle(below)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.ryde.chris.ryde"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.supportrecyclerview-v7:23.0.0'
}
I rebuilt the app and tried installing the Recycler View repo. When installing, I ran into the same exact issue that this user did.
I took a look at the answer on that thread. I chose to use RecyclerView v 23.0.0 and made sure that I compiled with api version 23 (compileSdkVersion 23 in build.gradle). Using the AVD manager, I also made sure that my support library for api version 23 was installed and updated
Does anyone know why I am still getting this issue? Internet is working fine (this to be specific)
Change
compile 'com.android.supportrecyclerview-v7:23.0.0'
to
compile 'com.android.support:recyclerview-v7:23.0.0'
Use the new version:
compile 'com.android.support:recyclerview-v7:23.1.1'
I am unable to compile 'compile .android...' any dependicies from my last update , After some update like Android support library, android support repository , sdk platform tools in SDK manager. I am unable to add dependency, whenever i add it shows below error
And If i change my dependency compiled like this to latest As
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
}
it shows like this :
So please solve my problem i m unable to work with android studio, say ur suggestions for above.
Please check if this folder exist
C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools on your machine. If it does not, y advice is to remove Android studio and reinstall it. Note: The binary version and not the Archived version of AS
do u set compileSdkVersion 23 and buildToolsVersion "23.0.1"?
Update android SDK to latest version 23 and see that your gradle file content is similar to below
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "yur id"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}