Gradle 同步失败:找不到参数的方法 compile()



我指的是将 mopub 集成到我的应用程序中的 https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started。在项目的build.gradle文件中添加mopub-sdk依赖项时,我收到错误"找不到参数的方法编译"。请帮帮我。Build.gradle 文件:

    buildscript {
    repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    }}
    allprojects {

    repositories {
    jcenter()
}
dependencies {
    compile('com.mopub:mopub-sdk:4.14.0@aar') {
        transitive = true
    }
    // For banners
    compile('com.mopub:mopub-sdk-banner:4.14.0@aar') {
        transitive = true
    }
    // For interstitials
    compile('com.mopub:mopub-sdk-interstitial:4.14.0@aar') {
        transitive = true
    }
    // For rewarded videos. This will automatically also include 
      interstitials
    compile('com.mopub:mopub-sdk-rewardedvideo:4.14.0@aar') {
        transitive = true
    }
    // For native static (images).
    compile('com.mopub:mopub-sdk-native-static:4.14.0@aar') {
        transitive = true
    }
    // For native video. This will automatically also include native static
    compile('com.mopub:mopub-sdk-native-video:4.14.0@aar') 
    {transitive = true}
    }
    }
    task clean(type: Delete) {
    delete rootProject.buildDir
   }

实际错误:-

Error:(31, 0) Could not find method compile() for arguments [com.mopub:mopub-sdk:4.14.0@aar, build_7edkg2m28hxg79jomt8w3j8ic$_run_closure1$_closure4$_closure5@1c36532] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
您需要

将依赖项放在其他build.gradle中。它们属于单个模块build.gradle文件。

此外,您还将导入 com.mopub:mopub-sdk:4.14.0@aar ,其中包含您在 Gradle 文件中已有的所有广告格式依赖项。您只需要com.mopub:mopub-sdk:4.14.0@aar模块化工件。

相关内容

  • 没有找到相关文章

最新更新