【问题标题】:Could not find method maven()找不到方法 maven()
【发布时间】:2018-12-31 19:05:50
【问题描述】:

我收到以下错误:

在 org.gradle.api.Project 类型的根项目“约会”上找不到参数 [build_3sdtqstdmsgdnexrxaaxgljji$_run_closure1$_closure4@325a800c] 的 maven() 方法。

这是我的项目级 Gradle 文件:

buildscript {

repositories {
    google()
    jcenter()
    maven { url "http://jcenter.bintray.com"}
    maven { url "https://maven.fabric.io/public" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.0'
    classpath 'io.fabric.tools:gradle:1.25.4'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
}
maven {
    url 'https://maven.google.com/'
}
}

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

这是我的应用级 Gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.gtaandteam.android.wellcure"
    minSdkVersion 19
    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'
    }
 }
}

repositories {
mavenCentral()
maven {
    url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'ai.devsupport.instamojo:instamojolib:0.1.6'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-crash:11.0.4'
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:design:24.2.0"
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'


}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

我已经尝试了其他帖子和解决方案网站中提到的所有技术,但我没有在这些网站中找到相同的错误。因此我在这里提出这个问题。

【问题讨论】:

  • maven{}之后写jcenter()
  • 你可能没有应用 maven 插件。 gradle.org/docs/current/userguide/maven_plugin.html
  • @Einzig7 我试过你告诉我的。我在这两个地方都写了 jcenter() 在 maven{} 之后。现在我收到错误找不到 io.fabric.tools:gradle:1.25.4。
  • 刷新你的 gradle 依赖?

标签: android maven android-gradle-plugin crashlytics firebase-crash-reporting


【解决方案1】:

您收到此错误是因为您的 maven 不应该是“allprojects”的直接子代,而是“repositories”的直接子代。

allprojects {
  repositories {
    google()
    jcenter()

    maven {
      url 'https://maven.google.com/'
    }
  }
}

【讨论】:

    猜你喜欢
    • 2015-05-22
    • 1970-01-01
    • 2012-01-07
    • 2019-04-20
    • 2021-02-14
    • 2019-05-27
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多