I am using android-studio 0.6.1 and have all necessary google repositories installed in SDK manager: however when I try to build a project, gradle says about unresolved dependency:
Unresolved dependencies:
Error:com.google.maps.android:android-maps-utils:+
My build.gradle looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 12
targetSdkVersion 19
versionCode 1
versionName '0.1'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.maps.android:android-maps-utils:+'
}
I know I can just import all necessary instruments in library folder, however I would like to resolve this problem. Do you have any suggestions?
EDIT:
Found a way to solve it:
Looks like the problem was in absense of
compile 'com.android.support:support-v4:19.0.1'
in build.gradle, also I had to empty 'library' folder and delete the line in order to avoid 'duplicate packages' problem with support libraries:
compile project(':library')
So my final build.gradle file looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 12
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
repositories {
mavenCentral()
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.google.android.gms:play-services:4.4+'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
The error is
Unresolved dependencies:
Error:com.google.maps.android:android-maps-utils:+
I'd say double check that you've got the dependency correctly defined. Looking at the Map Utils website leads me to believe you might want to declare the dependency with a version.
Replace
compile 'com.google.maps.android:android-maps-utils:+'
to
compile 'com.google.maps.android:android-maps-utils:0.3+'
Do a Gradle Sync and everything should build correctly.
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// Support Libraries
compile 'com.google.android.gms:play-services:4.1.32'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
com.google.android.gms:play-services:3.1.36 can be downloaded by going to your SDK Manager and installing the Extras->Google Repository package (you may want to install the Extras->Android Support Repository as well while you are there). These allow Gradle to automatically use these resources without the need for library projects or jars manually added to your project.
Try to replace this:
compile 'com.google.maps.android:android-maps-utils:0.3+'
with this
compile 'com.google.android.gms:play-services-maps:9.4.0'
Related
My build.gradle(:app) code
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "tk.yurkiv.recipes"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:28.0.0'
compile 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.jakewharton:butterknife:6.1.0'
annotationProcessor 'com.jakewharton:butterknife:6.1.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.akexorcist:RoundCornerProgressBar:1.2.3'
compile 'com.vlonjatg.android:progress-activity:1.1.1'
compile 'me.zhanghai.android.materialprogressbar:library:1.0.2'
compile('com.github.florent37:materialviewpager:1.1.0#aar') {
transitive = true
}
compile 'com.afollestad:material-dialogs:0.7.9.1'
compile 'org.adw.library:discrete-seekbar:1.0.0'
compile 'com.github.leonardoxh:fake-search-view:0.3.1'
}
Build Output
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.afollestad:material-dialogs:0.7.9.1.
Searched in the following locations:
file:/E:/Android/Sdk/extras/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
file:/E:/Android/Sdk/extras/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
file:/E:/Android/Sdk/extras/google/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
file:/E:/Android/Sdk/extras/google/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
file:/E:/Android/Sdk/extras/android/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
file:/E:/Android/Sdk/extras/android/m2repository/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
https://dl.google.com/dl/android/maven2/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
https://dl.google.com/dl/android/maven2/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
https://jcenter.bintray.com/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
https://jcenter.bintray.com/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
https://jitpack.io/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.pom
https://jitpack.io/com/afollestad/material-dialogs/0.7.9.1/material-dialogs-0.7.9.1.jar
Required by:
project :app
According to this issue on the library repository
https://github.com/afollestad/material-dialogs/issues/990
The library is moved to JCenter so in your build.gradle make sure you have this line jcenter()
allprojects {
repositories {
jcenter()
...
}
}
In any new project, this code is added by default
Replace this:
compile 'com.afollestad:material-dialogs:0.7.9.1'
with this:
implementation 'com.afollestad.material-dialogs:core:3.3.0'
Looks like you are running a legacy project which needs a lot of refactoring.
NOTE: This solution might work for the specific question but not for the project. Update your project to fix every other issues.
Edit: Also see AmrDeveloper's answer below assuming the project is old.
Referring question here.
Problem is that i am including something which is repeated.
Can somebody help me figure which one is causing problem?
And this error started arising when i added twitter sdk.
build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.sony.login_signup"
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'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.shamanland:facebook-like-button:0.1.8'
compile 'com.google.android.gms:play-services:+'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.github.curioustechizen.android-ago:library:1.3.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile('com.twitter.sdk.android:twitter:1.9.0#aar') {
transitive = true;
}
}
If you do:
gradle -q dependencies
It should output a tree of all gradle dependencies and their dependencies. If you trace the dependency tree you will find which ones are using support-v4 and their versions, to tell you where the problem is.
EDIT:
This should be run on a command line / terminal. Gradle is just another program...
https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html
To do this, make sure that "gradle" is in your environment PATH (this is different depending on if you're Windows or Mac, but if you search you will find it).
Then run the command from the folder where your "build.gradle" and "settings.gradle" files are located (your project "root" folder typically).
I have new clear android app. I want to add volley to my app to make HTTP request. I am developing app with Android studio using Gradle. Here is screenshot for my app:
Ass you see i am going to add volley to my app adding this line of code com.mcxiaoke.volley:library-aar:1.0.0 to build.gradle file
I tried to add Retrofit too. But it gives same type of error: Failed to resolve: bla bla bla.
So i think in my situation gradle can not sync any other library different than com.android......
And i have tried add this lines of code to my build.gradle too. but nothing is changing
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
repositories {
mavenCentral()
}
}
Please advise
Edit: After comments added build.gradle files for project and for module.
Project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "domain.testgradle"
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'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
Volley is now published by the Android Open Source Project on jCenter:
dependencies {
compile 'com.android.volley:volley:1.0.0'
}
You can use
com.mcxiaoke.volley:library-aar:1.0.1
Or its latest version (Not aar)
compile 'com.mcxiaoke.volley:library:1.0.19'
And set
buildToolsVersion "23.0.1"
and use
'com.google.code.gson:gson:2.3'
Add this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:+'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
I am going to add material-dialogs library to my project but I get this error Error:Failed to find: com.android.support:appcompat-v7:21.0.3 This is build.gradle..Where is my mistake?Is sth wrong with my project?
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.peomtime.tosca.peomtime"
minSdkVersion 15
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:support-v4:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'de.hdodenhof:circleimageview:1.2.0'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
//Core
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
compile 'com.github.machinarius:preferencefragment:0.1.1'
//compile 'com.github.nirhart:parallaxscroll:1.0'
compile project(':Parallax')
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.afollestad:material-dialogs:0.6.3.1'
}
thank you so much for your help
Check that you have latest libraries installed in Android SDK Manager. For appcompat-v7:21.0.3, the packages need to be checked/updated are:
Android Support Repository
Android Support Library
Also, it's recommended to fix your dependencies version rather than using + to get latest version:
compile 'com.android.support:appcompat-v7:21.0.3'
Not sure why, but I added this repo from Afollestad to my build.gradle (project, not model) and everything was resolved.
repositories {
maven { url "https://jitpack.io" }
}
link
My (Android Studio) project has two modules: an Android-Library (app) Module and a Google Backend Module. The app module accesses the backend. in my gradle dependencies (app) I have:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':Backend', configuration: 'android-endpoints')
compile ('com.google.android.gms:play-services-wearable:6.1.71') {
exclude module: 'support-v4'
}
I want to use the app library in other projects, so I tried a) exporting it to a aar-library and b) exporting it into a jar-library. It works during compile time. I can use all classes of the app-module. But when running this app, it gives me an error, that it does not find the class that is the Interface between app and backend modules (as part of the backend).
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/cluedup/voicecontrols/backend/apiVoiceForm/model/VoiceFormBean;
Does anybody have an idea of how I can get this to work?
EDIT: Here are the complete gradle-files:
Library-App:
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.cluedup.voicecontrols"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs', '../backend/libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':Backend', configuration: 'android-endpoints')
compile ('com.google.android.gms:play-services-wearable:6.1.71') {
exclude module: 'support-v4'
}
}
Importing app
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.cluedup.voicecontrols.sample"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('com.google.android.gms:play-services-wearable:6.1.71') {exclude module: 'support-v4'}
compile(name:'app-debug', ext:'aar'){transitive=true}
}
Here is what works for me - it seems like a hack for me, though! So if someone has a better solution, I'll still would be glad to hear about
Step 1: Create a jar of the backend-module. Actually, the jar of the backend is produced as byproduct when trying to publish the whole app in the sonatype central repository. I followed this example (http://gmariotti.blogspot.de/2013/09/publish-aar-file-to-maven-central-with.html) to prepare for the upload.
As a result, I found a jar-file of the backend in the ../backend/build/libs Directory.
Step 2: Remove the dependency of the app to the backend-module and replace it with a dependency to the created jar-file
// DO NOT USE compile project(path: ':Backend', configuration: 'android-endpoints')
compile(name:'Backend-0.0.2', ext:'jar'){transitive=true}
Step 3: create the aar-file of the app with gradlew assemble
Step 4: add the jar of the backend and the aar of the app as dependencies in the importing Project
compile(name:'app', ext:'aar'){transitive=true}
compile(name:'Backend-0.0.2', ext:'jar'){transitive=true}