after Migrating to Expo modules apps crash in release version
See original GitHub issueSummary
i upgraded to 43 SDK and after some adjustment apps worked. then i Migrating to Expo modules using documentations here and i made a comparison every files too from here
at first my apps cannot works even in debug, i found some error when gradle build like:
- apps cannot build in debug, i delete file BasePackageList.java then problem solved.
- i add native debug symbols so i found that gradle plugin must >= 4.1
- upgrade gradle plugin 4.2.2 but i found some issue so i’m back to 4.1
- upgrade gradle wrapper properties to 6.8.1, there is some error log that suggest me to upgrade
- i fix splash screen resize mode in strings.xml because we delete it from MainActivity.java
- error while build “Unable to extract native debug metadata from …” so i add NDK in project build gradle with ver 21.4.7075529 (i found this from latest commit file in expo)
- error kotlin “Detected multiple Kotlin daemon sessions at build/kotlin/sessions” so i force set it in app build gradle ver 1.4.21
i’m still have some problems:
- i dont know sometimes when i did a release build it was failed, but when i try again error is gone. “Error: ENOENT: no such file or directory, watch …”
- i success to build my release apps using assembleRelease or installRelease, but my apps still crash. this is log from my release apps which i suspected:
11-22 11:40:40.435 29180 29180 E m.brambang.app: Not starting debugger since process cannot load the jdwp agent.
...
11-22 11:40:40.458 29180 29180 W ActivityThread: Application com.brambang.apps can be debugged on port 8100...
...
/************* I DONT UNDERSTAND, WHY WE NEED DEBUGGER IN RELEASE APPS?? *********************/
...
1-22 11:40:40.525 29180 30411 W m.brambang.app: ClassLoaderContext type mismatch. expected=PCL, found=DLC (PCL[] | DLC[];PCL[/data/app/com.brambang.apps-TyeTg5XmZZyiSrbcF2JhjQ==/base.apk*2490141572:/data/app/com.brambang.apps-TyeTg5XmZZyiSrbcF2JhjQ==/base.apk!classes2.dex*3236238951])
11-22 11:40:40.526 1618 30154 D NetworkMonitor/160: [isDataStallSuspected] mConsecutiveTimeoutCount =0timeoutCountThreshold =5mDataStallValidDnsTimeThreshold =1800000
11-22 11:40:40.526 1618 30154 D NetworkMonitor/160: isDataStall: result=false, consecutive dns timeout count=0
11-22 11:40:40.526 29180 30411 W m.brambang.app: Found duplicate classes, falling back to extracting from APK : /data/user_de/0/com.google.android.gms/app_chimera/m/00000325/MeasurementDynamite.apk
11-22 11:40:40.526 29180 30411 W m.brambang.app: NOTE: This wastes RAM and hurts startup performance.
11-22 11:40:40.526 29180 30411 W m.brambang.app: Found duplicated class when checking oat files: 'Landroid/support/v4/app/RemoteActionCompatParcelizer;' in /data/app/com.brambang.apps-TyeTg5XmZZyiSrbcF2JhjQ==/base.apk and /data/user_de/0/com.google.android.gms/app_chimera/m/00000325/MeasurementDynamite.apk
11-22 11:40:40.526 29180 30411 W m.brambang.app:
11-22 11:40:40.530 29180 29180 E e : Could not read embedded manifest
11-22 11:40:40.530 29180 29180 E e : java.io.FileNotFoundException: app.manifest
11-22 11:40:40.530 29180 29180 E e : at android.content.res.AssetManager.nativeOpenAsset(Native Method)
11-22 11:40:40.530 29180 29180 E e : at android.content.res.AssetManager.open(AssetManager.java:833)
11-22 11:40:40.530 29180 29180 E e : at android.content.res.AssetManager.open(AssetManager.java:810)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.l.e.h(Unknown Source:18)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.l.g.x(Unknown Source:29)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.l.g.B(Unknown Source:96)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.f.D(Unknown Source:75)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.f.s(Unknown Source:5)
11-22 11:40:40.530 29180 29180 E e : at expo.modules.updates.UpdatesPackage$a.b(Unknown Source:12)
11-22 11:40:40.530 29180 29180 E e : at f.a.e.createReactInstanceManager(Unknown Source:33)
11-22 11:40:40.530 29180 29180 E e : at com.facebook.react.s.a(Unknown Source:9)
11-22 11:40:40.530 29180 29180 E e : at com.brambang.apps.MainApplication.onCreate(Unknown Source:11)
11-22 11:40:40.530 29180 29180 E e : at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1204)
11-22 11:40:40.530 29180 29180 E e : at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6648)
11-22 11:40:40.530 29180 29180 E e : at android.app.ActivityThread.access$1600(ActivityThread.java:232)
11-22 11:40:40.530 29180 29180 E e : at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1953)
11-22 11:40:40.530 29180 29180 E e : at android.os.Handler.dispatchMessage(Handler.java:107)
11-22 11:40:40.530 29180 29180 E e : at android.os.Looper.loop(Looper.java:214)
11-22 11:40:40.530 29180 29180 E e : at android.app.ActivityThread.main(ActivityThread.java:7697)
11-22 11:40:40.530 29180 29180 E e : at java.lang.reflect.Method.invoke(Native Method)
11-22 11:40:40.530 29180 29180 E e : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
11-22 11:40:40.530 29180 29180 E e : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
11-22 11:40:40.530 29180 29180 D AndroidRuntime: Shutting down VM
11-22 11:40:40.530 29180 29180 E AndroidRuntime: FATAL EXCEPTION: main
11-22 11:40:40.530 29180 29180 E AndroidRuntime: Process: com.brambang.apps, PID: 29180
11-22 11:40:40.530 29180 29180 E AndroidRuntime: java.lang.AssertionError: The embedded manifest is invalid or could not be read. Make sure you have configured expo-updates correctly in android/app/build.gradle. app.manifest
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.l.e.h(Unknown Source:96)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.l.g.x(Unknown Source:29)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.l.g.B(Unknown Source:96)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.f.D(Unknown Source:75)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.f.s(Unknown Source:5)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at expo.modules.updates.UpdatesPackage$a.b(Unknown Source:12)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at f.a.e.createReactInstanceManager(Unknown Source:33)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at com.facebook.react.s.a(Unknown Source:9)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at com.brambang.apps.MainApplication.onCreate(Unknown Source:11)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1204)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6648)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.app.ActivityThread.access$1600(ActivityThread.java:232)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1953)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7697)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
11-22 11:40:40.530 29180 29180 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
11-22 11:40:40.532 1618 9210 W ActivityTaskManager: Force finishing activity com.brambang.apps/.MainActivity
11-22 11:40:40.532 1618 30447 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
11-22 11:40:40.533 1618 9210 D OpQuickReply: setQuickReplyResumed focusedApp AppWindowToken{383c711 token=Token{7acb38 ActivityRecord{ee3b9b u0 com.microsoft.launcher/.Launcher t83105}}} pkgName com.microsoft.launcher
11-22 11:40:40.533 1618 30447 D FrameworkEventCollector: recordAppIssue PN: com.brambang.apps
11-22 11:40:40.533 1618 9210 D ActivityTrigger: ActivityTrigger activityPauseTrigger
11-22 11:40:40.534 1618 9825 D cpe : OS Event: crash
11-22 11:40:40.533 1618 9210 D OpQuickReply: setQuickReplyResumed focusedApp AppWindowToken{383c711 token=Token{7acb38 ActivityRecord{ee3b9b u0 com.microsoft.launcher/.Launcher t83105}}} pkgName com.microsoft.launcher
11-22 11:40:40.536 1618 1741 D OpRestartProcessManager: Duration is too short, ignore : 118 in com.brambang.apps
11-22 11:40:40.536 1618 1842 D cpe : OS Event: appuse
11-22 11:40:40.537 1618 1739 I ActivityManager: Showing crash dialog for package com.brambang.apps u0
...
this is my release build setup in app build gradle:
configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21"
}
}
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
}
}
/*
ERROR WHEN bundleRelease:
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
OR WARNING WHEN bundleRelease:
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
*/
// plugins {
// id("kotlin-android") apply false
// }
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
// WARNING: The onesignal-gradle-plugin MUST be before com.android.application!
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. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://reactnative.dev/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 = [
enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../cli.js"),
]
apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../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
/**
* Enables resource shrinking, which is performed by the Android Gradle plugin.
*/
def enableShrinkResourcesBuilds = true
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
/**
* 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 that value will be read 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);
/**
* Architectures to build native code for.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId 'com.brambang.apps'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 130000 // 1X.XX.XX
versionName "3.0.0"
}
dexOptions {
javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
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.release
minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableShrinkResourcesBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
ndk { debugSymbolLevel = "SYMBOL_TABLE" }
}
}
// 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
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
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 =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
packagingOptions {
pickFirst '**/libhermes.so'
pickFirst '**/libjsc.so'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
// All fresco packages should use the same version
if (isGifEnabled || isWebpEnabled) {
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
}
if (isGifEnabled) {
// For animated gif support
implementation 'com.facebook.fresco:animated-gif:2.0.0'
}
if (isWebpEnabled) {
// For webp support
implementation 'com.facebook.fresco:webpsupport:2.0.0'
if (isWebpAnimatedEnabled) {
// Animated webp support
implementation 'com.facebook.fresco:animated-webp:2.0.0'
}
}
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" // add ver 1.0.0 or newer versions should work too
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute().text.trim(), "../android/hermes-debug.aar"))
releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute().text.trim(), "../android/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: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
43
Environment
Expo CLI 4.13.0 environment info: System: OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa) Shell: 5.0.17 - /bin/bash Binaries: Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v14.17.0/bin/npm IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 npmPackages: expo: ^43.0.0 => 43.0.3 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 react-navigation: ^3.13.0 => 3.13.0 npmGlobalPackages: expo-cli: 4.13.0 Expo Workflow: bare
Reproducible demo or steps to reproduce from a blank project
i dont have Reproducible demo
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:20 (8 by maintainers)
Top Related StackOverflow Question
@hotaryuzaki reanimated + proguard is a known issue, please reference this to add proguard rule for reanimated: https://github.com/software-mansion/react-native-reanimated/issues/1868#issuecomment-806468122
for
FileSystemPackage, you should be able to remove it.@Kudo
Oh, where should I setuseDeveloperSupportproperty on Android? Since I changed nothing about that property, I’m really confused.I found the property. But I’m curious, whySorry, I found the answer. Wrong imports.BuildConfig.DEBUGis no longer working? It’s always false even if debug environment.