(Android)错误:找不到Admob +无法加载广告

时间:2018-10-14 10:44:22

标签: android react-native appodeal

我遵循了https://github.com/appodeal/react-native-appodeal上的简单Android appodeal安装指南。仔细检查了手动安装部分,所有步骤均已完成。当我在Android上运行该应用程序时,一切正常,但在第一次加载时,在底部显示一条小提示:“错误:未找到Admob”。我设置了onRewardedVideoLoadedonRewardedVideoFailedToLoad侦听器,这些侦听器在iOS上运行良好,但是,它们都没有在Android上返回任何内容,因此广告根本就不会加载。

这是我的/build.gradle

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

ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28

googlePlayServicesVersion = "15.0.1"
googleSupportLibraryVersion = "28.0.0"
}

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
        android {
            compileSdkVersion rootProject.ext.compileSdkVersion
            buildToolsVersion rootProject.ext.buildToolsVersion
        }
    }
}
}

buildscript {
repositories {
    google()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'

    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
}
}

allprojects {
repositories {
    mavenLocal()
    google()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
}

task wrapper(type: Wrapper) {
gradleVersion = '4.6'
distributionUrl = distributionUrl.replace("bin", "all")
}

这是我的/app/build.gradle

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://jcenter.bintray.com' }
    maven { url  "https://adcolony.bintray.com/AdColony" }
}

import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js",
nodeExecutableAndArgs: ["/Users/Ilyakar/.nvm/versions/node/v10.1.0/bin/node"]
]

apply from: "../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
*   - An APK that only works on ARM devices
*   - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "org.biggo.einee"
        minSdkVersion 16
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 75
        versionName "1.4"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
    }
    signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
dexOptions {
    jumboMode true
    preDexLibraries = false
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation project(':react-native-branch')
    implementation project(':react-native-share')
    implementation project(':react-native-amplitude-analytics')
    implementation project(':react-native-rate')
    implementation project(':react-native-fabric')
    implementation project(':react-native-firebase')
    implementation project(':react-native-sound')
    implementation project(':react-native-iap')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-mail')
    implementation project(':react-native-blur')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-appodeal')

    // React native
    implementation "com.facebook.react:react-native:+"  // From node_modules

    // Gif support
    implementation "com.android.support:appcompat-v7:28.0.0"
    implementation 'com.facebook.fresco:animated-gif:1.3.0'

    // Firebase dependencies
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-analytics:16.0.3'
    implementation 'com.google.firebase:firebase-messaging:17.3.3'

    // Fabric dependencies
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5@aar'

    // Amplitude analytics
    implementation 'com.amplitude:android-sdk:2.19.1'

    // Extra
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
}
}

// Run this once to be able to run the application with BUCK
// puts all implementation dependencies into folder libs for BUCK to 
use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services'

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您忘记在您的build.gradle中添加此依赖项:

implementation 'com.google.android.gms:play-services-ads:17.0.0'