错误:无法解决:: HERE-sdk:

时间:2017-08-01 10:24:33

标签: gradle

我正在尝试创建一个有两种风格的新项目,sdk独立于app。 所以我修改了这些build.gradle文件,如下所示:

对于android lib模块:sdk

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"

    defaultConfig {
        minSdkVersion 19
        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'
        }
    }
    productFlavors {
        en
        zh
    }
    publishNonDefault true
}


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'
    testCompile 'junit:junit:4.12'
    compile(name: 'HERE-sdk', ext: 'aar')
}

repositories {
    flatDir {//HERE SDK
        dirs 'libs'
    }
    mavenCentral()
}

对于Android应用模块:app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "cn.hudplay.testgradle"
        minSdkVersion 19
        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'
        }
    }
    productFlavors {
        en
        zh
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    enCompile project(path:":sdk",configuration:"enRelease")
    zhCompile project(path:":sdk",configuration:"zhRelease")
    //compile(name: 'HERE-sdk', ext: 'aar')//this seems to be workaround if un-blocked
}

repositories {
    flatDir {//HERE SDK
        dirs 'libs'
    }
    mavenCentral()
}

然后它告诉我Failed to resolve ::HERE-sdk:,没有其他原因......

我尝试将Here-sdk相关的gradle代码移到应用的build.gradle,没有错。但我确实需要sdk模块..

我该怎么办。任何人都可以帮助我?

暂时使用的解决方法:appsdk编译HERE-sdk,再没有错。但我还是觉得不对劲......

3 个答案:

答案 0 :(得分:1)

您好,这里更新了文档,可能会对您有所帮助。我也遇到了同样的问题,可以按照以下步骤解决:

https://github.com/heremaps/here-android-sdk-examples

答案 1 :(得分:0)

使用上面的代码作为示例(如果有人正在寻找有效的解决方案)对我有用的是这种方法:

将“ \ HERE-sdk \ libsHERE-sdk.aar”文件(从此处的帐户下载)复制到\ App \ libs文件夹,然后:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar','*.aar'])
    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'
    testCompile 'junit:junit:4.12'
    //compile(name: 'HERE-sdk', ext: 'aar')
}

注意:更改只有2行: 注释-> // compile(name:'HERE-sdk',ext:'aar')和ADDED->' .aar'扩展到此处的数组作用域->编译fileTree(dir:'libs',包括: [' .jar','*。aar'])。

OBS:我知道这是一个古老的问题,也许外面的某个人肯定已经回答了这个问题,但是我在这里留下我的谦虚的贡献。如果有人想雇用我,我正在找工作,呵呵

答案 2 :(得分:0)

通过从

添加来获得aar编译而没有错误
  

打开模块设置

Step 1,将aar添加到app / libs文件夹

Step 2,右键单击App,对Open Module Settings否定

enter image description here

Step 3,单击左侧的dependencies,然后单击+下的Declared Dependencies enter image description here

Step 4,从下拉列表中选择libs/HERE-sdk.aar,然后单击OK enter image description here