Mopub Android 设置:'Could not find moat-mobile-app-kit'
Mopub Android Setup: 'Could not find moat-mobile-app-kit'
预计
使用 Getting Started documentation under the jcenter 实施中概述的配置成功构建 Android mopub 库。
设置
build.gradle(项目)
包括 jcenter 和 moat-sdk-builds 库。
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(应用程序)
包含库 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
尝试的解决方案
当 transitive = true
在 Gradle 中被注释掉时,应用程序构建、运行,并且 mopub 库出现在外部库部分下。
是否需要启用transitive = true
?如果是这样,我该如何解决 Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit 错误?
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
//transitive = true
}
最新 MoPub 版本已修复问题
在文档中查找最新版本的 MoPub here。
build.gradle(项目)
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(应用程序)
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'
}
已弃用的解决方案
感谢@wacamoe,我在 Twitter Community Forumn 中找到了解决方案。
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.
根据 Mopub 的官方文档,不推荐使用。
上面写的很清楚-
To add the mopub-sdk dependency, open your project and update the app module’s build.gradle.
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
它明确提到在模块级别添加依赖而不是项目级别。
有关如何添加的更多信息,请查看 link here
类似的问题讨论建议更新到最新版本,目前是5.8,推荐。- Check here
我尝试按照推荐的步骤将 MoPub sdk 更新到最新版本,并且构建成功。
我的模块等级gradle如下
apply plugin: 'com.android.application'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
flatDir {
dirs 'libs-aar'
}
}
dependencies {
//MoPub
implementation('com.mopub:mopub-sdk:5.9.0@aar') {
transitive = true
// exclude module: 'moat-mobile-app-kit' // To exclude Moat
}
implementation 'com.google.ads.mediation:mopub:5.8.0.0'
}
注意:我评论了 exclude 模块语句只是为了表明它在不使用 exclude 语句的情况下工作,否则我已将其从我的 gradle 文件中删除。
预计
使用 Getting Started documentation under the jcenter 实施中概述的配置成功构建 Android mopub 库。
设置
build.gradle(项目)
包括 jcenter 和 moat-sdk-builds 库。
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(应用程序)
包含库 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
尝试的解决方案
当 transitive = true
在 Gradle 中被注释掉时,应用程序构建、运行,并且 mopub 库出现在外部库部分下。
是否需要启用transitive = true
?如果是这样,我该如何解决 Could not find com.moat.analytics.mobile.mpub:moat-mobile-app-kit 错误?
implementation('com.mopub:mopub-sdk:5.4.1@aar') {
//transitive = true
}
最新 MoPub 版本已修复问题
在文档中查找最新版本的 MoPub here。
build.gradle(项目)
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(应用程序)
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'
}
已弃用的解决方案
感谢@wacamoe,我在 Twitter Community Forumn 中找到了解决方案。
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.
根据 Mopub 的官方文档,不推荐使用。
上面写的很清楚-
To add the mopub-sdk dependency, open your project and update the app module’s build.gradle.
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
它明确提到在模块级别添加依赖而不是项目级别。
有关如何添加的更多信息,请查看 link here
类似的问题讨论建议更新到最新版本,目前是5.8,推荐。- Check here
我尝试按照推荐的步骤将 MoPub sdk 更新到最新版本,并且构建成功。
我的模块等级gradle如下
apply plugin: 'com.android.application'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
flatDir {
dirs 'libs-aar'
}
}
dependencies {
//MoPub
implementation('com.mopub:mopub-sdk:5.9.0@aar') {
transitive = true
// exclude module: 'moat-mobile-app-kit' // To exclude Moat
}
implementation 'com.google.ads.mediation:mopub:5.8.0.0'
}
注意:我评论了 exclude 模块语句只是为了表明它在不使用 exclude 语句的情况下工作,否则我已将其从我的 gradle 文件中删除。