Building the Android mopub library successfully with the configuration outlined in the Getting Started documentation under the jcenter implementation.
build.gradle (project)
Included the jcenter and moat-sdk-builds libraries.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gralde (app)
Included the library mopub-sdk:5.4.1@aar.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.coinverse"
minSdkVersion 27
targetSdkVersion 28
versionCode 15
versionName "0.15"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".staging"
debuggable true
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding.enabled = true
}
dependencies {
def lifecycle_version = "2.0.0"
def paging_version = "2.0.0"
def nav_version = "1.0.0-alpha09"
def nav_testing_version = "1.0.0-alpha08"
def room_version = "2.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
implementation "androidx.paging:paging-runtime:$paging_version"
implementation "androidx.paging:paging-rxjava2:$paging_version"
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-firestore:17.1.5'
implementation 'com.google.firebase:firebase-functions:16.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.2.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'
implementation 'com.google.firebase:firebase-config:16.1.2'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.2'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.2'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation "androidx.room:room-guava:$room_version"
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
transitive = true
}
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "android.arch.navigation:navigation-testing:$nav_testing_version"
testImplementation "androidx.room:room-testing:$room_version"
testImplementation "android.arch.persistence.room:testing:$room_version"
}
Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit:2.4.5.
Searched in the following locations: file:/Users/adamhurwitz/Library/Android/sdk/extras/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom file:/Users/adamhurwitz/Library/Android/sdk/extras/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar file:/Users/adamhurwitz/Library/Android/sdk/extras/google/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom file:/Users/adamhurwitz/Library/Android/sdk/extras/google/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar file:/Users/adamhurwitz/Library/Android/sdk/extras/android/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom file:/Users/adamhurwitz/Library/Android/sdk/extras/android/m2repository/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar https://dl.google.com/dl/android/maven2/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom https://dl.google.com/dl/android/maven2/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar https://jcenter.bintray.com/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.pom https://jcenter.bintray.com/com/moat/analytics/mobile/mpub/moat-mobile-app-kit/2.4.5/moat-mobile-app-kit-2.4.5.jar
When transitive = true
is commented out in Gradle the app builds, runs, and the mopub library is present under the external libraries section.
Does transitive = true
need to be enabled? If so, how can I resolve the Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit error?
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
//transitive = true
}
Find the latest version of MoPub in the documentation here.
build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
...
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com/' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
build.gradle (app)
dependencies {
def mopub_version = '+@aar'
implementation("com.mopub:mopub-sdk-native-static:$mopub_version") { transitive = true }
implementation("com.mopub:mopub-sdk-native-video:$mopub_version") { transitive = true }
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.1.0.0'
implementation 'com.flurry.android:ads:11.4.0@aar'
implementation 'com.flurry.android:analytics:11.4.0@aar'
implementation 'com.mopub.mediation:flurry:11.4.0.0'
}
I've found the solution in the Twitter Community Forumn thanks to @wacamoe.
Step 1) In gradle-wrapper.properties, ensure you are using
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Step 2) Ensure that in your application’s gradle script, you have
maven { url “https://s3.amazonaws.com/moat-sdk-builds 26” }
in both the buildscript and allprojects sections.