简体   繁体   中英

Integrating moPub into Android Studio

I'm trying to integrate the moPub sdk into my android studio project, but I haven't been able to get the gradle to sync properly. This question has been asked here before, but none of those solutions have worked for me. I followed these instructions, but got the error messages "Plugin with id org.roboelectric not found" and "Unable to load class org.codehaus.groovy.runtime.typehandling.ShortTypeHandling". To fix this, I modified my app's build.gradle with new classpaths:

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
        classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
        classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'

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

allprojects {
    repositories {
        jcenter()
    }
}

Unfortunately, I still get the error message "Error:(1, 0) Cause: org/codehaus/groovy/runtime/StringGroovyMethods". I've tried using version 1.0.1 of gradle but nothing changed. I'm not sure where to go from here, so any help would be greatly appreciated.

Read the comment in that build.gradle file.

From this answer https://stackoverflow.com/a/23241888/2278598

<PROJECT_ROOT>\\app\\build.gradle is specific for app module.

<PROJECT_ROOT>\\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.

You need to put the dependencies you are adding in the <PROJECT_ROOT>\\app\\build.gradle

You have configured Robolectric correctly in the top level gradle file.

You need to use a later version of gradle to build using the Groovy plugin. I would use classpath 'com.android.tools.build:gradle:1.2.3'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM