Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not recognize the device in the dashboard when install the signed apk in device. #547

Closed
amirmahdinezhad opened this issue Jun 7, 2018 · 24 comments

Comments

@amirmahdinezhad
Copy link

Description:

When i generate signed apk and install on device , it does not recognize the device in the dashboard. But in debugger environment, recognizes the device and show in dashboard and it's not a problem.

Environment

"react-native-onesignal": "^3.2.4"
"react-native-navigation": "^1.1.469"
compileSdkVersion : 26
buildToolsVersion :  "26.0.2"
compile 'com.android.support:appcompat-v7:26.0.1'```
using yarn 


**Steps to Reproduce Issue:**

  1. Install the OneSignal SDK using yarn in my project
  2. Initialize the SDK in the  app/build.gradle az example project
  3. Attempt to receive a push notification

app/build.gradle : 
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 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",
 *
 *   // 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"
]

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 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "**********"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
   
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    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 {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.facebook.react:react-native:+'
    compile project(':react-native-navigation')
    compile project(':react-native-onesignal')
}

// 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'
}

and android/build.gradle : 
buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { 
           
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/' 
            name 'Google' 
    }
}

@Nightsd01
Copy link
Contributor

@amir-m7 For issues where the device doesn't register with OneSignal, that will generally display an error in logcat.

Can you please copy + paste your logcat for at least 10 seconds after opening your app?

@amirmahdinezhad
Copy link
Author

amirmahdinezhad commented Jun 8, 2018

@Nightsd01
adb server is out of date. killing...
adb I 3913 415648 usb_osx.cpp:259] Found vid=04e8 pid=6860 serial=ce031713fb1cb8970c
adb I 3913 415648 usb_osx.cpp:259]

  • daemon started successfully *
    --------- beginning of crash
    --------- beginning of main
    --------- beginning of system
    06-08 16:26:47.859 28778 28778 D ReactNative: ReactInstanceManager.ctor()
    06-08 16:26:48.034 28778 28778 W ReactNative: ======================================
    06-08 16:26:48.034 28778 28778 W ReactNative:
    06-08 16:26:48.034 28778 28778 W ReactNative: Overlay permissions needs to be granted in order for react native apps to run in dev mode
    06-08 16:26:48.034 28778 28778 W ReactNative:
    06-08 16:26:48.034 28778 28778 W ReactNative:
    06-08 16:26:48.034 28778 28778 W ReactNative: ======================================
    06-08 16:26:59.206 28778 28778 D ReactNative: ReactInstanceManager.createReactContextInBackground()
    06-08 16:26:59.207 28778 28778 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
    06-08 16:26:59.438 28778 28778 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
    06-08 16:26:59.439 28778 28778 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
    06-08 16:26:59.439 28778 28778 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
    06-08 16:26:59.455 28778 29801 D ReactNative: ReactInstanceManager.createReactContext()
    06-08 16:26:59.640 28778 29801 D ReactNative: Initializing React XplatBridge.
    06-08 16:26:59.643 28778 29801 D ReactNative: Initializing React XplatBridge before initializeBridge
    06-08 16:26:59.651 28778 29801 D ReactNative: Initializing React XplatBridge after initializeBridge
    06-08 16:26:59.651 28778 29801 D ReactNative: CatalystInstanceImpl.runJSBundle()
    06-08 16:26:59.652 28778 29829 D ReactNative: ReactInstanceManager.setupReactContext()
    06-08 16:26:59.652 28778 29829 D ReactNative: CatalystInstanceImpl.initialize()
    06-08 16:27:00.319 28778 28778 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
    06-08 16:27:00.329 28778 29827 I ReactNativeJS: Running application "A" with appParams: {"initialProps":{"screenInstanceID":"screenInstanceID2","navigatorID":"navigatorID1_nav","navigatorEventID":"screenInstanceID2_events"},"rootTag":1}. DEV === true, development-level warning are ON, performance optimizations are OFF
    06-08 16:27:37.284 28778 28778 D ReactNative: ReactInstanceManager.onReloadWithJSDebugger()
    06-08 16:27:37.286 28778 28778 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
    06-08 16:27:37.286 28778 28778 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
    06-08 16:27:37.286 28778 28778 D ReactNative: ReactInstanceManager.tearDownReactContext()
    06-08 16:27:37.293 28778 28778 D ReactNative: CatalystInstanceImpl.destroy() start
    06-08 16:27:37.338 28778 30420 D ReactNative: CatalystInstanceImpl.destroy() end

@Nightsd01
Copy link
Contributor

@amir-m7 unfortunately that doesn’t really help. Can you set the OneSignal log level to verbose?

@amirmahdinezhad
Copy link
Author

@Nightsd01
I don't know how to do this.
can i send my sample project for you?

@jkasten2
Copy link
Member

jkasten2 commented Jun 9, 2018

@amir-m7 You will need to call OneSignal.setLogLevel(6, 0); to enable this. We just added this to our docs and a link on how to get the log too
https://documentation.onesignal.com/docs/react-native-sdk#section-debugging

@Nightsd01
Copy link
Contributor

Nightsd01 commented Jun 9, 2018

@amir-m7 apologies that setLogLevel was not documented earlier but @jkasten2 added it.

Once you call OneSignal.setLogLevel(6, 0) we will likely be able to see what the issue is in your logcat. Please run the app for ~30 seconds and post your output

@amirmahdinezhad
Copy link
Author

@Nightsd01
Copy link
Contributor

Nightsd01 commented Jun 9, 2018

@amir-m7 This is a bit confusing. Are you saying your app is crashing?

Unfortunately, your test app includes OneSignal in the name so it is impossible to dig through all 500+ log statements to look for any errors specific to our SDK. Can you try renaming your app to something else and post a new logcat?

If you're getting a crash, it's related to this, which wouldn't be related to our SDK:

06-09 11:27:02.714 28641-28736/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
    Process: com.notification, PID: 28641
    java.lang.RuntimeException: com.facebook.react.bridge.JavaJSExecutor$ProxyExecutorException: java.lang.IllegalStateException: WebSocket connection no longer valid
        at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
        at com.facebook.react.devsupport.DevSupportManagerImpl.handleException(DevSupportManagerImpl.java:289)
        at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:511)
        at com.facebook.react.bridge.CatalystInstanceImpl.access$900(CatalystInstanceImpl.java:39)
        at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:527)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
        at android.os.Looper.loop(Looper.java:211)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: com.facebook.react.bridge.JavaJSExecutor$ProxyExecutorException: java.lang.IllegalStateException: WebSocket connection no longer valid
        at com.facebook.react.devsupport.WebsocketJavaScriptExecutor.executeJSCall(WebsocketJavaScriptExecutor.java:182)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:211) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
        at java.lang.Thread.run(Thread.java:818) 
     Caused by: java.lang.IllegalStateException: WebSocket connection no longer valid
        at com.facebook.react.devsupport.JSDebuggerWebSocketClient.sendMessage(JSDebuggerWebSocketClient.java:148)
        at com.facebook.react.devsupport.JSDebuggerWebSocketClient.executeJSCall(JSDebuggerWebSocketClient.java:129)
        at com.facebook.react.devsupport.WebsocketJavaScriptExecutor.executeJSCall(WebsocketJavaScriptExecutor.java:175)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
        at android.os.Looper.loop(Looper.java:211) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
        at java.lang.Thread.run(Thread.java:818) 

@amirmahdinezhad
Copy link
Author

@Nightsd01 my app name is notification.my app is not crashing.in debugging recognize my device in dashboard.when generate the signed apk and install it does not recognize in dashboard.

@Nightsd01
Copy link
Contributor

Nightsd01 commented Jun 9, 2018

When you say the device is "not recognized", what do you mean? You mean that the device is not getting registered at all and doesn't show up in the dashboard?

When I look in your logs, I do see this:

06-09 11:35:55.945 31170-31582/com.notification V/OneSignal: OneSignalRestClient: After con.getResponseCode  to: https://onesignal.com/api/v1/players/b17a6e78-9086-4626-b808-2b414c5b1c65/on_session
06-09 11:35:55.945 31170-31582/com.notification D/OneSignal: OneSignalRestClient: Successfully finished request to: https://onesignal.com/api/v1/players/b17a6e78-9086-4626-b808-2b414c5b1c65/on_session
06-09 11:35:55.947 31170-31582/com.notification D/OneSignal: POST RECEIVED JSON: {"success":true}
06-09 11:35:55.949 31170-31595/com.notification I/OneSignal: session sent, UserId = b17a6e78-9086-4626-b808-2b414c5b1c65

That means that the device has a OneSignal User ID, which means it registered successfully. Since the device is getting registered with OneSignal, that means it should definitely show up in the dashboard.

@amirmahdinezhad
Copy link
Author

@Nightsd01
when i connect the device to mac os with cable and write react-native run-android in terminal and open app in device automatically, my device registered in dashboard.but when i disconnect the device and generate the signed apk with cd android && ./gradlew assemblerelease ,and install app on device does not registered in dashboard.i send apk to another android device, they are not registered in dashboard too

@phantom1299
Copy link

phantom1299 commented Jun 10, 2018

Hi, I'm facing this issue too, both on ios and android, where sometimes the device gets listed in the dashboard and sometimes not, plus when teh device gets registered the tags are not send most of the time, i call sendTags but again I can't see the tags being send in the dashboard.

I called OneSignal.setLogLevel(6, 0) and let the app run on android emulator for 30 seconds. Then I run
adb logcat -b all -d -v threadtime > onesignal_crash_logcat.txt
to get the logs. Found this in the logs
onesignal: Unable to initialize the OneSignal SDK because activity is null true or oneSignalInitDonefalse

Couldn't get more info out of that.
Full logs:
onesignal_crash_logcat.txt

Edit:

Seems like this is related with react-native-navigation #516
Gonna try initialization on native side and report back

@Nightsd01
Copy link
Contributor

@amir-m7 @phantom1299

This does seem to be an incompatibility issue with the react-native-navigation dependency. Please do try using native initialization and let me know how it goes.

@amirmahdinezhad
Copy link
Author

@Nightsd01
i create new sample project without react-native-navigation, generate signed apk and install it on device, my device register in dashboard.It looks like it's having trouble using react-native-navigation.

@phantom1299
Copy link

I can't seem to get it working, native initialization didn't help and I can't find any logs about it

@Nightsd01
Copy link
Contributor

Nightsd01 commented Jun 12, 2018

@amir-m7 @phantom1299 Can you please copy + paste your MainApplication.java?

In the getPackages() method, are you sure you're returning new ReactNativeOneSignalPackage()?

The installation instructions for react-native-navigation advise you to replace a lot of code in MainApplication.java, so some developers mistakenly remove our SDK as a package here.

https://documentation.onesignal.com/v5.0/docs/react-native-sdk-setup#section-android-specific-instructions

@phantom1299
Copy link

I'm returning the package:

package com.APP_NAME;

import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import com.reactnative.photoview.PhotoViewPackage;
import cl.json.RNSharePackage;
import com.oblador.keychain.KeychainPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends NavigationApplication {

  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new VectorIconsPackage(),
        new ReactNativeOneSignalPackage(),
        new PickerPackage(),
        new PhotoViewPackage(),
        new RNSharePackage(),
        new KeychainPackage()
      );
  }

  @Override
  public String getJSMainModuleName() {
    return "index";
  }

  @Override
  public boolean isDebug() {
    return BuildConfig.DEBUG;
  }

  @Override
  public List<ReactPackage> createAdditionalReactPackages() {
    return getPackages();
  }

  public String getFileProviderAuthority() {
    return "com.example.com.APP_NAME.provider";
  }
}

@amirmahdinezhad
Copy link
Author

amirmahdinezhad commented Jun 12, 2018

@Nightsd01


import android.app.Application;

import com.facebook.react.ReactApplication;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

import com.reactnativenavigation.NavigationApplication;

public class MainApplication extends NavigationApplication {

  @Override
  public boolean isDebug() {
    // Make sure you are using BuildConfig from your own application
    return BuildConfig.DEBUG;
  }

  protected List<ReactPackage> getPackages() {
    // Add additional packages you require here
    // No need to add RnnPackage and MainReactPackage
    return Arrays.<ReactPackage>asList(
      new ReactNativeOneSignalPackage()
    );
  }

  @Override
  public List<ReactPackage> createAdditionalReactPackages() {
    return getPackages();
  }

  @Override
  public String getJSMainModuleName() {
    return "index";
  }
}

@Nightsd01
Copy link
Contributor

@amir-m7 Yeah, I have created a project using react-native-navigation with react-native-onesignal and it works fine, I cannot reproduce your issue.

Would it be possible for you to upload a sample project that reproduces this issue? If you want to send us your full project that works as well, but don't post it publicly, contact OneSignal support (on our dashboard website click the ? button) and link them to this git issue.

@amirmahdinezhad
Copy link
Author

@Nightsd01
can you send sample project for me without App Id ?

@Nightsd01
Copy link
Contributor

@amir-m7 I am not sure what you mean....?

I was asking you to send us an example project where you are able to reproduce this issue

@amirmahdinezhad
Copy link
Author

@Nightsd01
How to send my project to you?
I sent the message support on dashboard and sent this issue 2 days ago, but they have not yet responded to me.

@Nightsd01
Copy link
Contributor

Nightsd01 commented Jun 21, 2018

@amir-m7 I found an issue that is likely causing this issue, fixed it in #572 It will be available in a new release either today or tomorrow

@Nightsd01
Copy link
Contributor

The particular issue that caused this problem in Amir-M7's case should now be resolved in 3.2.5.

If anyone else encounters this issue going forward, please comment here and I'll be happy to help investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants