Reputation: 343
I'm trying to build the debug version of my app on android. the offline version works alright. (with the react-native bundle ...
). But of course, it doesn't trigger the metro bundler. Also, the bundler is listening for build and when https://localhost:8081/index.bundle?platform=android is called on the browser, it starts to bundle.
I've tried:
build
folderdebug.keystore
./gradlew clean
watchman watch-del-all
rm -rf .gradle
rm -rf node_modules
rm -rf package-lock.json
npm i
npx react-native run-android
And almost all sorts of cleaning and resetting. But still no chance. It's a highly customized project and I can not update the react-native version or clean the android folder.
This is my react-native info
result:
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 417.64 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Intel x86 Atom_64, android-29 | Intel x86 Atom_64
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
And this is my logcat when I launch the app on the emulator:
09-03 14:48:11.523 8400 9820 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.demo/com.myapp.MainActivity bnds=[35,503][237,780]} from uid 10083
09-03 14:48:11.751 8400 8440 I ActivityManager: Start proc 12348:com.myapp.demo/u0a111 for activity {com.myapp.demo/com.myapp.MainActivity}
09-03 14:48:11.751 12348 12348 I m.myapp.dem: Not late-enabling -Xcheck:jni (already on)
09-03 14:48:11.782 12348 12348 E m.myapp.dem: Unknown bits set in runtime_flags: 0x8000
09-03 14:48:11.783 12348 12348 W m.myapp.dem: Unexpected CPU variant for X86 using defaults: x86_64
09-03 14:48:11.857 12348 12348 I m.myapp.dem: The ClassLoaderContext is a special shared library.
09-03 14:48:12.303 1652 1652 E Layer : [Surface(name=AppWindowToken{71e8676 token=Token{370511 ActivityRecord{b1c4138 u0 com.myapp.demo/com.myapp.MainActivity t37}}})/@0x93ca15a - animation-leash#0] No local sync point found
09-03 14:48:12.303 1652 1652 E Layer : [Surface(name=AppWindowToken{71e8676 token=Token{370511 ActivityRecord{b1c4138 u0 com.myapp.demo/com.myapp.MainActivity t37}}})/@0x93ca15a - animation-leash#0] No local sync point found
09-03 14:48:12.321 1652 1652 E Layer : [Surface(name=AppWindowToken{71e8676 token=Token{370511 ActivityRecord{b1c4138 u0 com.myapp.demo/com.myapp.MainActivity t37}}})/@0x93ca15a - animation-leash#0] No local sync point found
09-03 14:48:12.422 12348 12376 I FA : adb shell setprop debug.firebase.analytics.app com.myapp.demo
09-03 14:48:12.452 12348 12348 D SoLoader: adding application source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64 flags = 0]
09-03 14:48:12.453 12348 12348 D SoLoader: adding backup source from : com.facebook.soloader.ApkSoSource[root = /data/data/com.myapp.demo/lib-main flags = 1]
09-03 14:48:12.453 12348 12348 D SoLoader: Preparing SO source: com.facebook.soloader.DirectorySoSource[root = /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64 flags = 0]
09-03 14:48:12.453 12348 12348 D SoLoader: Preparing SO source: com.facebook.soloader.ApkSoSource[root = /data/data/com.myapp.demo/lib-main flags = 1]
09-03 14:48:12.455 12348 12348 V fb-UnpackingSoSource: locked dso store /data/user/0/com.myapp.demo/lib-main
09-03 14:48:12.456 12348 12348 I fb-UnpackingSoSource: dso store is up-to-date: /data/user/0/com.myapp.demo/lib-main
09-03 14:48:12.456 12348 12348 V fb-UnpackingSoSource: releasing dso store lock for /data/user/0/com.myapp.demo/lib-main
09-03 14:48:12.583 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
09-03 14:48:12.584 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
09-03 14:48:12.584 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:12.584 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
09-03 14:48:12.587 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
09-03 14:48:12.588 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
09-03 14:48:12.589 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:12.589 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
09-03 14:48:12.589 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, linking, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->peekLong(JZ)J (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->pokeLong(JJZ)V (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->pokeInt(JIZ)V (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->peekInt(JZ)I (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->pokeByteArray(J[BII)V (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->peekByteArray(J[BII)V (greylist, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
09-03 14:48:12.592 12348 12404 W m.myapp.dem: Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, reflection, allowed)
09-03 14:48:12.593 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, reflection, allowed)
09-03 14:48:13.115 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:13.121 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:13.121 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
09-03 14:48:13.122 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
09-03 14:48:13.122 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
09-03 14:48:13.122 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
09-03 14:48:13.122 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
09-03 14:48:13.127 12348 12393 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
09-03 14:48:13.129 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
09-03 14:48:13.139 12348 12348 W RenderThread: type=1400 audit(0.0:54): avc: denied { write } for name="property_service" dev="tmpfs" ino=8201 scontext=u:r:untrusted_app:s0:c111,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.myapp.demo
09-03 14:48:13.263 12348 12348 D SoLoader: libjscexecutor.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.263 12348 12348 D SoLoader: libjscexecutor.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.277 12348 12413 D SoLoader: libhermes.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.277 12348 12413 D SoLoader: libhermes.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.295 12348 12413 D SoLoader: libhermes-executor-release.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.295 12348 12413 D SoLoader: libhermes-executor-release.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.317 12348 12413 D SoLoader: libfb.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.317 12348 12413 D SoLoader: libfb.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.320 12348 12413 D SoLoader: libfb.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.320 12348 12413 D SoLoader: libfb.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.320 12348 12413 I m.myapp.dem: Thread[39,tid=12413,Native,Thread*=0x7d6527e8b800,peer=0x16f77c58,"create_react_context"] recursive attempt to load library "/data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64/libfb.so"
09-03 14:48:13.320 12348 12348 W m.myapp.dem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
09-03 14:48:13.321 12348 12348 W m.myapp.dem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
09-03 14:48:13.329 12348 12348 D FirebasePerformance: onResume(): com.myapp.MainActivity: 1089086 microseconds
09-03 14:48:13.332 12348 12348 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:13.332 12348 12348 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
09-03 14:48:13.335 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
09-03 14:48:13.335 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
09-03 14:48:13.336 12348 12404 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
09-03 14:48:13.403 12348 12413 W InstanceID: Instance ID SDK is deprecated, com.myapp.demo should update to use Firebase Instance ID
09-03 14:48:13.437 12348 12413 I m.myapp.dem: The ClassLoaderContext is a special shared library.
09-03 14:48:13.598 8400 8438 I ActivityTaskManager: Displayed com.myapp.demo/com.myapp.MainActivity: +2s74ms
09-03 14:48:13.622 12348 12420 W m.myapp.dem: Accessing hidden method Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/Handler;Landroid/os/UserHandle;)Z (greylist, reflection, allowed)
09-03 14:48:13.658 8400 8440 I ActivityManager: Start proc 12425:com.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0/u0i12 for {com.myapp.demo/org.chromium.content.app.SandboxedProcessService0}
09-03 14:48:13.815 12348 12413 D SoLoader: libreactnativejni.so not found on /data/data/com.myapp.demo/lib-main
09-03 14:48:13.815 12348 12413 D SoLoader: libreactnativejni.so found on /data/app/com.myapp.demo-tzqejRbWBgXm8igk7j-Npw==/lib/x86_64
09-03 14:48:13.910 12348 12361 I m.myapp.dem: Background young concurrent copying GC freed 72355(9202KB) AllocSpace objects, 26(776KB) LOS objects, 65% free, 3229KB/9373KB, paused 2.318ms total 125.689ms
09-03 14:48:13.912 12348 12413 E AndroidRuntime: Process: com.myapp.demo, PID: 12348
09-03 14:48:13.939 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
09-03 14:48:13.939 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
09-03 14:48:13.939 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
09-03 14:48:13.939 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
09-03 14:48:13.944 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
09-03 14:48:13.946 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
09-03 14:48:13.954 12348 12376 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed)
09-03 14:48:13.954 12348 12376 W m.myapp.dem: Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed)
09-03 14:48:13.955 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
09-03 14:48:13.955 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed)
09-03 14:48:13.956 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed)
09-03 14:48:13.956 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
09-03 14:48:13.956 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, reflection, allowed)
09-03 14:48:13.956 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, reflection, allowed)
09-03 14:48:13.956 12348 12376 W m.myapp.dem: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, reflection, allowed)
09-03 14:48:13.980 8400 10689 W ActivityTaskManager: Force finishing activity com.myapp.demo/com.myapp.MainActivity
09-03 14:48:14.039 8400 8493 W InputDispatcher: channel 'a546a57 com.myapp.demo/com.myapp.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
09-03 14:48:14.039 8400 8493 E InputDispatcher: channel 'a546a57 com.myapp.demo/com.myapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
09-03 14:48:14.062 8400 10382 I ActivityManager: Process com.myapp.demo (pid 12348) has died: vis+99 TOP
09-03 14:48:14.096 8400 8841 I WindowManager: WIN DEATH: Window{a546a57 u0 com.myapp.demo/com.myapp.MainActivity}
09-03 14:48:14.096 8400 8841 W InputDispatcher: Attempted to unregister already unregistered input channel 'a546a57 com.myapp.demo/com.myapp.MainActivity (server)'
And this is the build.gradle setup for debug:
buildTypes {
debug {
signingConfig signingConfigs.debug
applicationIdSuffix ".demo"
versionNameSuffix " - Dev"
resValue "string", "app_name", "My App"
}
I believe somehow the customizations made some changes that the build version is not actually a debug one that shows the debug red screen and is connected to the development server. But I can not find the source to change.
I also installed a react-native init --version 0.61.5
on my laptop and it installs and runs and connects to the metro server like a charm.
So if you have any suggestions to check further deep inside the configurations and android folder I'll be deeply grateful. I've tried so many questions on StackOverflow and issues on the react-native, react-native-CLI, and metro repos, but couldn't find any advanced guides that I need.
Upvotes: 2
Views: 4924
Reputation: 343
The magic of posting the question on StackOverflow worked and I found the answer after a few tries after it.
Apparently, the problem was with the imported BuildConfig
file at the MainApplication.java
. This causes the program to use the imported build config and not the debug one that is in this file:
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
Because the libraries use the production config in their build config and when we import it the compiler prevents debug features. That's why it can not get connected to the metro bundler.
So if you're viewing this question and have the same problem make sure to check the MainApplication.java
and remove any external BuildConfigs that you find, such as:
import com.facebook.react.BuildConfig;
import androidx.multidex.BuildConfig;
In my case, the second was there in the code. After doing this make sure to remove the offline bundle if you've got any:
rm android/app/src/main/assets/index.android.bundle
And remove the android build folder:
rm -rf android/app/build
or:
cd android && ./gradlew clean
Now you can run react-native run-android
and it will hopefully build and run and connect to the bunder successfully.
Upvotes: 8