I have already installed Android SDK Platform 26, Android SDK Tools 26.0.2
This is my app level build.gradle file.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
testCompile 'junit:junit:4.12'
}
I can't sync the gradle. I am getting these errors:
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.2
Error:(27, 13) Failed to resolve: com.android.support:support-v4:26.0.2
Are the appcompat and support library versions are wrong?
How can I solve this issue? Please help.
Thanks in advance.
There are two things to it
First
This is the page that announces recent releases of the support library, and I don't see 26.0.2 version. The latest is 26.0.0-beta2 and
Note that 26.0.0-beta2 is a pre-release version
Second
Make sure you have google's maven repository included in you project's gradle file. Something like :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
appcompat version must to match with SdkVersion.
Try this one
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
Related
I am having runtime problems with my gradle file. I added this compile 'com.google.android:flexbox:0.3.1' as a compile time dependency to my Gradle file. I encountered an error and added this in my project level Gradle file.
maven {
url "https://maven.google.com"
}
Which finally looked liked this after adding the above
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
After adding the above in my app level Gradle file I am now encountering a different error when I am trying to run my app. So I did the following as per some answers from SO.
Tried a Clean and Rebuild.
Navigated to the path projectName\.idea\libraries and deleted the files that contained the support library version other than the current versions 25.3.1
3.In order to solve the error I further removed this line from my app level Gradle file,
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Now the final Gradle file looks like this with the error,
Error:
Error:(28, 8) error: cannot access ActivityCompatApi23
class file for android.support.v4.app.ActivityCompatApi23 not found
My Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android:flexbox:0.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
testCompile 'junit:junit:4.12'
}
Like the Problem I meet。
When I Use Android Room like this :
compileSdkVersion 25
compile "android.arch.persistence.room:runtime:1.0.0"
I get the same Error.
Because compileSdkVersion should match support libs major version.
More Detail you can see this :
Error in support lib after room persistence
Room depends on 26.1 of support library, which is probably why it is broken because SupportLibrary does not promise interop between versions.
Also, you can fix the problem use this
compile ("android.arch.persistence.room:runtime:1.0.0") {
exclude group: 'com.android.support'
}
You have declared compileSdkVersion equal to 25, whereas 0.3.1 version of flexbox layout uses support libs version 26.0.0 - that's a problem, compileSdkVersion should match support libs major version.
Either upgrade your project to 26 or use a version of flexbox layout that relies on sdk 25, which seems to be v0.2.7:
compile 'com.google.android:flexbox:0.2.7'
use
compile 'com.android.support:appcompat-v7:26.1.0'
I just changed the line
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
to
compile 'com.android.support:appcompat-v7:26.+'
and it worked for me
I'm using Android Studio version 2.3.3. It has been updated recently. Whenever I try to add a new dependency for any use e.g. recyclerview, cardview, retrofit, etc, the gradle fails to resolve them.
I have mentioned the repositories in gradle file. But there is no solution.
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.apurva.bargraph"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.philjay:mpandroidchart:v3.0.2'
testCompile 'junit:junit:4.12'
}
for each of the dependency, gradle sync fails and I don't know what else to do.
Any kind of help would be great.
There may be number of problems for this
1. First check your buildToolVersion which you are using is installed in your sdk.
2. You have to add below code in project gradle file not in app gradle.
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
Just change the buildToolVersion to higher version which is installed in you studio.
It's May be help you out.
This is because you didn't have support library 25.3.1 installed in your system. So, you need to install the sdk from Android Studio via Tools->Android->SDK Manager for support library below 25.4.0. You only need to use google maven to use support library starting from revision 25.4.0.
I'm trying out Android Studio 3.0 Canary 9 with an existing project, and I'm getting this error trying to sync the build files:
Error:Failed to resolve: commons-logging:commons-logging:1.1.1
I am not adding commons-logging as a dependency, so it must be used by some other dependency but I don't know what. Here's the buildscript section of my top-level build file where I made changes for 3.0:
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.5'
}
}
In gradle-wrapper.properties I have this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
The only change I made in the project build file was to the way I was renaming the APK file. Anybody know how to track down this dependency and what to do to fix it?
If you using Android Gradle 2.2 plugin or newer, then you should remove com.neenbedankt.gradle.plugins:android-apt from your Gradle plugins.
Also change all apt in dependencies to annotationProcessor
You can read more here
I don't know if this will fix, but it might help in locating the issue.
start a new empty project using AS 3.0, add the 3 dependencies 1 by 1 while testing in between each add. I have a suspicion one of them doesn't play nicely with AS 3.0, and that it has nothing to do with your code since you made no changes.
Another thing you can try is going back to an older version of AS and rechecking that it runs. This isolates the issue to AS 3.0 and not your code or dependencies.
Lastly if nothing works, create a brand new project with new package name and manually copy paste everything into the new project. I usually find lots of bugs doing this.
I followed moonpire00's suggestion and created a new project. I discovered that the problem was with the AWS imports:
implementation 'com.amazonaws:aws-android-sdk-core:2.2.0'
implementation 'com.amazonaws:aws-android-sdk-ses:2.2.0'
I changed them to this:
implementation 'com.amazonaws:aws-android-sdk-core:2.2.0', {
exclude module: 'commons-logging'
}
implementation 'com.amazonaws:aws-android-sdk-ses:2.2.0', {
exclude module: 'commons-logging'
}
And now the gradle sync works! If anyone has insight into why this error would appear with Android Studio / gradle 3.0, please post a comment.
Its Working
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.keshav.mraverification"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
testCompile 'junit:junit:4.12'
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
I recently decided to learn Android programming, so I installed Android Studio and Android SDK on my Ubuntu machine. The issue is when I build a new project, it says :
Gradle Sync completed with some erros
and the log is :
/home/moein/apps/android-studio-projects/Testapp/app/build.gradle
Error:Error:line (24)Failed to resolve: com.android.support:appcompat-v7:23.+
Error:Error:line (23)Failed to resolve: junit:junit:4.12
my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.moein.testapp"
minSdkVersion 23
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.0.0'
}
Do you have this in your build.gradle file:
compile 'com.android.support:appcompat-v7:23.3.0'
The most probable reason for such errors is you do not have all support libraries installed. Go to SDK manager and install all the supporting repositories. For more details you can visit this answer.
These are the correct version that you can add in your build.gradle according to the API needs.Use it by your requirement.
API 21:
compile 'com.android.support:appcompat-v7:21.0.1'
OR
compile 'com.android.support:appcompat-v7:21.0.2'
OR
compile 'com.android.support:appcompat-v7:21.0.3'
API 22:
compile 'com.android.support:appcompat-v7:22.0.0'
API 23:
compile 'com.android.support:appcompat-v7:23.2.0'
Try Installing the following Highlighted item:
I found the answer to this problem.
I used to get it whenever I open a new project.
Just paste these lines in build.gradle (module:app)
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
Sync it again it will probably solve your problem.
I have a problem with android studio.
I have added the .jar file of okhttp from this link : https://github.com/square/okhttp to my libs directory on my android studio. and when I try to add this line : compile 'com.squareup.okhttp3:okhttp:3.2.0' in the dependencies in build.gradle(Module:app), after trying to syncing it I get error 28, 13. Actually after researching I found out that I can't compile anything in dependencies and sync it remember that I have checked my "android SDK build tool" is installed.
hear is the whole of my code in build.gradle(app) directory:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.kasra.stormy"
minSdkVersion 14
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.1'
compile 'com.android.support:design:23.1.1'
compile files('libs/okhttp-3.2.0.jar')
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
I'll be very glad and thankful if someone help me fix this problem.
Thank you very much:)
Either your internet is bad and you can't download that file from JCenter, or you are just missing a repositories section in your gradle file.
apply plugin: 'com.android.application'
repositories {
jcenter()
}
Also, if you are going to be compiling using gradle instead of a JAR file, then delete the file libs/okhttp-3.2.0.jar and remove the line that says compile files('libs/okhttp-3.2.0.jar').
It is also worth mentioning that you don't need any lines that start with compile files('libs/ because compile fileTree(dir: 'libs', include: ['*.jar'], ) already includes all JAR files within the libs/ folder.
It may help someone. In my case after update com.squareup.okhttp3 to the latest version, I got this error in Android Java libaray. Then I update the Java version to 1.8 which solved my problem.
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
you should change the build.gradle(app):
use
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
instead of
compile 'com.squareup.okhttp3:okhttp:3.2.0'
or just follow the guide as mentioned here.
Just Replace the dependencies with folowng dependencies and they will work for sure.(100%).
if in future this issue comes again then go to https://square.github.io/okhttp/ and update your dependencies with latest one
//define any required ok http without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
//define a BOM and its version
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.0"))
Just remove compile files('libs/okhttp-3.2.0.jar')
I solved my problem by editing my build.gradle as below:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile project(':library')
//compile('com.squareup.okhttp3:okhttp:+') {
// exclude group: 'org.json'
//}
//replaced as below:
compile 'com.squareup.okhttp3:okhttp:3.9.1'
}
Check your code in app.gradle
apply plugin: 'com.android.application'
repositories {
jcenter()}
OR
make your compile okhttp to offline mode, next you uncheck offline mode in setting -> gradle. and try it again
You will not need this
compile 'com.squareup.okhttp3:okhttp:3.2.0'
rather you will need
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
As of today the 30th of September 2020
Check https://square.github.io/okhttp/ for documentation