(Android) Error: Admob not found + not loading ads
(Android) Error: Admob not found + not loading ads
我遵循 https://github.com/appodeal/react-native-appodeal 上的简单 Android appodeal 安装指南。仔细检查手动安装部分,所有这些都已完成。当我 运行 Android 上的应用程序构建正常但在第一次加载时,我在底部收到一条小通知:"Error: Admob not found"。我设置了 onRewardedVideoLoaded
和 onRewardedVideoFailedToLoad
侦听器,它们在 iOS 上工作正常,但是,none return 在 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'
有什么想法吗?
您忘记在 build.gradle
中添加此依赖项:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
我遵循 https://github.com/appodeal/react-native-appodeal 上的简单 Android appodeal 安装指南。仔细检查手动安装部分,所有这些都已完成。当我 运行 Android 上的应用程序构建正常但在第一次加载时,我在底部收到一条小通知:"Error: Admob not found"。我设置了 onRewardedVideoLoaded
和 onRewardedVideoFailedToLoad
侦听器,它们在 iOS 上工作正常,但是,none return 在 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'
有什么想法吗?
您忘记在 build.gradle
中添加此依赖项:
implementation 'com.google.android.gms:play-services-ads:17.0.0'