Setting up Gradle for api 26 (Android) - android

Since I have upgraded my Nexus 5x to Android O DP3 I am not able to test my applications. I get the error for not having configured my Gradle-file to work with the new API-level (26).
So I changed this and the dependencies, but I keep getting errors on ALL my support libraries like
Failed to resolve: com.android.support:design:26.0.0-beta2
Clicking on
Install repository and sync project
Pops up a progressdialog for downloading the right dependency but does not remove the error. Cleaning up project, installing repositories and then rebuilding the project won't work either.
appcompat-v7
On appcompat-v7:26.0.0-beta2 I get (before even a Gradle sync) squickly lines with the error:
When using a compileSdkVersion older than android-O revision 2,
the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)
Can someone help me get the gradle file to be configured correctly for Android API 26?
Any help would be appreciated.
PS: I'm using Gradle 3.0.0-alpha3 at the moment but get the same error on Gradle 2.3.2
My Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "********"
minSdkVersion 21
targetSdkVersion 26
versionCode 3
versionName "2.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:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
compile 'com.redbooth:WelcomeCoordinator:1.0.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.4.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.ramotion.foldingcell:folding-cell:1.1.0'
}

Have you added the google maven endpoint?
Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.
Add the endpoint to your build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
Which can be replaced by the shortcut google() since Android Gradle v3:
allprojects {
repositories {
jcenter()
google()
}
}
If you already have any maven url inside repositories, you can add the reference after them, i.e.:
allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com'
}
}
}

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
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'
}
}
}
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'

Appart from setting maven source url to your gradle, I would suggest to add both design and appcompat libraries.
Currently the latest version is 26.1.0
maven {
url "https://maven.google.com"
}
...
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'

You could add google() to repositories block
allprojects {
repositories {
jcenter()
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
maven {
url "https://jitpack.io"
}
google()
}
}

Appears to be resolved by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.

you must add in your MODULE-LEVEL build.gradle file with:
//module-level build.gradle file
repositories {
maven {
url 'https://maven.google.com'
}
}
see: Google's Maven repository
I have observed that when I use Android Studio 2.3.3 I MUST add repositories{maven{url 'https://maven.google.com'}} in MODULE-LEVEL build.gradle.
In the case of Android Studio 3.0.0 there is no need for the addition in module-level build.gradle. It is enough the addition in project-level build.gradle which has been referred to in the other posts here, namely:
//project-level build.gradle file
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
UPDATE 11-14-2017: The solution, that I present, was valid when I did the post. Since then, there have been various updates (even with respect to the site I refer to), and I do not know if now is valid. For one month I did my work depending on the solution above, until I upgraded to Android Studio 3.0.0

Related

Failed to resolve: com.android.support:appcompat-v7:23.4.0

I want to use MusicBobber library in my project, but this error showed up
Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
I have com.android.support:appcompat-v7:23.1.1
and this is complete gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tabaneshahr.playaudiotest"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
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.cleveroad:audiowidget:0.9.2'
}
I'd searched stackoverflow but noting useful. what should I do? does minSDK must change? shall I download anything?
First, replace your appcompat compile line with the latest one like this:
compile 'com.android.support:appcompat-v7:24.2.0'
Update to the targetSdkVersion 24 as well.
and remove the compile line for the library:
compile 'com.cleveroad:audiowidget:0.9.2'
Second, clean/build and run the project, you should not get any errors. If this happened, then your problem is not with the appcompact at all, but it is with the library.
Thrid, try to add the library compile line and again and let the gradle sync. If you still getting a problem, then I recommend to save your self the hassle and integerate the library in your code manually by doing the following this link steps
Hope it helps!
Please update your build tool version :
buildToolsVersion "23.0.2"
to 25 or you can use
compile 'com.android.support:appcompat-v7:23.0.0'
Clean and rebuild your android project.
> create a new project and you will see exact version .
for example for me in project file was :
compile 'com.android.support:appcompat-v7:24.2.0'
but after created new project i saw it is like this :
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
so changed and sync and fixed .
I ran into this error while trying to run SQLite Android Bindings. It still uses a very old gradle configuration (included below).
TLDR
com.android.support:appcompat-v7:23.4.0 is very old and only available on https://maven.google.com (google() in build.gradle) as of this writing. Make sure your root build.gradle includes the google() repository in its allprojects.repositories section:
allprojects {
repositories {
jcenter()
google()
}
}
SQLite's woefully out of date gradle configuration:
$ROOT/build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
// this was the problem. google() was missing!
}
}
$ROOT/sqlitetest/build.gradle:
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}

Android Studio Gradle does not download maven depedencies

I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
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'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.

Cannot add CircularReveal library by ozodrukh in Android studio

I am using Android Studio 1.1.0 and am trying to add CircularReveal library .I have followed the instructions mentioned there.
my build.gradle(Module: app) is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.geronimo.myapplication"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
}
I have added the repository in `build.gradle(Project: MyApplication3)`
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
The error that I am getting is
D:\Workspaces\AndroidStudio\Studio1.0\MyApplication3\app\build.gradle
Error:(24, 13) Failed to resolve: com.github.ozodrukh:CircularReveal:(latest-release)
Show in File<br>Show in Project Structure dialog
I have tried variations of the dependency too ie:
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
compile 'com.github.ozodrukh:CircularReveal:(v1.0.4)#aar'
compile 'com.github.ozodrukh:CircularReveal-v1.0.4 #aar'
The error always remains as Failed to resolve...
Is there any other way to import a remote aar file and to add this dependency?
Copy #aar file to the libs directory manually. Then by going to
Files>Project Structure>Dependency
on the right red cross choose library dependency. This will prompt you a dialog where you can search for your dependency and add them.
or
download circularReveal library from github and import it as Module Dependency from Files>Project Structure>Dependency
You need to put only version number without brackets and 'v' char
com.github.ozodrukh:CircularReveal:1.0.4#aar
I had the same problem before. After I checked, I saw that the problem was the miniSDKversion which was lower than 15. Once I changed it to 15, it worked.
minSdkVersion 14 (change it to 15 or above)
targetSdkVersion 26
Then paste this to your library dependency
implementation ('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
Also add remote maven url
repositories {
maven {
url "https://jitpack.io"
}
}

Android Studio gradle sync failed to find library

So I'm working on project in AndroidStudio 0.8.1 beta and I want to make use of a library I found on github (https://github.com/derekbrameyer/android-betterpickers). I add the dependency like it says inside the README.md but when I try to sync the project with the gradle files it says:
Failed to find: com.doomonafireball.betterpickers:library:1.5.2
Here is my build.gradle file:
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'gtsarandum.syncc'
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.+'
compile project(':extendedCalendarView')
compile project(':src')
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
compile 'com.github.gabrielemariotti.cards:library-extra:1.7.3'
compile 'com.doomonafireball.betterpickers:library:1.5.2'
}
Last time I had this problem with gabriellemariotti.cards:libraryd:1.7.3 I added maven { url 'http://repo1.maven.org/maven2' } inside the buildscript as you can see above.
Is there something else I have to add? If not, how do I solve this problem?
Many thanks in advance!
My fix was to add:
allprojects {
repositories {
mavenCentral()
}
}
to the build.gradle file
Try alter 'gradle.settings' with an include statement for the path/lib not being found.
Don't use HTTP Proxy. Android Studio -> File -> Settings-> HTTP Proxy -> No proxy

Gradle only downloads .aar.asc from Maven Central

I freshly deployed an Android library named TypedPreferences. I used it in another Android project for some days. Suddenly, it stopped working - dependencies cannot be found any longer. I noticed that Gradle only downloads one file when I clean the project:
Download http://repo1.maven.org/maven2/info/metadude/android/typed-preferences/ \
1.0.0/typed-preferences-1.0.0.aar.asc
These are build files of my pet project:
build.gradle:
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url "${System.env.HOME}/.m2/repository"
}
maven {
url "https://github.com/novoda/public-mvn-repo/raw/master/releases"
}
}
}
app/build.gradle:
apply plugin: 'android'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
compile 'com.squareup.okhttp:okhttp:1.3.+'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
compile 'com.novoda:sqliteprovider-core:1.0.+'
compile 'com.androidmapsextensions:android-maps-extensions:2.1.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'info.metadude.android:typed-preferences:1.0.0'
}
As you can see, I also enable Gradle to look into my local Maven cache here:
maven {
url "${System.env.HOME}/.m2/repository"
}
I deleted the relevant folders to avoid Gradle loading stuff from there.
There might be a misconfiguration in the build.gradle files of the library - please find them here:
Library files
Please tell me also whether I can test your fix locally without deploying to Maven Central.
Looks like the packaging element of the published POM has the wrong value. It should be aar, not aar.asc.
Also, you always can force the type of artifact to download. Just add dependency like:
compile "group:artifact:version#type"
And in your case it will be
compile "info.metadude.android:typed-preferences:1.0.0#aar"
That's it.

Categories

Resources