Mopub-sdk does not build

android

#1

I added ‘:mopub-android-sdk:mopub-sdk’ to my project’s settings.gradle but when I try to build the project it says:

Error:(8, 0) Plugin with id 'org.robolectric' not found.

…in mopub-android-sdk/mopub-sdk/build.gradle.

I copy/pasted the “buildscript” block from mopub-android-sdk/build.gradle at the top of mopub-android-sdk/mopub-sdk/build.gradle and now it builds:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
    }
}

Not sure what the proper fix is. No idea why mopub-android-sdk/build.gradle exists.


#2

Hello Aderalxnu,

The imported folder should just be the folder mopub-sdk and not mopub-android-sdk/mopub-sdk. The mopub-sdk folder should be in the same directory level as your app’s folder.

In Android Studio navigate to your project’s settings.gradle file and include the MoPub SDK as a module as shown below. You may need to sync Gradle again in Android Studio to have the ‘mopub-sdk’ show up in the left Project window.

include ':app', ':mopub-sdk'

Open your app’s build.gradle file and add the MoPub SDK as a dependency:

dependencies {
   compile project(':mopub-sdk')
}

Let me know if this fixes your issue. If not, we can troubleshoot further.

Thanks!


#3

I have the same problem and tried the suggested fix. It did not work.

What works is reverting to MoPub 3.7.0 with a git submodule of mopub-android-sdk (with subdir mopub-sdk) and using :mopub-android-sdk:mopub-sdk in Gradle.

MoPub 3.9.0 no longer works that way, nor does it work copying mopub-sdk subdir to become a top-level dir. Followed @ekinbenho’s instructions which match https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started#adding-as-source-recommended


#4

Hey talklittle,

I believe this issue may be dependent on a specific setup. I was able to get MoPub SDK 3.9 set up in Android Studio 1.2.2 with no issues with mopub-sdk being one of the top level directories in the project on the same level as my app directory.

Could you provide more information on how you are setup (IDE, plugins, adapters, project hierarchy), so that we may reproduce? Please also provide information on the versions of the MoPub SDKs and IDE you are seeing this issue on.

Thanks!


#5

@ekinbenho Thanks for the reply. I’m assuming your test project uses Robolectric already, and that’s why MoPub 3.9.0 works with it.

Of course adding the classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0' to my project’s build.gradle fixes the problem, as @aderalxnu has already indicated. But I’d rather not have to add that extra Robolectric dependency.


#6

I just noticed on https://github.com/robolectric/robolectric-gradle-plugin that the Robolectric Gradle plugin is deprecated as of Robolectric 3.0.

@ekinbenho Will MoPub be migrating from Robolectric 2.4 to 3.0, and therefore remove the need for apply plugin: 'org.robolectric' which is causing this build issue?


#7

Hey Talklittle,

I have escalated the request for an update to Robolectric 3.0 to the team.

Let us know if you have any questions or experience any other issues here.

Thanks!


#8

I have the same problem could you help me.

Error:(8, 0) Plugin with id ‘org.robolectric’ not found.


#9

Hey AyYoGames,

In your Project’s build.gradle file, please add the following line to your dependencies. This should be the top level build.gradle file.

classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'

It should look like the below, similar to aderalxnu’s post above.

dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
}

Let us know if this fixes your issue.

Thanks!


#10

It worked.

Thanks