0

New to flutter/mobile development. Had to do a bit of R&D to get what i need in a mobile app, I'm stuck at the very end of the finish line. i.e making my .apk work on the actual device.

I've tried installing app with flutter install and by transferting build\app\outputs\apk\release\app-arm64-v8a-release.apk on to my device. App get installed successfully, but crashes immediately on the start.

On the other hand It builds and runs fine with flutter run, on both emulator and on physical device (s10+)

Build

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).

No plan to publish it on the Play Store, it has to be used internally and i'm stuck at the very end of my work. Any word of advice what to look for to solve this?

Update

Logcat set to Error

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

Update 2

While searching online i've found that similar issue happened if you are using a third party lib and try shrinking the build.

I'm using msal_mobile for authenticating user at the beginning. If i don't shrink my build

flutter build apk --no-shrink

Now the app works and doesn't crash.

On the other hand if I avoid the following msal_mobile initializing code, and build the apk with shrinking enabled flutter build apk, which uses R8 to shrink, app doesn't crash again.

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;
            });
        });
    }
}

Is there some different approach to shrink the app when u are using lib that causes such issue.

AlphaTry
  • 475
  • 5
  • 27
  • Are you able to read the logcat of the phone while lauching the app? Root is not required. Just plug your phone and see the console from AS. – gcantoni Sep 29 '20 at 19:58

1 Answers1

1

I encountered the same error and narrowed the problem down to the msal_mobile package having issues invoking platform-specific functionality with its method channels (specifically Line 39 of msal_mobile.dart).

Based on what I read here, it seems like the Android modification and obfuscation process ends up being a bit overzealous when renaming methods, making the method channels used in the msal_mobile package think that the method they are trying to call doesn't exist.

The only solution that I found to work for my own situation isn't ideal, as it increases the size of my app, but it got my project working again, so I thought I would share.

In your project's directory, open the file android/app/build.gradle and add the following lines to the release section of buildTypes:

buildTypes {
    release {
        signingConfig signingConfigs.debug

        minifyEnabled false   // Add this line
        shrinkResources false // Add this line
        useProguard false     // Add this line
    }
}

I hope this helps a bit!

amphibious_RV
  • 21
  • 2
  • 5
  • Hi @amphibious, thanks for your concern. I actually got over this issue with tweeking the build types options,like you mentioned. Posted the answer [here](https://stackoverflow.com/a/65859481/5702164). Now im facing another problem which i believe is again msal_mobile related. Afrer obfuscating the build app runs without crash but trowing error. [Here](https://stackoverflow.com/q/65852598/5702164) are the details. Thanks again. – AlphaTry Jan 27 '21 at 22:15