Today, I will show you guys how I fixed my app which was crashing on Nougat. So I made a mistake when I was developing my app which caused a bit of a headache but now I am happy to say that the issues has been resolved and I will be more than glad to show you guys how I fixed my app.
First off, when I started developing my app with Android Studio, I had updated all my SDK tools to the latest and greatest and I started building my app set on API Level 25. This was all fine and the app would build and run on my phone. What I had forgot and thought that it didn’t matter is that my Samsung S6 which I have been using to test my app was running on Android 6.0 and not Android 7.0 N (Nougat) which is the latest OS released by Google.
I thought this wouldn’t be an issue as my app ran fine on my phone until the next day when Momma Bear told me that my app didn’t work. I asked her, how does it not work? We have the same phone and I tested/developed it on the same phone? She said, I don’t know sonny, but the app crashes on start up.
At first, I just thought that her phone went into doo doo mode or that she had downloaded some crap which causing the issue. But, when I looked at the phone, I realized her UI was different than mine and that she had set automatic updates on her phone, so she was now running Android Nougat on her Samsung S6 and this was causing my app to crash right away.
This is when I updated my Samsung S6 to Android Nougat to see what the issue was. So, I tried to run the app on my phone with the new Nougat OS on it and it would just crash, just like Momma Bear said. This is when I figured out that it wasn’t an issue with her phone but that there was some funny business going on with the new Android Nougat OS on my cell and my app, which was causing a problem where the app won’t open at all.
How did I fix app crashing on Android Nougat?
Now, to be fair, this fix might not work for everyone but I hope that it can help most developers who are experiencing their app crashing on Android Nougat. The reason that I say that it might not help everyone is because the reason that my app was crashing was due to a custom background image that I was using for my app. Well, what does that mean? Originally I had an .jpeg image that I was using for the background in my app which was 1920 x 1052 and it worked fine for most devices that I tested it on which were running Android 6 or below. However, with Android Nougat the app would just crash right away.
This is where the debug and logcat option helped tremendously! After looking into the logcat after the app crashed, I saw something that said something along the lines of canvas draw image error. This basically means that the image that I was trying to use was to being scaled to big on the device which was causing the app to crash on start-up.
I then thought that it might the file type, so I changed it from .jpeg to .png keeping the same size of the pic, with no luck. Then, I went into Photoshop and re-scaled the image to around half the original size at 1000 x 548, saved as .png and gave it a go. Boom. It worked like a charm! Now, I am not sure what the issue is with Android Nougat and the image types/file sizes but what I did above fixed my app crashing on Android Nougat. Then for the fun of it, I tried to increase the image size to see how far I could push it before it would crash again. I increased the image size from 1000 x 548 to 1200 x 658 and the app again would crash.
I have since reverted back to the .png image with a size of 1000 x 548 and this allows it work on both my tablet and Samsung S6. I am not sure what Google did with the latest update in regards to file types an image sizes but this is what worked for me when my app was crashing on Android Nougat. I hope it can help you too!