How can i add dependencies in Android Astudio - android

I want add this dependencies compile 'com.github.ar-android:DrawRouteMaps:1.0.0' into my Android studio Project.
When add this into dependencies and click on Sync show me this error :
Error:(39, 13) Failed to resolve: com.github.ar-android:DrawRouteMaps:1.0.0
Show in File<br>Show in Project Structure dialog
build.gradle codes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.example.mohammadn.a1_maptutorial"
minSdkVersion 14
targetSdkVersion 25
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: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services-maps:9.2.1'
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}
How can I fix it and add this library into my dependencies?

Add support jitpact repository in root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Read official guideline about DrawRouteMaps .

Add this to your project: build.gradle file to this
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}

Try adding following lines to project/build.gradle (not app/build.gradle)
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
app/build.gradle
compile 'com.github.ar-android:DrawRouteMaps:1.0.0'

First, you have to add the Maven Repository in your project:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
And then, add dependencies in build.gradle module app :
dependencies {
compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}

In addition to above comments you can add dependencies in file->project structure-> add->+(plus sign)->add library

Related

Failed to resolve: com.google.android.ads.consent:consent-library:1.1.0

I would to integrate GDPR SDK i always get this error, what i can do to reslove this error
Failed to resolve:
com.google.android.ads.consent:consent-library:1.1.0
build.gradle (module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.artdevstudio.currencyconverter"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.google.android.ads.consent:consent-library:1.1.0'
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.android.support:design:27.1.1'
compile 'agency.tango.android:material-intro-screen:0.0.3'
compile 'com.github.GrenderG:Prefs:1.1'
}
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
maven {
url "http://repo1.maven.org/maven2"
}
google()
}
}
The latest version of the consent SDK is 1.0.6, not 1.1.0. Try using this instead:
implementation 'com.google.android.ads.consent:consent-library:1.0.6'
Replace compile with implementation under the dependencies section.

Error:Failed to resolve: support-vector-drawable

I have a problem with gradle. it was working fine but all of sudden when I was rebuilding the project it gives me this error:
Error:Failed to resolve: support-vector-drawable
I can't find out what my problem is?
My app.gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.arizeh.arizeh"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
versionCode 29
versionName "3.0.5"
useLibrary 'org.apache.http.legacy'
testInstrumentationRunner
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
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+'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-places:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile 'com.google.android.gms:play-services-base:15.0.1'
compile 'com.google.firebase:firebase-messaging:15.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.android.support:percent:26.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.shawnlin:number-picker:2.4.2'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:support-compat:26.1.0'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.2#aar'
compile 'com.zarinpal:purchase:0.0.3-beta'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
}
In my case, I've moved the Google repo on the top in the build.gradle config:
allprojects {
repositories {
google() // now here
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// google() // was here
}
}
Add vectorDrawables.useSupportLibrary = true in defaultConfig
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
If an error still persists then
allprojects {
repositories {
google() // make it first element
jcenter()
maven { url 'https://maven.google.com' }
}
}
I just encountered this error along with some others:
Failed to resolve: support-vector-drawable
Failed to resolve: livedata-core
Failed to resolve: common
Failed to resolve: runtime
Failed to resolve: viewmodel
Failed to resolve: monitor
I'm not using React Native but found the answer on there:
In android/build.gradle move the jcenter() to the bottom:
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
jcenter()
}
}
I faced this error on androidx project and solved it with:
1- in Build.gradle (Module file), android{} section add:
vectorDrawables.useSupportLibrary = true
2- in dependencies {} section,
change :
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
to update version:
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-beta02'
compile again.
I had the same problem. you must change build.gradle to
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I had the same problem.
Resolved it via raising the version of v7 Support Libraries:
implementation 'com.android.support:appcompat-v7:28.0.0'
i have tried enough and getting the same issue as in screen shot and finally got success.
my code was like this..
so after searching enough i solved it by adding maven in my gradle file..
its solved then..
You should add this to build.gradle(module: app)
implementation 'com.android.support:support-vector-drawable:28.0.0'
I try many but only this decoration help me to sync the Gradle,
Hope this one help yours
repositories {
mavenLocal()
google()
jcenter()
}
And actually add this line to defaultConfig of app module :
vectorDrawables.useSupportLibrary = true

Failed to resolve: project :Library:materialDrawer

I am trying to add mikepenz's Material Drawer as third party project. The reason I want to add it as project (not by just compile as dependency) so that I can modify the drawer's UI as per my requirement. But I cannot sync my gradle successfully and getting the following error:
Failed to resolve:project :Library:materialDrawer
Here is my project structure:
-> root
->app
->Library
-> materialDrawer
-> app
-> build.gradle
-> settings.gradle
-> build.gradle(project)
-> settings.gradle
I tried to follow this project https://github.com/foragerr/android-multi-project-sample/blob/master/settings.gradle But in vein.
Here is my build.gradle(My project) file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
settings.gradle (My project)
include ':app', ':Library:materialDrawer'
build.gradle (app : My project)
apply plugin: 'com.android.application'
apply plugin: 'android'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.******"
minSdkVersion 15
targetSdkVersion 25
versionCode 38
versionName "2.1.8"
generatedDensities = []
}
dexOptions {
javaMaxHeapSize "4g"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
/*
compile('com.mikepenz:materialdrawer:5.6.0#aar') {
transitive = true
}
*/
compile project(':Library:materialDrawer')
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.ParkSangGwon:TedPermission:v1.0.12'
compile 'hanks.xyz:smallbang-library:0.1.2'
compile 'com.yalantis:ucrop:2.2.0'
compile 'com.github.clans:fab:1.6.4'
compile 'me.zhanghai.android.materialratingbar:library:1.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (Project : materialDrawer)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.novoda:bintray-release:0.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
My Android Studio is v2.3.3. I'm scratching my head but couldn't find any solution. Please someone help me I'm stuck with this for three days...
Since you are using:
compile project(':Library:materialDrawer')
gradle is looking for a build.gradle inside that module.
Checking your question, this file exists but it is a top-level file instead of a module file.
You should change structure in this way (you should not put the library folder inside another module)
-> root
->app
-> build.gradle
->Library
-> materialDrawer
-> app
-> build.gradle
-> build.gradle
-> settings.gradle
-> build.gradle(project)
-> settings.gradle
You have to change the settings.gradle with:
include ':app', ':materialDrawer'
project(':materialDrawer').projectDir = new File('/Library/materialDrawer/app')
Then as dependency use:
compile project(':materialDrawer')

What is the correct Way to integrate KSOAP library in Android Studio?

I am trying something like this,
In Gradle,
Inside Build Types,
repositories {
maven { url 'http://ksoap2-android.googleco/svde.cmomn/2-repo'
}
and in dependencies . . .
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
Error: Failed to resolve dependencies
Solution: inside build.gradle of a module (not project) write:
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
and inside Dependencies
implementation 'com.google.code.ksoap2-android:ksoap2-android:3.6.2'
in Android Studio, you have two build.gradle File:
My first file (Project):
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and my Second File (Module):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.asemansystem.com.caferc"
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'
}
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'
}
}
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.0-alpha7'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2'
testCompile 'junit:junit:4.12'
}
Goto to this link and download the jar file. Then add the downloaded jar file to your libs folder inside your app folder(Your Project->app->libs).
Then right click on the ksoap jar file and select "Add as Library".
Done.
EDIT : UPDATED THE LINK
this is mine in new versions of Android Studio:
in build.gradle (module):
dependencies {
...
implementation 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'
}
in settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
}
rootProject.name = "idt.pda"
include ':app'
Another way is:
1: Download the ksoap2-versionX.jar file from here.
2: Copy ksoap2-versionX.jar file to libs folder in your project.
3: Right click in the copied file in your project and select Add as library.
See:
http://ask.android-studio.org/?/question/188

Android studio gradle not recognise com.google.code.gson:gson:2.3.1

Developing app with Android studio using gradle. I have added this dependencies to it:
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
but it says :
Error:A problem occurred configuring project ':app'.
> Could not download gson.jar (com.google.code.gson:gson:2.3.1)
> Could not get resource 'https://jcenter.bintray.com/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar'.
> Could not GET 'https://jcenter.bintray.com/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar'.
> Connection to https://jcenter.bintray.com refused
Full source for my build.gradle files
Project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
App:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "domain.myapplication"
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.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
}
Define this in you gradle build script.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
...
}
}
allprojects {
repositories {
mavenCentral()
}
}
Call mavenCentral() in your build.gradle .
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
}
add maven repository to build.gradle
Failed to resolve: com.google.code.gson:gson:2.3.1

Categories

Resources