Stops working in release mode

DOCCDOCC USMember ✭✭

I have a app that receives information over the internet. It works fine running on the tablet in debug mode. When I put it in release mode it works fine for about 20 minutes and then locks up. Anyone got any ideas what's causing this? The fact it works for a few minutes is extremely frustrating, and make the problem hard to fine. How can I find this problem? Doesn't running in debug mode use more resources on the tablet?

Answers

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    There's many variables that go into this. Have you grabbed logs from your adb logcat to see why the application is locking up?

    Sadly there's not enough information in your post to help diagnose what's going on. The first thing you should do it minimize the variables between Debug / Release modes. For example a major issue is the Linker setting in Debug vs. Release as it can potentially strip code.

    https://developer.xamarin.com/guides/android/advanced_topics/linking/

  • LjusnanLjusnan DEMember ✭✭✭
    edited March 2017

    @DOCC
    Here are some things you can try
    1) Check the internet permission. In debug mode internet permission is automatically added.
    2) Give all permissions your app might need. Access to network/internet/external storage for example. Also check for runtime permissions in Android Marshmallow and Nougat.
    3) Disable "Use Shared Runtime"
    4) Disable Proguard and AOT Compilation
    5) Set Linking to "None"
    6) Set Java Max Heap Size to "1G"
    7) Check all supported architectures

    Also check for information in logcat.

  • DOCCDOCC USMember ✭✭

    Thanks for the replies. I hope to give these ideas a try in the next couple of days.

  • DOCCDOCC USMember ✭✭

    I ran a test and the program locked up at 13:05:55. The program puts the time on the screen every couple of seconds so I know at what time it locks up when the screen quits updating. Here is the log file around that time. The app is receiving data over port 8899.

    I noticed the error:

    04-11 13:05:27.076  Acer A1-850 Info    515 WAKELOCK_ACQUIRE    TIMESTAMP=1125012291626306,     TAG=NlpWakeLock, TYPE=PARTIAL_WAKE_LOCK             , COUNT=0, PID=25775, UID=10012, FLAGS=
    

    around that time. What does this mean?

  • DOCCDOCC USMember ✭✭

    Here is another run. The lockup occurred at 17:42:25.

  • RicardoBritoBrensRicardoBritoBrens USMember ✭✭

    Hello Xamers,

    I was facing the same error using the following tools:

    Integrated Development Environment (IDE): Visual Studio 2019 16.2.4
    Minimum Android version: Android 6.0 (API level 23 - Marshmallow)
    Target Android version: Android 9.0 (API Level 28 - Pie)

    Nuget Packages Libraries:

    Permissions:

    https://github.com/jamesmontemagno/PermissionsPlugin
    https://github.com/jamesmontemagno/CurrentActivityPlugin/blob/master/README.md

    Persistence

    https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/2.2.6?_src=template

    Here is what I did and works for me:

    On Release Mode:

    1)- Follow @DOCC steps here is an extract:

    1. Check the internet permission.
    2. Give all permissions your app might need. Access to network/internet/external storage for example. Also check for runtime permissions in Android Marshmallow and Nougat.
    3. Disable "Use Shared Runtime"
    4. Disable Proguard and AOT Compilation
    5. Set Linking to "None"
    6. Check all supported architectures

    One of them, really important was to add permissions into the Manifest but not manually instead I went to the Android Project Property > Android Manifest > Required permissions > and check all what I need.

    `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />`
        `<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />`
        `<uses-permission android:name="android.permission.INTERNET" />`
        `<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />`
    

    2)- Check the Device Log and I notice that there is an error that I do now able to see because it does not appear in any display message. The application just closed without any messages from the try - catch block I set for, so I simplify the try-catch block and immediately the error rose:

    "1252 encoding not found"

    So, to solve it, I’ve went to Android project property > Android Options> Additional supported encodings > check all.

    References Device logs:
    https://devblogs.microsoft.com/xamarin/enhanced-device-logging-in-visual-studio/

    Those steps solve all the errors and now the app run well in debug and release mode, I hope this can help anyone too.

    Regards,

Sign In or Register to comment.