我正在尝试在android上构建我的应用程序的调试版本。脱机版本工作正常。(带有react-native bundle ...
)。但是,当然,它不会触发Metro Bundle。此外,捆绑程序正在侦听构建,并且在浏览器上调用https:// localhost:8081 / index.bundle?platform = android时,捆绑程序开始捆绑。我试过了:
build
文件夹debug.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
以及几乎所有的清洁和重置。但是仍然没有机会。这是一个高度自定义的项目,我无法更新react-native版本或清理android文件夹。
这是我的react-native info
结果:
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
这是我在模拟器上启动应用程序时的日志:
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)'
这是用于调试的build.gradle设置:
buildTypes {
debug {
signingConfig signingConfigs.debug
applicationIdSuffix ".demo"
versionNameSuffix " - Dev"
resValue "string", "BATCH_API_KEY", "5DA44387E4C3511C7F8F1AA84C4B56"
resValue "string", "app_name", "My App"
}
我相信定制会以某种方式进行一些更改,使构建版本实际上不是显示调试红色屏幕并已连接到开发服务器的调试版本。但是我找不到改变的源头。
我还在react-native init --version 0.61.5
笔记本电脑上安装了一个,它可以像魅力一样安装,运行并连接到Metro服务器。因此,如果您有任何建议可以进一步检查配置和android文件夹的内部内容,我们将不胜感激。我已经在StackOverflow上尝试了很多问题,还对React-native,React-native-CLI和Metro仓库进行了尝试,但是找不到我需要的任何高级指南。
在StackOverflow上发布问题的魔力奏效了,在尝试了几次之后,我找到了答案。显然,问题出在处的导入BuildConfig
文件MainApplication.java
。这将导致程序使用导入的构建配置,而不使用此文件中的调试文件:
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
因为这些库在其生成配置中使用生产配置,并且在我们导入它时,编译器会阻止调试功能。这就是为什么它无法连接到Metro Bundle的原因。
因此,如果您正在查看此问题并且遇到相同的问题,请确保检查MainApplication.java
并删除找到的所有外部BuildConfig,例如:
import com.facebook.react.BuildConfig;
import androidx.multidex.BuildConfig;
就我而言,第二个在代码中。完成此操作后,请确保删除脱机捆绑包(如果有):
rm android/app/src/main/assets/index.android.bundle
并删除android build文件夹:
rm -rf android/app/build
要么:
cd android && ./gradlew clean
现在,您可以运行react-native run-android
,它将有望成功构建并运行并连接到bunder。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句