I create empty project in android studio 2.3.3 and it by default has compile 'com.android.support:appcompat-v7:26.+' in it's module level build.gradle file and it compiles ok, but when I specify any concrete version from https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-2
gradle sync fails with message
I also tried the following notation compile group: 'com.android.support', name:'v7-appcompat', version: '26.0.0', still no success.
I have
jcenter()
maven {
url "https://maven.google.com"
}
in repositories secion. Install repository and sync project button is not clickable. Support repository is updated:
You misswrote the artefact name. Change it as below:
compile 'com.android.support:v7-appcompat:26.0.0'
to
compile 'com.android.support:appcompat-v7:26.0.0'
Be sure to use:
compileSdkVersion 26
buildToolsVersion "26.0.0"
or later.
Invalidate Cache, go to File > Invalidates Caches
Just click in the Install Repository and sync Project link to install the missing dependencies.
Then sync your project with the gradle files again.
Second solution, try uninstalling an reinstalling Android Support Repository again (I think its similar to clean cache):
Check the error message:
Failed to resolve com.android.support:v7-appcompat:26.0.0'
The right library is appcompat-v7 and not v7-appcompat
Use:
compile 'com.android.support:appcompat-v7:26.x.x'
Related
I'm using Android Studio 3.0.1 and I'm trying to add an online dependency and while Gradle initially syncs without a problem it doesn't show my dependency in External Libraries and my code that references the dependency doesn't work.
Here's a snippet of what my build.gradle file looks like:
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public/' }
}
dependencies {
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT'
}
I'm pretty new to android development (took over an existing project from a dev who quit without leaving any documentation) so I'm not sure if this is a mistake with how to add a project dependency or if there is a problem with the dependency that I'm trying to add. Any help would be greatly appreciated!
I was able to get this to work by changing the dependency declaration to:
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT', classifier: 'jar-with-dependencies'
The library artifacts up on the repository include an apklib and a JAR with a special classifier. The apklib format is not supported by Android Studio, and unfortunately the classifier on the JAR means that it's not accessible simply using the group-name-version format when declaring dependencies.
Your build.gradle file seems fine. If you want to keep the library specified as an external library, you can try and define the dependency using the alternative notation, replace:
compile group: 'com.fortysevendeg.android', name: 'swipelistview', version: '1.0-SNAPSHOT'
with:
compile 'com.fortysevendeg.android:swipelistview:1.0-SNAPSHOT'
The alternative approach is to download the jar file yourself and use it as a local dependency. If you navigate to the maven repository you can inspect the package which is included as a dependency and download the jar directly. Place the jar file in the libs folder of your project and add the following to your build.gradle file:
compile fileTree(dir: 'libs', include: ['*.jar'])
For further details on how to configure the dependencies of your gradle project, check out the Android Studio documentation here.
Based on the information you have provided, this should fix your issues. If this does not solve the error then there may be other issues with the project.
Your dependencies should not placed in the top-level build.gradle file where the repositories are defined. There is even a comment in that file that says so, by default.
You app dependencies should be the module's build.gradle along with the others like android-support
Additionally, that library is very old, and is a SNAPSHOT build, meaning it isn't meant to be generally used in a release environment. You should find an alternative... And there are plenty of other ListView swiping ones
In my project, I'm trying to use the design support library. I have in my Gradle file:
dependencies {
....
compile 'com.android.support:design'
....
}
And when I try to build this, I get the error:
Normally I would just click Install Repository and sync project, however, this seems to not work anymore. Clicking this does absolutely nothing, even though clicking Open File works fine.
How can I manually install it?
I have the latest Android Support Repository (30.0.0), and Android Support Library (23.2.1) installed.
For me the solution was to add maven in the allprojects section. From the setup document: https://developer.android.com/topic/libraries/support-library/setup.html
in the project level settings.gradle file.
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
Then double check the document for the latest version.
In the app level of the settings.gradle file add:
dependencies{
compile 'com.android.support:design:26.0.1'
}
And use Gradle to sync the project.
I think it is because you've not specified the version.
compile 'com.android.support:design:23.1.1'
change version to what you have downloaded.
You can go File->Settings->Gradle Look at the "Offline work" inbox,
If it's checked you can uncheck and try to sync again.
I want to migrate gradle project in Android Studio to version 1.0.
I have the next problem:
Warning:Project app: Only Jar-type local dependencies are supported. Cannot handle: /home/jaume/android-studio-0.8.14/projects/Rutacomandero/app/libs/google-gson-1.7.1-release.zip
Assuming "google-gson-1.7.1-release.zip" is just the gson dependency, then include it in your dependencies section of your build.gradle file, like so:
compile 'com.google.code.gson:gson:1.7.1'
You should be depending on jar files, not zips, and in the case of gson, grab it from central rather than keeping a copy in libs.
Also, 1.7.1 is old, since you're upgrading anyway, try 2.3.1
Had the same problem and I was able to resolve it by adding
repositories {
mavenCentral()
}
so use:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.code.gson:gson:2.5'
}
I exampled version 2.5 but you should check for updates. see https://github.com/google/gson/releases
My answer was found at http://www.javacodegeeks.com/2013/08/getting-started-with-google-gson.html
I'm trying to add the support libraries to my app by putting this in the dependencies section of build.gradle:
compile 'com.android.support:appcompat-v7:20.0.+'
This works fine in all my libgdx apps except for one of them. It simply cannot find the library. It says:
Error:Could not find any version that matches com.android.support:appcompat-v7:20.0.+.
Searched in the following locations:
file:/C:/Users/MyName/.m2/repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/C:/Users/MyName/.m2/repository/com/android/support/appcompat-v7/
https://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml
https://repo1.maven.org/maven2/com/android/support/appcompat-v7/
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/appcompat-v7/maven-metadata.xml
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/appcompat-v7/
https://oss.sonatype.org/content/repositories/releases/com/android/support/appcompat-v7/maven-metadata.xml
https://oss.sonatype.org/content/repositories/releases/com/android/support/appcompat-v7/
I tried this with the Android support libraries as well, and they have the same issue.
local.properties is pointing to the android sdk just as it is in my other projects.
I see that its searching the Android SDK's local Maven repository for it. But the directory as listed above in the error does not exist. The .m2/repository directory exists with some of my other local stuff, but not the android one. And since this is working fine in my other projects, I'm not sure what could be going on. Perhaps they are checking a different local Maven repository?
I recently installed Maven so I could create my own local repository for use when working on a library project. Maybe I somehow overwrote the original android directory? Doesn't explain why the other old libgdx projects are not failing to find the library though. How can I check where they are searching for it?
Here's the build script (generated by libgdx project generator):
buildscript {
repositories {
jcenter()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.4'
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'org.robovm:robovm-gradle-plugin:1.0.0-beta-01'
}
}
Here are relevant parts of build.gradle in top level of project and from the android module:
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenLocal()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:6.5.87'
}
Check you Android sdk folder.
You should find this folder under this:
androidSdk/extras/android/m2repository/com/android/support/appcompat-v7/20.0.0
If this folder doesn't exist:
update the SDK Manager and update the Android Repository (the last block).
Also I suggest you using the last releases:
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
Please compile with this
compile 'com.android.support:appcompat-v7:20.0.0'
Instead
compile 'com.android.support:appcompat-v7:20.0.+'
Try adding the mavenCentral repo:
mavenCentral()
to your allprojects
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:6.5.87'
}
Sidenote: the support libraries have been updated (not sure if you need the most recent ones):
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
First check whether you have updated 'Android Support Repository' and 'Android Support Library' in your Android SDK Manager. Once updated, you should be able to build with latest appcompat-v7, at this time 21.0.3.
It would be more tricky for older appcompat-v7 versions. We had the same problem before, we were using appcompat-v7:19.0.+ at the time. It appears that once you update Android Support Repository & Library from Android SDK Manager, which contains the source for your support libraries, there is no going back. Once updated, it will only contain the latest source for support libraries, which means your build will always fail unless you update your build.gradle to point appcompat-v7 to latest version.
I find it surprising that we cannot have multiple versions of appcompat available, like how the SDK manager handles the multiple version of Android SDK build tools.
Sounds support library not installed or not in the right path as Android Studio supposed, so double check:
Check your Android SDK location from: File->project Structure->SDK Location
Then go to SDK Location path to check if \extras\android\support\v7\appcompat available
If not available then start SDK Manager under SDK Location, install both Android Support Library and Android Support Repository under Extras
I eventually fixed this after uninstalling Android Studio and the previous beta version I had, as well as all copies of the Android SDK on my computer. Then I reinstalled a fresh copy of Android Studio with the SDK.
Since none of the project configuration changes I made helped, I think there was possibly some kind of internal configuration in Android Studio that made it point at the wrong Maven repository, possibly the Maven repository in an Android SDK somewhere that was no longer maintained.
I'm glad I didn't reconstruct the project from scratch (to find step-by-step what differed between the problematic project and others that did work). Much faster to reinstall Android Studio.
I've taken an Android project that was created in IntelliJ and imported it into AndroidStudio. After looking at Googles hopeless instructions for how to migrate a project to Gradle I pressed buttons at random and prayed to the gods of droid whilst sacrificing a small innocent child and somehow eventually ended up with a Gradle controlled project that synced, built and ran on my Android devices.
I then added some additional dependencies to my build.gradle file:
compile 'com.octo.android.robospice:robospice:1.4.12'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.12'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.http-client:google-http-client-jackson:1.18.0-rc'
compile 'com.octo.android.robospice:robospice-google-http-client:1.4.12'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
Now when I try to sync Gradle I get the following message:
Gradle Project sync Failed. Basic functionality (e.g. editing, debugging) will not work properly.
In the Gradle Sync window I get the following messages:
Unresolved Dependencies:
Error:com.google.http-client:google-http-client-gson:1.18.0-rc
Error:com.octo.android.robospice:robospice-spring-android:1.4.12
...
and so on for each of the dependencies that I have listed.
How might I resolve this?
OK I've figured it out.
I added
allprojects {
repositories {
mavenCentral()
}
}
to the bottom of my build.gradle file.
It was obviously struggling to find a repository to load from.
The script already had
buildscript {
repositories {
mavenCentral()
}
This it would seem was insufficient.