invertase / react-native-google-mobile-ads

React Native Google Mobile Ads enables you to monetize your app with AdMob.
https://docs.page/invertase/react-native-google-mobile-ads
Other
673 stars 135 forks source link

App Crashes with react-native-google-mobile-ads 13.6.0 #598

Closed CraigMarc closed 1 month ago

CraigMarc commented 3 months ago

What happened?

I am using react-native-google-mobile-ads 13.6.0 and my app is crashing when it starts ever since i have installed the library. I am not using expo.

Platforms

Android, but have not tested behavior on iOS

React Native Info

info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.22631
  CPU: (4) x64 Intel(R) Core(TM) i3-1005G1 CPU @ 1.20GHz
  Memory: 4.31 GB / 11.75 GB
Binaries:
  Node:
    version: 20.12.2
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-233.14808.21.2331.11709847
  Visual Studio: Not Found
Languages:
  Java: 17.0.10
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0
    wanted: 0.73.0
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Are your using Typescript?

package.json

{
  "name": "gymtimerAds1256",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@sayem314/react-native-keep-awake": "^1.2.3",
    "react": "18.2.0",
    "react-native": "0.73.0",
    "react-native-google-mobile-ads": "^13.6.0",
    "react-native-sound": "^0.11.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "^0.73.18",
    "@react-native/eslint-config": "^0.73.1",
    "@react-native/metro-config": "^0.73.2",
    "@react-native/typescript-config": "^0.73.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

app.json

{
  "name": "gymtimerAds1256",
  "displayName": "gymtimerAds1256",
  "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-3866044541725967~8626697260",
    "ios_app_id": "ca-app-pub-3866044541725967~8626697260"  }
}

ios/Podfile

No response

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    allprojects {
        repositories {
            google()
            mavenCentral()
        }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    }
}

apply plugin: "com.facebook.react.rootproject"

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

android {
    ndkVersion rootProject.ext.ndkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace "com.gymtimerads1256"
    defaultConfig {
        applicationId "com.gymtimerads1256"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation("com.facebook.react:flipper-integration")
    implementation('com.google.android.gms:play-services-ads:22.2.0')
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/settings.gradle

No response

AndroidManifest.xml

<application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
        <meta-data
            android:name="com.google.android.gms.ads.gymtimerAds1256"
            android:value="ca-app-pub-3866044541725967~8626697260"/>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>
CraigMarc commented 3 months ago

Here is part of my log:

07-02 21:21:10.732 13673 13673 W View : requestLayout() improperly called by android.widget.FrameLayout{61062ff V.E...... ......ID 0,0-1080,525 #7f0b0fee app:id/googleapp_discover_header_container} during layout: running second layout pass 07-02 21:21:13.026 561 611 W BatteryExternalStatsWorker: error reading Bluetooth stats: 9 07-02 21:21:13.035 561 2464 D TelephonyManager: requestModemActivityInfo: Sending result to app: ModemActivityInfo{ mTimestamp=14400059 mSleepTimeMs=0 mIdleTimeMs=14399986 mActivityStatsTechSpecificInfo=[{mRat=UNKNOWN,mFrequencyRange=UNKNOWN,mTxTimeMs[]=[0, 0, 0, 0, 0],mRxTimeMs=0}]} 07-02 21:21:13.403 821 904 D EGL_emulation: app_time_stats: avg=13336.41ms min=13336.41ms max=13336.41ms count=1 07-02 21:21:13.405 821 821 D StatusBarIconController: ignoring old pipeline callbacks, because the new mobile icons are enabled 07-02 21:21:19.472 561 604 E ActivityManager: Timeout waiting for provider com.google.android.gms/10123 for provider com.google.android.gsf.gservices caller=ProcessRecord{8bf152c 13580:com.google.android.gms/u0a123} 07-02 21:21:19.472 561 604 E ActivityManager: Timeout waiting for provider com.google.android.gms/10123 for provider com.google.android.gsf.gservices caller=ProcessRecord{8d2efaa 13673:com.google.android.googlequicksearchbox:search/u0a124} 07-02 21:21:19.472 13673 13702 E ActivityThread: Failed to find provider info for com.google.android.gsf.gservices 07-02 21:21:19.478 13580 13580 E ActivityThread: Failed to find provider info for com.google.android.gsf.gservices 07-02 21:21:19.541 13580 13580 W ProviderHelper: Unknown dynamite feature providerinstaller.dynamite 07-02 21:21:19.544 13580 13580 I DynamiteModule: Considering local module com.google.android.gms.providerinstaller.dynamite:1 and remote module com.google.android.gms.providerinstaller.dynamite:0 07-02 21:21:19.545 13580 13580 I DynamiteModule: Selected local version of com.google.android.gms.providerinstaller.dynamite 07-02 21:21:19.551 13580 13580 V NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 295 native methods... 07-02 21:21:19.567 13580 13580 I ProviderInstaller: Installed default security provider GmsCore_OpenSSL 07-02 21:21:19.603 13580 13763 I Watchcat: Started 07-02 21:21:19.610 13580 13580 I cuir : Primes not initialized, returning default (no-op) Primes instance which will ignore all calls. Please call Primes.initialize(...) before using any Primes API. 07-02 21:21:19.613 561 2464 I ActivityManager: Flag disabled. Ignoring finishAttachApplication from uid: 10123. pid: 13580 07-02 21:21:19.618 13580 13763 I GMS_MM_Logger: Start time: 240801 07-02 21:21:19.619 13580 13763 I GMS_MM_Logger: Started. 07-02 21:21:19.745 561 604 E ActivityManager: Timeout waiting for provider com.google.android.gms/10123 for provider com.google.android.gsf.gservices caller=ProcessRecord{8bf152c 13580:com.google.android.gms/u0a123} 07-02 21:21:19.748 561 604 E ActivityManager: Timeout waiting for provider com.google.android.gms/10123 for provider com.google.android.gsf.gservices caller=ProcessRecord{8d2efaa 13673:com.google.android.googlequicksearchbox:search/u0a124} 07-02 21:21:19.751 13580 13580 E ActivityThread: Failed to find provider info for com.google.android.gsf.gservices 07-02 21:21:19.754 13673 13708 E ActivityThread: Failed to find provider info for com.google.android.gsf.gservices

CraigMarc commented 3 months ago

I was going to delete this issue my only problem was that I was trying to run this on an emulator and it only seems to work on a real device it would cause my emulator to crash every time but works fine with my phone.

github-actions[bot] commented 2 months ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.