androidfirebaseandroid-studiomopub

How to add Mopub ads in android studio


I am trying to integrate Mopub ads into my Android Studio project, but I am encountering an error when building the project. I have followed the instructions provided in the link (https://developers.mopub.com/publishers/android/integrate/#option-3-cloned-github-repository), but I am still unsure how to resolve the error. The error message is:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method implementation() for arguments [com.mopub:mopub-sdk:@aar, build_2jh7i72qxdht1wclzb0v2ink0$_run_closure1$_closure3$_closure5@13b54e85] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Here is my build.gradle file for reference:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        jcenter()
        google()
        maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'
        implementation('com.mopub:mopub-sdk:@aar') {
            transitive = true
        }
        // NOTE: Do not place your application dependencies here; they belon
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
       
    }
}

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

Solution

  • The implementation('com.mopub:mopub-sdk:5.13.1@aar') goes into your app's (not project's) build.gradle.