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

Android app not starting after release - only shows boot splash screen #2431

Closed
Balhut opened this issue May 10, 2023 · 31 comments · Fixed by #2446
Closed

Android app not starting after release - only shows boot splash screen #2431

Balhut opened this issue May 10, 2023 · 31 comments · Fixed by #2446
Labels

Comments

@Balhut
Copy link

Balhut commented May 10, 2023

Describe the bug

Hello,

First of all, thank you for your work! Ignite is awesome!

I tried to preview the newest Ignite version and see what changed with the introduction of RN 0.71. I managed to release a test app on iOS, but I couldn't do the same with Android. The app runs perfectly on the emulator (npm run android), but when I run:

npm run release:android

and try to run it on either a physical device or by dragging an APK on the emulator window, the app installs correctly and the splash screen shows up, but then it crashes immediately.

Steps to reproduce:

  1. npx ignite-cli@latest new PizzaApp
  2. Change the bundle identifier, e.g., com.pizza.pizzaapp
  3. Leave the default project directory
  4. Choose "Yes" to initialize a Git repository
  5. Choose "Yes" to remove the demo code
  6. Choose "npm" as the package manager
  7. Choose "Yes" to install dependencies
  8. After the CLI finishes, run "npm run release:android"

I noticed that during the building of an APK file, two warnings were displayed:

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.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':expo', ':expo-modules-core'

And then, I saw the same warnings with :react-native-screens and :react-native-gesture-handler. I found a comment on the RNGH repo suggesting that adding this line to app/build.gradle might help:

implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))

software-mansion/react-native-gesture-handler#2307 (comment)

However, it didn't help in my case.

Has anyone encountered similiar problem? I would highly appreciate any help :)

Ignite version

8.8.0

Additional info

System
platform darwin
arch arm64
cpu 10 cores Apple M1 Pro
directory Erko /Users/balhut/Developer/new-repo/clear/Erko

JavaScript (and globally-installed packages)
node 18.15.0 /Users/balhut/.nvm/versions/node/v18.15.0/bin/node
npm 9.6.6 /Users/balhut/.nvm/versions/node/v18.15.0/bin/npm
corepack 0.15.3
ios-deploy 1.12.2
npm 9.6.6
yarn - not installed
pnpm - not installed
expo 48.0.15 managed

Ignite
ignite-cli 8.8.0 /Users/balhut/.npm/_npx/e31027f3785124a8/node_modules/.bin/ignite
ignite src build /Users/balhut/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/build

Android
java 11.0.19 /usr/bin/java
android home - undefined

iOS
xcode 14.3
cocoapods 1.12.1 /Users/balhut/.rbenv/shims/pod

Tools
git git version 2.40.1 /opt/homebrew/bin/git

@Balhut Balhut added the bug label May 10, 2023
@jingledongding
Copy link

me too
but studio got some log to me
couldn't find DSO to load: libjscexecutor.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.goodmorning/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~6rXV60o4FePFo89POF2Z_g==/com.goodmorning-Omf7q4pKTUaOW_qDBQHM7A==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/~~6rXV60o4FePFo89POF2Z_g==/com.goodmorning-Omf7q4pKTUaOW_qDBQHM7A==/lib/arm64 result: 0 2023-05-11 18:03:05.346 31774-31793 ExpoModulesCore com.goodmorning I ✅ AppContext was initialized 2023-05-11 18:03:05.623 31774-31806 ReactNativeJS com.goodmorning E Invariant Violation: "GoodMorning" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error andAppRegistry.registerComponentwasn't called., js engine: hermes 2023-05-11 18:03:05.626 31774-31807 AndroidRuntime com.goodmorning E FATAL EXCEPTION: mqt_native_modules Process: com.goodmorning, PID: 31774 com.facebook.react.common.JavascriptException: Invariant Violation: "GoodMorning" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error andAppRegistry.registerComponent` wasn't called., js engine: hermes, stack:
invariant@1:143917
runApplication@1:302698
__callFunction@1:149237
anonymous@1:147607
__guard@1:148557
callFunctionReturnFlushedQueue@1:147565

                                                                                                	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
                                                                                                	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
                                                                                                	at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                	at android.os.Looper.loop(Looper.java:288)
                                                                                                	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
                                                                                                	at java.lang.Thread.run(Thread.java:1012)

2023-05-11 18:03:05.651 31774-31806 ReactNativeJNI com.goodmorning I Memory warning (pressure level: TRIM_MEMORY_UI_HIDDEN) received by JS VM, ignoring because it's non-severe
2023-05-11 18:03:05.683 31774-31774 unknown:ReactNative com.goodmorning E Tried to remove non-existent frame callback
logcat`

@jingledongding
Copy link

@jingledongding
Copy link

expo/expo#17450

@jingledongding
Copy link

I have tried all the solutions mentioned above.

@trungjune
Copy link

i have same issue

@geninhocell
Copy link

https://developer.android.com/reference/tools/gradle-api/7.4/com/android/build/api/dsl/JniLibsPackagingOptions

android {

    packagingOptions {      
        jniLibs {
            useLegacyPackaging = true
            pickFirsts.add("**/libjscexecutor.so")
        }
    }
    ...
}

The set of patterns where the first occurrence is packaged in the APK. For each native library APK entry path matching one of these patterns, only the first native library found with that path gets packaged.

Example: android.packagingOptions.jniLibs.pickFirsts += "**/pickFirst.so"

@frankcalise
Copy link
Contributor

Hi all, thanks for the bug report. I am able to reproduce it - still searching for a solution at the moment.

@dibyopra
Copy link

same issue

@ahmadsyamim
Copy link

+1

@Hranatikk
Copy link

Same issue, in logs saw two error, one with soLoader, the second one with Invariant Violation: "app" has not been registered
After hours of search on github and stackoverflow i tried all of solutions and they are not working

@geninhocell
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

@frankcalise
Copy link
Contributor

Ah so it is a pick a flow (vanilla or Expo) issue, thank you

@oottoohh
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

still force close for me

@trungjune
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

thank you so much, it worked for me

@geninhocell
Copy link

package.json, remova esta linha"main": "node_modules/expo/AppEntry.js",

ainda forçar o fechamento para mim

greetings! can you send the error log

@oottoohh
Copy link

oottoohh commented May 25, 2023

@geninhocell

10:14 M 0
). 49%
Report bug
com.facebook.react.common.JavascriptExcep
tion: Invariant Violation: "Auto2000v7" has not
been registered. This can happen it:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error
    and 'AppRegistry.registerComponent' wasn't
    called., js engine: hermes, stack:
    invariant@1:74973
    runApplication@l:269009
    -_calIFunction@1:83734
    anonymous@l:82245
    __guard@l:83182
    callFunctionReturnFlushedQueue@1:82203
    at
    com.facebook.react.modules.core.Exceptions
    ManagerModule.reportException(ExceptionsM
    anagerModule.java:72)
    atjava.lang.reflect.Method.invoke(Native
    Method)
    at
    com.facebook.react.bridge.JavaMethodWrap
    per.invoke(JavaMethodWrapper.java:372)
    at
    com.facebook.react.bridge.JavaModuleWrap
    per invoke (JavaModuleWrapper.java:188)
    at
    com.facebook.ini.NativeRunnable.run(Native
    Mathard)
    Cancel
    Send

@oottoohh
Copy link

on my project, i try custom root path using babel-plugin-module-resolver, is it make impact to build release app or not ?

@geninhocell
Copy link

can you upload a sample project with the reported error? I need to take a closer look to be able to help. hug.

@oottoohh
Copy link

oottoohh commented May 25, 2023

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

first i try build from new ignite boilerplate then i build release and its working well. conclusion is the problem when when i try migrate to v8.8.2, so i try again to remigrate from v8.7.0 to v8.8.2 . first build still force close after i follow this my APK running well on device. Thankyou ! @geninhocell

@oottoohh
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

I guess that solution doesn't work on iOS.

because the problem is not from IOS 😆

@abdulmateentechbits
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

Thanks for save my hours

@finnmerlett
Copy link

finnmerlett commented Jul 17, 2023

I've cooked up a fully automatic fix, it just requires the expo-constants package. Assuming you're working in the project root:

add ./entry-point.js with the following code:

import Constants, { ExecutionEnvironment } from "expo-constants";

const isInExpoMode = Constants.executionEnvironment === ExecutionEnvironment.StoreClient;

const entryPoint = isInExpoMode ? require("./App") : require("./index");

export default entryPoint

In your package.json, change your "main" property to point to the new file:

  "main": "entry-point.js",

This will direct any run modes that use the "main" property as the entry poin to the correct file. Any run modes that just use index.js (such as react-native run-android) will still operate as normal.

Tested and confirmed working on:

  • expo start --ios
  • expo start --android
  • react-native run-ios
  • react-native run-android
  • android/gradlew assembleRelease

For further reading here is the link to the documentation on runtime detection in expo projects

@frankcalise frankcalise linked a pull request Jul 17, 2023 that will close this issue
2 tasks
@frankcalise
Copy link
Contributor

Just tested this in the latest version of Ignite (v9 to be released) and it is no longer an issue just FYI for new projects that will use this template. Thanks to all who chimed in here to help others along!

@gwijaya94
Copy link

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

just updated 8.7.0 to 8.8.2, and got the same problem on Android. Success run release mode after remove this line. Thankyou for the solution.

@frankcalise
Copy link
Contributor

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

just updated 8.7.0 to 8.8.2, and got the same problem on Android. Success run release mode after remove this line. Thankyou for the solution.

@gwijaya94 Do you have both expo splash screen and react native bootsplash installed?

@gwijaya94
Copy link

gwijaya94 commented Aug 8, 2023

@frankcalise Yeah both are installed, with reference from Ignite-diff-purge.
But running not using expo, just rn-cli.
Haven't tried it yet build on ios, but I believe it should be fine..

@frankcalise
Copy link
Contributor

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

just updated 8.7.0 to 8.8.2, and got the same problem on Android. Success run release mode after remove this line. Thankyou for the solution.

@gwijaya94 Do you have both expo splash screen and react native bootsplash installed?

Try dropping expo splash screen then

@bielb2
Copy link

bielb2 commented Aug 18, 2023

package.json, remove this line "main": "node_modules/expo/AppEntry.js",

thank you so much, i'm stuck for about 1 week in this bug

@LeeRaybone
Copy link

none of the above fixes are working for me any ideas,, or when is version 9 due to be released @frankcalise

@frankcalise
Copy link
Contributor

@LeeRaybone you can jump on it now with npx ignite-cli@next

@andrew-vqn
Copy link

I've cooked up a fully automatic fix, it just requires the expo-constants package. Assuming you're working in the project root:

add ./entry-point.js with the following code:

import Constants, { ExecutionEnvironment } from "expo-constants";

const isInExpoMode = Constants.executionEnvironment === ExecutionEnvironment.StoreClient;

const entryPoint = isInExpoMode ? require("./App") : require("./index");

export default entryPoint

In your package.json, change your "main" property to point to the new file:

  "main": "entry-point.js",

This will direct any run modes that use the "main" property as the entry poin to the correct file. Any run modes that just use index.js (such as react-native run-android) will still operate as normal.

Tested and confirmed working on:

  • expo start --ios
  • expo start --android
  • react-native run-ios
  • react-native run-android
  • android/gradlew assembleRelease

For further reading here is the link to the documentation on runtime detection in expo projects

Thanks for save my hours. Worked for me.

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

Successfully merging a pull request may close this issue.