question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SOLVED - Android ANR - HeapTaskDaemon - Broadcast of Intent - INSTALL_REFERRER AppMeasurementInstallReferrerReceiver

See original GitHub issue

React Native version:

System: OS: macOS High Sierra 10.13.6 CPU: (4) x64 Intel® Core™ i7-2640M CPU @ 2.80GHz Memory: 2.89 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.11.3 - /usr/local/bin/node npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: ^16.8.6 => 16.8.6 react-native: ^0.60.5 => 0.60.5 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1

Describe what you expected to happen:

We’ve started a React Native

The first version of the app is finally ready and we published it onto the Play Store.

I’ve found that on app start up we get ANRs.It happens on App Start and only on Signed Released Builds

I’ve included the main and blocked stack traces. I can included all if needed

"main" prio=5 tid=1 Waiting
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x73782400 self=0x7ebb6c0a00
  | sysTid=31013 nice=-10 cgrp=default sched=0/0 handle=0x7ec0dad9c8
  | state=S schedstat=( 323778862 16297043 589 ) utm=15 stm=16 core=7 HZ=100
  | stack=0x7ff8db1000-0x7ff8db3000 stackSize=8MB
  | held mutexes=
  at java.lang.Object.wait (Native method)
- waiting on <0x0cfce672> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:2135)
- locked <0x0cfce672> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:358)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:868)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued (AbstractQueuedSynchronizer.java:900)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire (AbstractQueuedSynchronizer.java:1223)
  at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock (ReentrantReadWriteLock.java:950)
  at com.facebook.soloader.SoLoader.doLoadLibraryBySoName (SoLoader.java:702)
  at com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:591)
- locked <0x04110ac3> (a java.lang.Object)
  at com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:539)
  at com.facebook.soloader.DirectorySoSource.loadDependencies (DirectorySoSource.java:103)
  at com.facebook.soloader.DirectorySoSource.loadLibraryFrom (DirectorySoSource.java:73)
  at com.facebook.soloader.UnpackingSoSource.loadLibrary (UnpackingSoSource.java:465)
- locked <0x025b2f40> (a java.lang.Object)
  at com.facebook.soloader.SoLoader.doLoadLibraryBySoName (SoLoader.java:681)
  at com.facebook.soloader.SoLoader.loadLibraryBySoName (SoLoader.java:591)
- locked <0x04b8ce79> (a java.lang.Object)
  at com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:529)
  at com.facebook.soloader.SoLoader.loadLibrary (SoLoader.java:484)
  at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory (ReactInstanceManagerBuilder.java:304)
  at com.facebook.react.ReactInstanceManagerBuilder.build (ReactInstanceManagerBuilder.java:279)
  at com.facebook.react.ReactNativeHost.createReactInstanceManager (ReactNativeHost.java:88)
  at com.facebook.react.ReactNativeHost.getReactInstanceManager (ReactNativeHost.java:41)
  at com.facebook.react.ReactActivityDelegate.loadApp (ReactActivityDelegate.java:91)
  at com.facebook.react.ReactActivityDelegate.onCreate (ReactActivityDelegate.java:80)
  at com.facebook.react.ReactActivity.onCreate (ReactActivity.java:52)
  at android.app.Activity.performCreate (Activity.java:7183)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1220)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2908)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3030)
  at android.app.ActivityThread.-wrap11 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6938)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
.
.
.

"HeapTaskDaemon" daemon prio=5 tid=7 Blocked
  | group="system" sCount=1 dsCount=0 flags=1 obj=0x15507a18 self=0x70daafc400
  | sysTid=19561 nice=4 cgrp=default sched=0/0 handle=0x70c12b84f0
  | state=S schedstat=( 16292575 10057040 15 ) utm=1 stm=0 core=4 HZ=100
  | stack=0x70c11b6000-0x70c11b8000 stackSize=1037KB
  | held mutexes=
  #00  pc 000000000001dfac  /system/lib64/libc.so (syscall+28)
  #01  pc 00000000000e2afc  /system/lib64/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+156)
  #02  pc 000000000024dfa0  /system/lib64/libart.so (_ZN3art2gc13TaskProcessor7GetTaskEPNS_6ThreadE+304)
  #03  pc 000000000024e90c  /system/lib64/libart.so (_ZN3art2gc13TaskProcessor11RunAllTasksEPNS_6ThreadE+92)
  #04  pc 000000000020c8ac  /system/framework/arm64/boot-core-libart.oat (Java_dalvik_system_VMRuntime_runHeapTasks__+124)
  at dalvik.system.VMRuntime.runHeapTasks (Native method)
- waiting to lock an unknown object
  at java.lang.Daemons$HeapTaskDaemon.runInternal (Daemons.java:461)
  at java.lang.Daemons$Daemon.run (Daemons.java:103)
  at java.lang.Thread.run (Thread.java:764)

app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.google.firebase.firebase-perf"
apply plugin: 'io.fabric'

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",

    enableHermes: true,
    hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
    // Sometimes (like if you use Android API<17) adb forwards don't work, so you need a bundle in the dev APK
    bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,
]

def enableHermes = project.ext.react.get("enableHermes", true)
def jscFlavor = 'org.webkit:android-jsc:+'

//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 rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        pickFirst '**/libc++_shared.so'
        //pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }

    defaultConfig {
        applicationId "package"
        minSdkVersion 21// rootProject.ext.minSdkVersion
        targetSdkVersion 28//rootProject.ext.targetSdkVersion
        versionCode 11
        versionName "1.1.8"

        // Needed to support API<21, though there is a small chance proguard shrinks things sufficiently
        multiDexEnabled true
    }
    signingConfigs {
       
    }


    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        debug {
            debuggable true
         
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }


    flavorDimensions  "client"
    productFlavors {
        flavour1 {
            dimension "client"
            minSdkVersion 21
            
        }
        flavour2 {
            dimension "client"
            minSdkVersion 21

        }
    }


    // 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, "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 {

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

    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-vector-icons')
    //implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    /* ----------------------------
    *    REACT NATIVE FIREBASE
    * ---------------------------- */

    // Library as defined in settings.gradle
    implementation project(path: ':react-native-firebase')

    // Required dependencies
    //noinspection GradleCompatible
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.android.gms:play-services-base:16.1.0"

    /* -------------------------
    *   OPTIONAL FIREBASE SDKS
    * ------------------------- */

    implementation('com.google.firebase:firebase-ads:15.0.1') {
      // exclude `customtabs` as the support lib version is out of date
      // we manually add it as a dependency below with a custom version
      exclude group: 'com.android.support', module: 'customtabs'
    }

    // Authentication
    implementation "com.google.firebase:firebase-auth:19.0.0"
    // Analytics
    implementation "com.google.firebase:firebase-analytics:17.1.0"
    // Performance Monitoring
    implementation "com.google.firebase:firebase-perf:19.0.0"
    // Remote Config
    implementation "com.google.firebase:firebase-config:19.0.0"
    // Cloud Storage
    implementation "com.google.firebase:firebase-storage:19.0.0"
    // Dynamic Links
    implementation "com.google.firebase:firebase-dynamic-links:19.0.0"
    // Real-time Database
    implementation "com.google.firebase:firebase-database:19.0.0"
    // Cloud Functions
    implementation "com.google.firebase:firebase-functions:19.0.0"
    // Cloud Firestore
    implementation "com.google.firebase:firebase-firestore:21.0.0"
    // Cloud Messaging / FCM
    implementation "com.google.firebase:firebase-messaging:20.0.0"

    // Firebase IID
    implementation "com.google.firebase:firebase-iid:20.0.0"

    // Crashlytics
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true
    }

    /* --------------------------------
    *  OPTIONAL SUPPORT LIBS
    * -------------------------------- */

    // Needed to support API<21, though there is a small chance proguard shrinks things sufficiently
    implementation 'androidx.multidex:multidex:2.0.0'

    // For Firebase Ads
    //noinspection GradleCompatible
    implementation 'androidx.browser:browser:1.0.0'

    // For React Native Firebase Notifications
    implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
}

// 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 plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="package"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <application
        android:hardwareAccelerated="true"
        android:usesCleartextTraffic="true"
        android:name=".MainApplication"
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher"
        android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
        <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
      </service>
        <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
    </application>

</manifest>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
BharathMG-ShareChatcommented, Mar 31, 2020

Using APK is not possible for us.

This issue happens for us. AAB fails always. Why was it closed?

1reaction
LzazSportscommented, Sep 30, 2019

@yashlinmaistry same error with .aab file . when i use .apk version it works fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

ANRs - Android Developers
An ANR is triggered for your app when one of the following conditions occur: ... Broadcast of intent: If a BroadcastReceiver hasn't finished ......
Read more >
ANR with blocked HeapTaskDaemon thread - Stack Overflow
On recent versions of Android, garbage collection(GC) generally runs on a background thread named HeapTaskDaemon.
Read more >
Deep dive into Android ANR | OkCredit - Medium
The goal of this blog post is to discuss our learnings about ANR, challenges around solving ANR, how we track ANRs, an analysis...
Read more >
[ANR] Starting from Android 11 - Visible to Public
I am getting the same error on android 11 devices, has a solution been ... ANR Broadcast of Intent { act=android.intent.action. ... Daemons$HeapTaskDaemon....
Read more >
Still Using InstallBroadcast? Switch to the Play Referrer API by ...
After this date, new versions of the Play Store app will no longer broadcast the install_referrer intent after app installs. We are asking ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found