我是一个Android/Java新手,遇到了一个我想编译的项目:
https://github.com/maxamillion32/Android-Firebase-mapping
它有点老了,也许这就是它给我带来问题的原因。
我得到的第一个错误是我下载的Build Tools 24.0.1。现在我得到以下错误,我无法解决:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method implementation() for arguments [com.google.android:support-v4:r7] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我已经在"文件">"项目结构"中检查了我的依赖项,并在那里找到了com.google.android:support-v4:r7。
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.6.3'
classpath 'com.google.gms:google-services:4.3.3'
// 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
}
build.gradle(应用程序(
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.mimming.hacks.starter"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:23.4.0'
implementation 'com.google.android.gms:play-services:9.6.1'
testImplementation 'junit:junit:4.12'
// compile 'com.firebase:firebase-client-android:2.5.2+'
apply plugin: 'com.google.gms.google-services'
implementation 'com.google.firebase:firebase-database:9.6.1'
}
有什么想法吗?非常感谢。
使用的渐变版本似乎是较低版本,为了使用implementation
渐变版本应该高于3
- 您应该将build.gradle中的依赖项替换为最新版本
classpath 'com.android.tools.build:gradle:3.6.3'
- 此外,您还必须升级
distributionUrl
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip
正如您已经提到的,您已经更新了buildToolsVersion,这应该可以正常工作,并确保所有依赖项都使用implementation
而不是compile
,因为不赞成使用compile。