React-native-onesignal: Crash with RN0.60 on any Android

Created on 23 Sep 2019  ·  43Comments  ·  Source: OneSignal/react-native-onesignal

Description:

(your description here)

Environment

System:
    OS: macOS 10.14.6
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 6.63 GB / 32.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.1 - ~/.nvm/versions/node/v10.16.1/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 23, 25, 27, 28, 29
      Build Tools: 25.0.2, 25.0.3, 28.0.3, 29.0.1, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A419c - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.5 => 0.60.5
[email protected]

On Android app start my app is crashing without any messages or windows.

adb logcat:

09-23 17:06:37.900 8388 8388 D AndroidRuntime: Shutting down VM
09-23 17:06:37.901 8388 8388 E AndroidRuntime: FATAL EXCEPTION: main
09-23 17:06:37.901 8388 8388 E AndroidRuntime: Process: com.macroactive, PID: 8388
09-23 17:06:37.901 8388 8388 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread.-wrap1(ActivityThread.java)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.macroactive-2/base.apk"],nativeLibraryDirectories=[/data/app/com.macroactive-2/lib/arm, /data/app/com.macroactive-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: ... 12 more
09-23 17:06:37.901 8388 8388 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.internal.zzbq
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
09-23 17:06:37.901 8388 8388 E AndroidRuntime: ... 13 more
09-23 17:06:37.901 8388 8388 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Cannot reproduce it on fresh app so perhaps it's related to any libraries. Found some issues with "com/google/android/gms/common/internal/zzbq" but cannot find any useful.
Tell me where to start?

Help Wanted

Most helpful comment

same error in react-native 0.60.5 , using [email protected]

All 43 comments

Similarly, my app is also crashing on getting notification on android. I tested it on mi note 4 (android 7.0, RN 0.60.3, react-native-onesignal 3.3.3).

@SAHITYASAI Could you show adb logcat?

Screenshot_2019-09-22-17-55-21-844_com miui bugreport
This is the runtime error im getting whenever app crashes.

same error in react-native 0.60.5 , using [email protected]

Can you make sure you have added the onesignal-gradle-plugin to the top of your app/build.gradle noted in step 1.1?
https://documentation.onesignal.com/docs/android-sdk-setup#section-1-gradle-setup

Missing this or adding it to the wrong build.gradle is the most common issue for this runtime error.

The beginning of my app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

apply plugin: "com.android.application"

import com.android.build.OutputFile

btw, I used before only

apply plugin: "com.onesignal.androidsdk.onesignal-gradle-plugin"

for react-native 0.59 & react-native-onesignal: 3.2.12

I added everything as described in the installation guide. But the line apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' is causing my app build to fail with this error

  • What went wrong: A problem occurred configuring root project ''. >Could not get unknown property 'android' for root project '' of type org.gradle.api.Project."

so that i commented that line as i could not find any solution on google.
Also can someone give me any example code on how to send scheduled notifications using onesignal REST API. Thanks in advance.

Can you make sure you have added the onesignal-gradle-plugin to the top of your app/build.gradle noted in step 1.1?
https://documentation.onesignal.com/docs/android-sdk-setup#section-1-gradle-setup

Missing this or adding it to the wrong build.gradle is the most common issue for this runtime error.

Yes added and the same error happens

The beginning of my app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

apply plugin: "com.android.application"

import com.android.build.OutputFile

the way i see it! you are doing it wrong! its not all for the app/build.gradle file the apply plugin goes only there and rest of the class path , maven url and gradle plugin repo url goes in the project build.gradle

@indapublic i just solved it ! i had the same bug! thankyou for posting this.! if you are still looking i am open to help reach me out at!

Hello,
Please upgrade to the latest version of the plugin (3.4.1) and try again.

@SAHITYASAI take a look here

@indapublic i just solved it ! i had the same bug! thankyou for posting this.! if you are still looking i am open to help reach me out at!

Thanks, Solved!!

Inside de Project Folder "app/build.gradle" added this in top of file.

buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: "com.android.application"

import com.android.build.OutputFile

it Works!

Great to hear!

@indapublic i just solved it ! i had the same bug! thankyou for posting this.! if you are still looking i am open to help reach me out at!

Show me your build.gradle

@indapublic i just solved it ! i had the same bug! thankyou for posting this.! if you are still looking i am open to help reach me out at!

Show me your build.gradle

buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
    *
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
    *
  • // the entry file for bundle generation
  • entryFile: "index.android.js",
    *
  • // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
  • bundleCommand: "ram-bundle",
    *
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
    *
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
    *
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
    *
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
    *
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
    *
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
    *
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
    *
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
    *
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
    *
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

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

/**

  • The preferred build flavor of JavaScriptCore.
    *
  • 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:+'

/**

  • Whether to enable the Hermes VM.
    *
  • This should be set on project.ext.react and mirrored here. If it is not set
  • on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  • and the benefits of using Hermes will therefore be sharply reduced.
    */
    def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.yourappid"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    missingDimensionStrategy 'react-native-camera', 'general'
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
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://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// 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:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        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
        }

    }
}

packagingOptions {
    pickFirst '**/armeabi-v7a/libc++_shared.so'
    pickFirst '**/x86/libc++_shared.so'
    pickFirst '**/arm64-v8a/libc++_shared.so'
    pickFirst '**/x86_64/libc++_shared.so'
    pickFirst '**/x86/libjsc.so'
    pickFirst '**/armeabi-v7a/libjsc.so'
}

}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules

if (enableHermes) {
  def hermesPath = "../../node_modules/hermesvm/android/";
  debugImplementation files(hermesPath + "hermes-debug.aar")
  releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
  implementation jscFlavor
}

}

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

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

Thanks, @lucasferreiraestevam. Btw, you can format this code as source for better reading.
Anyway I didn't see much difference with your example. But thank you again

Work for me after adding all libraries again for fresh project. Thank to all

My issue is not fixed yet. i'm still getting the same runtime error. Can someone help me please.

@SAHITYASAI show your build.gradle

android/build.gradle :-

buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" googlePlayServicesVersion: "15.0.0" firebaseVersion: "15.0.0" } repositories { google() jcenter() mavenLocal() maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal } dependencies { classpath("com.android.tools.build:gradle:3.4.1") classpath 'com.google.gms:google-services:4.3.2' classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.5, 0.99.99]' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() } } apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

android/app/build.gradle :-

apply plugin: "com.android.application" import com.android.build.OutputFile project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false def jscFlavor = 'org.webkit:android-jsc:+' def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.tutelage" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 3 versionName "1.2" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { storeFile file(MYAPP_RELEASE_STORE_FILE) storePassword MYAPP_RELEASE_STORE_PASSWORD keyAlias MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD } } } buildTypes { debug { signingConfig signingConfigs.debug } release { signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } applicationVariants.all { variant -> variant.outputs.each { output -> def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 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 } } } packagingOptions { pickFirst '**/armeabi-v7a/libc++_shared.so' pickFirst '**/x86/libc++_shared.so' pickFirst '**/arm64-v8a/libc++_shared.so' pickFirst '**/x86_64/libc++_shared.so' pickFirst '**/x86/libjsc.so' pickFirst '**/armeabi-v7a/libjsc.so' } } dependencies { implementation project(':react-native-onesignal') compile project(':react-native-admob') implementation "com.google.android.gms:play-services-base:17.0.0" implementation ('com.google.android.gms:play-services-ads:18.1.1') { force = true; } implementation 'com.google.firebase:firebase-analytics:17.2.0' implementation 'com.google.firebase:firebase-auth:18.1.0' implementation 'com.google.firebase:firebase-firestore:20.2.0' implementation 'com.google.firebase:firebase-ads:18.1.1' implementation project(':@react-native-community_netinfo') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" // implementation "com.google.android.gms:play-services-ads-lite:[18.1.1]" if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply plugin: 'com.google.gms.google-services'

@SAHITYASAI According to documentation you should move this code

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

to app/build.gradle. Move it to beginning of file

And reformat your code please

same issue here
`BUILD FAILED in 3s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:validateSigningDebug'.

    Keystore file 'E:\React Native\push notification\react-native-onesignal\examples\RNOneSignal\android\app\debug.keystore' not found for signing config 'debug'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s

at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (E:\React Native\push notification\react-native-onesignal\examples\RNOneSignal\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (E:\React Native\push notification\react-native-onesignal\examples\RNOneSignal\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at then.result (E:\React Native\push notification\react-native-onesignal\examples\RNOneSignal\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)`

I have it working with latest react-native-onesignal package! and RN 0.60.5

here is my project/build.gradle

Screenshot 2019-10-04 at 8 01 09 PM

Here is mine project/app/build.gradle file

Screenshot 2019-10-04 at 8 01 37 PM

STEPS TOOK TO USE IT are

yarn add react-native-onesignal

then for ios
simply
cd ios && pod install

for andorid

simply

react-native run-android it auto links the package

@waqaramjad You issue is related to code signing

Keystore file 'E:\React Native\push notification\react-native-onesignal\examples\RNOneSignal\android\app\debug.keystore' not found for signing config 'debug'.

@indapublic so what's the solution for that ?

@waqaramjad Show your android/app/build.gradle, signingConfigs section

@indapublic here is android/app/build.gradle
`// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

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

    google()
    jcenter()
}

}
`

@waqaramjad What RN version you have?

"0.60.5"

Did you update existing app or create new one?

i just clone existing app example which is in one signal repo and just start it

@waqaramjad You should say this first :)

First: you printed android/build.gradle, not android/app/build.gradle

Second: you should generate debug and release keystores regarding to this manual, for example

btw: I saw that you using Windows, so probably you should use some stuff for keytool launching, I don't have experience with Windows.

but why i need keystore because i don't want signed apk , i only want to test it

while here is the code for android/app/build.gradle

`apply plugin: "com.android.application"

import com.android.build.OutputFile

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
    *
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
    *
  • // the entry file for bundle generation
  • entryFile: "index.android.js",
    *
  • // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
  • bundleCommand: "ram-bundle",
    *
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
    *
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
    *
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
    *
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
    *
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
    *
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
    *
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
    *
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
    *
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
    *
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
    *
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

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

/**

  • The preferred build flavor of JavaScriptCore.
    *
  • 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:+'

/**

  • Whether to enable the Hermes VM.
    *
  • This should be set on project.ext.react and mirrored here. If it is not set
  • on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  • and the benefits of using Hermes will therefore be sharply reduced.
    */
    def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.rnonesignal"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
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://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// 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:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        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
        }

    }
}

packagingOptions {
    pickFirst '**/armeabi-v7a/libc++_shared.so'
    pickFirst '**/x86/libc++_shared.so'
    pickFirst '**/arm64-v8a/libc++_shared.so'
    pickFirst '**/x86_64/libc++_shared.so'
    pickFirst '**/x86/libjsc.so'
    pickFirst '**/armeabi-v7a/libjsc.so'
}

}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules

if (enableHermes) {
  def hermesPath = "../../node_modules/hermesvm/android/";
  debugImplementation files(hermesPath + "hermes-debug.aar")
  releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
  implementation jscFlavor
}

}

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

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

But you want install it for your device, isn't it?
Sign config is here

@indapublic thank you, my app is building successfully now. But i need to send notification to only those users who are inactive for 15 continuous days only programatically without using the onesignal notification dashboard. Can anyone help me please.

I think you should create new issue for this, isn't it?

@SAHITYASAI ,
Please reach out to our support channel at OneSignal.com for further assistance. Cheers

Was this page helpful?
0 / 5 - 0 ratings