我试图创建一个有两种风格的新项目,sdk独立于app。所以我修改了这些build.gradle文件,如下所示:
用于android模块: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()
}安卓应用程序模块: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代码移到app的build.gradle中,不再需要sdk模块中的wrong.But。
我应该do..Anyone能帮我什么?
临时使用的解决方法:为app和sdk编译这里-sdk,不再有错误了。但我还是觉得有些东西不在那里..。
发布于 2018-06-27 10:11:43
嗨,这里更新了文档,也许能帮你解决这个问题。我也遇到了同样的问题,下面的步骤解决了这个问题:
发布于 2019-09-13 00:35:44
使用上面的代码作为示例(如果有人寻找一个可行的解决方案)对我起作用的是这样的方法:
将"\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行:注释-> // -> (名称:' here -sdk',ext:'aar'),并将-> '.aar‘扩展添加到数组范围->-> fileTree(dir:'libs',include:[’..jar‘,'*.aar'])。
我知道这是个老生常谈的问题,也许这个外面的世界里的人已经回答了这个问题,但是我把我的微薄贡献留在这里。如果有人想雇用我,我在找一份工作
发布于 2019-12-09 22:23:56
通过将aar编译添加到
打开模块设置
Step 1,将aar添加到app/libs文件夹中。
Step 2,右击App,Open Module Settings为阴性

Step 3,单击左边的dependencies,然后单击Declared Dependencies下的+

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

https://stackoverflow.com/questions/45435277
复制相似问题