javaandroidmopubchartboost

Integrating Chartboost with MoPub


I'm having trouble with the integration steps from MoPub:

  1. Integrating using the SDK Source
    • I added ChartboostInterstitial.java and ChartboostShared.java to \app\src\main\java\com\mopub\mobileads\
  2. Link the third party SDKs
    • I added chartboost.jar to app\libs
    • I added compile files('libs/chartboost.jar') under dependencies
    • I followed Chartboost's integration steps up to the point of adding my appID and appSignature (Step 7)

At this point I'm confused because I already input my appID and appSignature into MoPub's dashboard. I removed Chartboost.startWithAppId(this, appId, appSignature); and only kept onCreate but MoPub's ChartboostInterstitial class is still being marked as unused. This doesn't seem right.

Any ideas? MoPub's documentation in this area seems unclear.


Solution

  • Steps you need to do:

    1. Integrate MoPub as instructed in this document
    2. Implement your MoPub Interstitial display logic according to this document
      At this point, you should be able to display MoPub Interstitial. But as you want to mediate Chartboost, you need to do extra steps following.
    3. Add ChartboostInterstitial.java and ChartboostShared.java to your project's app/src/main/java/com/mopub/mobileads/
    4. Add Chartboost SDK to libs/ and add play-services-ads:8.4.0 as dependencies. Download the Chartboost SDK jar here.
      You don't need to import or call any Chartboost SDK class/method in your code.
    5. Fill in Chartboost App ID and App Signature in MoPub's dashboard and set up a Interstitial Ad Unit which mediates Chartboost. Use this Ad Unit in your app to show Interstitial!

    Check that you have added all libraries needed, all Activity and required permissions declared in AndroidManifest.xml.

    AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    
    <application>
        <activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
        <activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
        <activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
        <activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
        <activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
    
        <activity android:name="com.chartboost.sdk.CBImpressionActivity"
               android:excludeFromRecents="true"
               android:hardwareAccelerated="true"
               android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
               android:configChanges="keyboardHidden|orientation|screenSize" />
    
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
    </application>
    

    If you use Gradle, your build.gradle dependencies should probrably look like this:

    dependencies {
        // ... other project dependencies
    
        // Compile the chartboost.jar in libs/
        compile fileTree(dir: 'libs', include: ['*.jar']
        // Google Play Services
        compile 'com.google.android.gms:play-services-ads:8.4.0
        //MoPub
        compile('com.mopub:mopub-sdk:4.12.0@aar') {
            transitive = true
        }
        compile('com.mopub:mopub-sdk-interstitial:4.12.0@aar') {
            transitive = true
        }
        compile 'com.mopub.volley:mopub-volley:1.1.0'
    
        compile 'com.android.support:support-v4:22.0.+'
        compile 'com.android.support:support-annotations:22.0.+'
        compile 'com.android.support:recyclerview-v7:22.0.+'
    }