How to add mopub ad library integration with android studio

I am trying to add a MoPub SDK to my application. I am trying to import and add a library in Android Studio, but I do not see any ads in my application.

I used Eclipse to add the library natively, but I am trying Android Studio because now it is a new tool supported by Google.

How to add MoPub SDK to my application using Android Studio?

+4
android android-studio mopub ads
source share
5 answers

Perhaps the Android studio was updated, I could not solve it in accordance with the answer of abaar or pyus13.

This answer is based on Android Studio 0.6.1.

  • mopub-sdk.zip you downloaded

  • Open project structure (File → Project Structure) in Android Studio

  • Click the "+" button in the upper left corner to add a new module

  • You can see the new wizzard module, select "Import an existing project" and click "Next"

  • Select the mopub-sdk folder that you just unzipped

  • Click "Next" and complete. Now you can see that Android Studio imports mopub-sdk into your project. And settings.gradle file is added to your project

  • Open settings.gradle and add the line include ':'

  • Open the build.gradle file of your project, add the compile project('mopubsdk') in the dependency record (mopubsdk is the name of the project you just added)

  • Open the project structure again, you can see the mopubsdk module on the left, click on it, then select the Dependencies tab at the top, change the com.android.support:support-v4:+ area from Compile to Provided

That's it. This works for me.

+4
source share

I could not get pyus13 answer to work, so this is how I did it in gradle. Put the mopub-sdk folder in your projects folder, which should be at the same level as your gradle folder. Put this build.gradle in your mopub-sdk

 apply plugin: 'android-library' android { compileSdkVersion 19 buildToolsVersion '19.0.1' sourceSets { main { java.srcDirs = ['src/main/java'] res.srcDirs = ['res'] manifest.srcFile 'AndroidManifest.xml' } } } dependencies { compile 'com.android.support:support-v4:19.0.0' // compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar') //not relevant anymore compile files('libs/MMSDK.jar') } 

then add compile project(':libraries:mopub-sdk') depending on your build.gradle level at your application level and include ':app', ":libraries:mopub-sdk" to your .gradle settings at a level higher than this.

The aforementioned build.gradle is for the complete package, which includes multimedia and admob. Millenial media may not work because the android studio does not seem to recognize the definition of video glider activity in my Android manifest. admob is working fine, but you might run into a conflict if you have google play services in your application since admob is now added. If you have one of these problems, download the simple mopub package and lose the lines of the compilation files.

EDIT: integrate the Google Play services as stated in the github quiz, then add google admob banner.java and inserstitial.java to your own mopub src directory next to yours.

+3
source share

You can integrate it by simply editing 2 files as shown in their REATME README for GitHub :

build.gradle () ---- Project one add jcenter () inside the repositories

 repositories { jcenter() } 

build.gradle () ---- Module 1 add the following dependencie

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' ........ compile('com.mopub:mopub-sdk: 4.3.0@aar ') { transitive = true } } 

Synchronize / rebuild the project, and you're done!

+3
source share

Steps to add Mopub or any library project as a jar / maven dependency in Android Studio (0.4.3) :

1 .. First, find out if this is any central maven repository available for your library if there is no need to download anything on your local computer. For example, actionbarsherlock is available on maven, so you just need to add this to your module build.gradle file in the dependency section.

  compile 'com.actionbarsherlock:actionbarsherlock: 4.4.0@aar ' 

You can search and add the maven dependency on File>Project Structure > Modules > Dependency Tab > "+" Sign > Maven Dependency or search.maven.org.

2. If it is not available as a maven dependency (for example, in the case of mopub), you need to download the entire library project to your local computer. Since mopub uses maven and there is no gradle project repository available. The process is a bit panic.

First you need to create the jar file of your mopub SDK using Ant / Maven (I saw that the library has no resources, only java code, so the jar will work).

Now create a directory in the directory of the main module and name it libs (same as in eclipse) and copy the mopub jar here.

Go to File > Project Structure or right-click on the project and go to Open Module Settings and select "Modules in the window that opens."

Now select the module for which you want to add a dependency from the left pane, and click the Dependency tab in the right pane.

Press the Green button + key , place the window on the right on the dependencies in the vertical panel and select "File Dependency"

It will show your libs directory in the windows with your jar, select the jar and click "OK".

Doing this will simply add this line to the build.gradle assembly file depending on the dependencies so you can check.

  compile files(libs/yourmopublib.jar) 

You can achieve the same by adding this line manually to the build.gradle file, I would like to add it manually.

Sync your project with Gradle.

Done!

Note. Things are subject to change for future releases.

+1
source share

Currently, I believe that the easiest way to integrate mopub with AS is to use fabric .

0
source share

All Articles