每当我运行implementation()方法时,我都会得到一个错误。
我试图导入这个Insiteo '.aar‘文件并设置它的依赖项,但是调用'implementation()’方法出现了问题。帮助?
Insiteo模块build.gradle:
configurations.maybeCreate("default")
artifacts.add("default", file('Insiteo-SDK-3.6.3g.aar'))
dependencies {
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
错误是这样的
Error:(6, 0) Could not find method implementation() for arguments ['com.squareup.retrofit:retrofit:2.0.0-beta2']
应用模块build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
apply plugin: 'com.android.library'
defaultConfig {
applicationId "com.example.joey.projectgenesis"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
implementation project(':Insiteo')
}
Project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的Android插件版本是3.0.1,我的Gradle版本是4.4.1
我也尝试过compile()
,但也出现了同样的错误。
其他build.gradle
脚本没有任何问题,只有Insiteo模块脚本有问题,只有implementation()
方法有问题。
发布于 2018-01-19 04:09:16
AFAIK,您不能像那样向aar模块添加依赖项。您很可能需要应用应用程序或库插件才能做到这一点。
但通常只需将依赖项直接添加到项目中,而不是库模块中。示例:
Root /
app/
myAarLibrary/
不要在myAarLibrary
中定义依赖项,而是在app
中定义它们
发布于 2018-01-19 13:28:54
你的gradle有点问题。您可以在gradle依赖项中使用compile
代替implelentaion
。默认情况下,所有gradle都支持此功能。
发布于 2018-01-19 20:23:12
app
级别build.gradle
应该如下所示://顶级构建文件,可以添加所有子项目/模块通用的配置选项。buildscript { repositories { google() jcenter() }依赖项{ classpath 'com.android.tools.build:gradle:3.0.1‘//注意:不要将应用程序依赖项放在这里;它们属于//在单独的模块build.gradle文件中}}所有项目{存储库{ google() jcenter() }}任务清理(类型:删除){删除rootProject.buildDir }
gradle-wrapper.properties
如下所示:#DATE distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip =包装器/dists zipStorePath=包装器/dists distributionBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
使用
implementation 'com.squareup.retrofit:retrofit:2.3.0'
implementation 'com.squareup.retrofit:adapter-rxjava:2.3.0'
implementation 'com.squareup.retrofit:converter-gson:2.3.0'
而不是
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
https://stackoverflow.com/questions/48329281
复制相似问题