将地图库添加到android studio

时间:2018-08-27 12:02:29

标签: android

我要将新库添加到我的android项目中,我添加了此内容:

repositories {       
    maven { url "https://dl.bintray.com/neshan/neshan-android-sdk" }
}

和这个:

dependencies {
    implementation 'neshan-android-sdk:mobile-sdk:0.9.1'
} 

但同步gradle后出现错误:

Error:(32, 13) Failed to resolve: neshan-android-sdk:mobile-sdk:0.9.1

(我的targetSdkVersion是25)

有人知道我该如何解决吗?

4 个答案:

答案 0 :(得分:2)

您的库版本较旧,已从存储库中删除,  您应该使用较新版本的库 参见Neshan Map Document

NeshanMobileSDK的当前版本为 0.9.5

答案 1 :(得分:0)

检查依赖项,它应包含

group_name:artifactory_name:version_name

答案 2 :(得分:0)

项目级别build.gradle

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://dl.bintray.com/neshan/neshan-android-sdk" }
    }
}

应用build.gradle

dependencies {
    //Neshan sdk library
    implementation 'neshan-android-sdk:mobile-sdk:0.9.5'
}

答案 3 :(得分:0)

请记住,在build.gradle (Project: ***)中,repositories有两个区域。一个位于buildscript下,另一个位于allprojects下,您应该将Maven存储库放在allprojects区域中。您的build.gradle (Project: ***)应该如下所示:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        // Putting maven URL here, will be useless! Please scroll down 
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        // Right place for repository URL
        maven {
            url  "https://dl.bintray.com/neshan/neshan-android-sdk"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

并且要确保其他所有内容都到位,请将您的build.gradle (module:app)与我的进行比较:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.myapp.my"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a'
            universalApk false
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.google.android.material:material:1.1.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    //Neshan sdk library
    implementation 'neshan-android-sdk:mobile-sdk:0.9.5'
}