apptentive / apptentive-react-native

Apptentive SDK module for React Native

Home Page:https://learn.apptentive.com/article-categories/react-native/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App crashes on android on reaction to dialog box or notes

Ayat11 opened this issue · comments

We are having issues with apptentive on android device after migrating to androidx, we have the latest version 5.4.5, the app is crashing with the following error:

java.lang.RuntimeException:` Unable to destroy activity
{com.appid/com.apptentive.android.sdk.ApptentiveViewActivity}: 
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean 
androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference

Hey @Ayat11,

Sorry for the issue. What SDK version do you use?

Sorry, I can see it in a description

Would you be able to provide the contents of your package.json and build.gradle files (both app and project level)?

@weeeBox
package.json

{
  "name": "MyApp",
  "version": "2.9.28",
  "private": true,
  "scripts": {
    "prepare": "patch-package",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "test:watch": "npm test -- --watch",
    "lint": "eslint . --ext .tsx",
    "postversion": "react-native-version",
    "postinstall": "npx jetify"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.2",
    "@react-native-community/netinfo": "^4.6.0",
    "@types/react-native-permissions": "^1.1.1",
    "accordion-collapse-react-native": "^0.1.11",
    "amplitude-js": "5.6.0",
    "apptentive-react-native": "^5.4.5",
    "bugsnag-react-native": "^2.23.1",
    "jwt-decode": "^2.2.0",
    "patch-package": "^6.2.0",
    "postinstall-postinstall": "^2.0.0",
    "pusher-js": "^5.0.1",
    "react": "16.9.0",
    "react-native": "0.61.4",
    "react-native-appsflyer": "^1.4.5",
    "react-native-camera": "^3.9.0",
    "react-native-cookies": "joeferraro/react-native-cookies",
    "react-native-device-info": "^5.2.1",
    "react-native-elements": "^1.2.0",
    "react-native-firebase": "^5.5.6",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-icon-badge": "^1.1.3",
    "react-native-permissions": "^1.2.0",
    "react-native-reanimated": "^1.4.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "^7.4.3",
    "react-navigation": "^4.0.10",
    "react-navigation-drawer": "^2.3.3",
    "react-redux": "^7.1.3",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "url": "^0.11.0"
  },
  "devDependencies": {
    "@babel/core": "7.7.2",
    "@babel/runtime": "7.7.2",
    "@types/amplitude-js": "^4.4.4",
    "@types/enzyme": "^3.10.3",
    "@types/jest": "^24.0.22",
    "@types/react": "^16.9.5",
    "@types/react-native": "^0.60.22",
    "@types/react-redux": "^7.1.4",
    "@types/react-test-renderer": "16.9.0",
    "@types/redux-mock-store": "^1.0.1",
    "@typescript-eslint/eslint-plugin": "^1.13.0",
    "@typescript-eslint/parser": "^1.13.0",
    "babel-eslint": "^10.0.2",
    "babel-jest": "24.9.0",
    "enzyme": "^3.10.0",
    "enzyme-adapter-react-16": "^1.15.0",
    "enzyme-react-16-adapter-setup": "^0.1.0",
    "enzyme-to-json": "^3.4.0",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.16.0",
    "jest": "24.9.0",
    "jest-enzyme": "^7.1.1",
    "metro-react-native-babel-preset": "0.57.0",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "16.11.0",
    "react-native-typescript-transformer": "^1.2.12",
    "react-native-version": "^3.2.0",
    "react-test-renderer": "16.11.0",
    "redux-mock-store": "^1.5.3",
    "ts-jest": "^24.1.0",
    "typescript": "^3.7.2"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "transform": {
      "^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
      "\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|@react-native-community/async-storage|react-native-button|@react-navigation/.*|react-native-reanimated|react-native-webview|react-native-elements|react-native-status-bar-height|react-native-vector-icons|react-native-ratings|react-native-gesture-handler|react-native-screens|react-navigation|react-native-safe-area-view|react-native-cookies|react-native-icon-badge|react-native-push-notification|accordion-collapse-react-native|react-native-appsflyer|apptentive-react-native)/)"
    ],
    "testEnvironment": "jsdom",
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "testPathIgnorePatterns": [
      "\\.snap$",
      "<rootDir>/node_modules/"
    ],
    "cacheDirectory": ".jest/cache",
    "setupFiles": [
      "./jestSetup.js"
    ]
  }
}

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 = true


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.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 25967583
        versionName "2.9.28"
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    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
            }
        }
    }
    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.
            // EDITED BY FR: signingConfig signingConfigs.debug
            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:
            // 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
            }

        }
    }
}

dependencies {
    implementation project(':react-native-cookies')
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/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)
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.bugsnag.android.gradle'

android/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
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
        classpath("com.google.gms:google-services:4.2.0")
        classpath("com.bugsnag:bugsnag-android-gradle-plugin:4.+")

        // 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()
        maven { url 'https://jitpack.io' }
    }
}

Thanks!

Hey @Ayat11, we were able to reproduce the issue: seems like one of your app dependencies is not compatible with Apptentive SDK. We'll get back to you once we identify the problem. Thanks for your patience!

@weeeBox any updates on this issue?

Hey @Ayat11,

We have migrated our SDK to AndroidX and now preparing a release. Should be available tomorrow. Thanks for your patience!

Hey @Ayat11,

We have found an issue while testing the new SDK. This might delay the release. Sorry for the inconvenience.

Hey @weeeBox
Thanks for getting back to me, how long delay are we talking? we currently cannot do any releases because of this issue, that we are considering removing apptentive in order to be able to do a release. Could you give me an estimate please?

@Ayat11 I'll work with @weeeBox to get an answer for you.

Would you mind sharing which app you're working on so I can coordinate with your account's Customer Success Manager as well? If you'd rather, feel free to email us the details at support@apptentive.com.

Thanks again.

@Ayat11, we have released native Android SDK today. React Native extension should go live tomorrow.

@Ayat11, the issue is now fixed in 5.5.0