【发布时间】:2020-09-29 19:55:21
【问题描述】:
flutter/移动开发新手。不得不做一些研发才能在移动应用程序中获得我需要的东西,我被困在了终点线的尽头。即让我的 .apk 在实际设备上工作。
我尝试使用flutter install 安装应用程序并将build\app\outputs\apk\release\app-arm64-v8a-release.apk 转移到我的设备上。
应用安装成功,但启动时立即崩溃。
另一方面,它可以在模拟器和物理设备 (s10+) 上使用 flutter run 构建和运行良好
构建
flutter build apk --split-per-abi --obfuscate --split-debug-info=/MyApp/
Running "flutter pub get" in Myapp... 0.8s
Removed unused resources: Binary resource data reduced from 494KB to 479KB: Removed 2%
Removed unused resources: Binary resource data reduced from 494KB to 479KB: Removed 2%
Removed unused resources: Binary resource data reduced from 494KB to 479KB: Removed 2%
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 75.5s
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (6.0MB).
没有计划在 Play 商店上发布它,它必须在内部使用,我在工作的最后阶段被困住了。有什么建议可以解决这个问题?
更新
Logcat 设置为错误
2020-09-30 00:00:12.918 2472-9529/? E/pageboostd: prefetch start : app comstsltdstevenspin
2020-09-30 00:00:12.919 507-507/? E/audit: type=1400 audit(1601420412.917:20565): avc: denied { search } for pid=2472 comm="pageboostd" name="com.stsltd.stevenspin" dev="sda31" ino=1708995 scontext=u:r:pageboostd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SM-G975F_10_0020 audit_filtered
2020-09-30 00:00:12.919 507-507/? E/audit: type=1400 audit(1601420412.917:20566): avc: denied { search } for pid=2472 comm="pageboostd" name="com.stsltd.stevenspin" dev="sda31" ino=1708995 scontext=u:r:pageboostd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SM-G975F_10_0020 audit_filtered
2020-09-30 00:00:12.921 2472-9529/? E/pageboostd: comstsltdstevenspin, amt 48201728 scnt 15 fcnt 35
2020-09-30 00:00:12.921 2472-9529/? E/pageboostd: prefetch end : app comstsltdstevenspin data_amount 48201728
2020-09-30 00:00:13.125 2472-9530/? E/pageboostd: active launch start : app comexampleStevensPin
2020-09-30 00:00:13.125 2472-9530/? E/pageboostd: comexampleStevensPin, amt 1536600 scnt 2 fcnt 0
2020-09-30 00:00:13.126 2472-9530/? E/pageboostd: comexampleStevensPin, amt 0 scnt 2 fcnt 0
2020-09-30 00:00:13.126 2472-9530/? E/pageboostd: active launch end : app comexampleStevensPin data_amount 1536600
2020-09-30 00:00:13.145 7174-7174/? E/mple.StevensPi: Not starting debugger since process cannot load the jdwp agent.
2020-09-30 00:00:13.481 572-572/? E/Layer: [Surface(name=AppWindowToken{8f83aa6 token=Token{a332c01 ActivityRecord{6c5ede8 u0 com.example.StevensPin/.MainActivity t2284}}})/@0xb5d144d - animation-leash#0] No local sync point found, barrierLayer : [com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity$_1923#0]
2020-09-30 00:00:13.560 7174-7174/? A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 7174 (mple.StevensPin), pid 7174 (mple.StevensPin)
2020-09-30 00:00:13.580 1025-1121/? E/WindowManager: win=Window{96f549b u0 Splash Screen com.example.StevensPin EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1248 com.android.server.wm.AppWindowToken.destroySurfaces:1229 com.android.server.wm.WindowState.onExitAnimationDone:5182 com.android.server.wm.WindowStateAnimator.onAnimationFinished:320 com.android.server.wm.WindowState.onAnimationFinished:5623 com.android.server.wm.-$$Lambda$yVRF8YoeNdTa8GR1wDStVsHu8xM.run:2 com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$SurfaceAnimator:100
2020-09-30 00:00:13.603 9594-9594/? A/DEBUG: pid: 7174, tid: 7174, name: mple.StevensPin >>> com.example.StevensPin <<<
2020-09-30 00:00:13.604 9594-9594/? A/DEBUG: #01 pc 00157a3f /data/app/com.example.StevensPin-pGnjhn3RCPRS-R-mc79c5Q==/lib/arm/libflutter.so (BuildId: e975fb1af56ffc3c5acc61eaa8e0aba1720b5000)
2020-09-30 00:00:13.604 9594-9594/? A/DEBUG: #02 pc 004e1a38 /data/app/com.example.StevensPin-pGnjhn3RCPRS-R-mc79c5Q==/lib/arm/libflutter.so!libflutter.so (offset 0x4e0000) (BuildId: e975fb1af56ffc3c5acc61eaa8e0aba1720b5000)
2020-09-30 00:00:14.003 507-507/? E/audit: type=1701 audit(1601420414.001:20595): auid=4294967295 uid=10309 gid=10309 ses=4294967295 subj=u:r:untrusted_app_27:s0:c53,c257,c512,c768 pid=7174 comm="mple.StevensPin" exe="/system/bin/app_process32" sig=6 res=1
2020-09-30 00:00:14.090 1025-1308/? E/InputDispatcher: channel 'f4478b2 com.example.StevensPin/com.example.StevensPin.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2020-09-30 00:00:14.094 1025-1433/? E/WindowManager: win=Window{f4478b2 u0 com.example.StevensPin/com.example.StevensPin.MainActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1248 com.android.server.wm.AppWindowToken.destroySurfaces:1229 com.android.server.wm.WindowState.onExitAnimationDone:5182 com.android.server.wm.-$$Lambda$01bPtngJg5AqEoOWfW3rWfV7MH4.accept:2 java.util.ArrayList.forEach:1262 com.android.server.wm.AppWindowToken.onAnimationFinished:3931 com.android.server.wm.AppWindowToken.commitVisibility:913
2020-09-30 00:00:14.525 2472-9613/? E/pageboostd: prefetch start : app comstsltdstevenspin
2020-09-30 00:00:14.526 507-507/? E/audit: type=1400 audit(1601420414.525:20596): avc: denied { search } for pid=2472 comm="pageboostd" name="com.stsltd.stevenspin" dev="sda31" ino=1708995 scontext=u:r:pageboostd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SM-G975F_10_0020 audit_filtered
2020-09-30 00:00:14.528 2472-9613/? E/pageboostd: comstsltdstevenspin, amt 48201728 scnt 15 fcnt 35
2020-09-30 00:00:14.529 2472-9613/? E/pageboostd: prefetch end : app comstsltdstevenspin data_amount 48201728
更新 2
在网上搜索时,我发现如果您使用第三方库并尝试缩小构建,也会发生类似的问题。
我在开始时使用msal_mobile 来验证用户。如果我不缩小我的构建
flutter build apk --no-shrink
现在应用程序可以运行并且不会崩溃。
另一方面,如果我避免使用以下msal_mobile 初始化代码,并使用启用收缩的flutter build apk 构建apk,它使用R8 进行收缩,应用程序不会再次崩溃。
class _MyAppState extends State<MyApp> {
MsalMobile msal;
@override
void initState() {
super.initState();
MsalMobile.create('assets/auth_config.json', "https://login.microsoftonline.com/Organizations").then((client) {
setState(() {
msal = client;
});
});
}
}
当您使用导致此类问题的 lib 时,是否有一些不同的方法来缩小应用程序。
【问题讨论】:
-
你能在启动应用程序时读取手机的logcat吗?不需要根。只需插入手机,即可从 AS 中查看控制台。
标签: android flutter installation msal