– At the moment, it is 2:18 in the middle of the night, and watching the national football team partners. We did not sleep. Let’s talk about the heart course of the bug I changed this time, although a little sad, but very interesting

Writing in the front

This is a redesign of the company from Uniapp to Cordova for better advertising revenue.

I have heard that Cordova has a lot of problems, but I still think that Uni has a lot of problems.

However, after I started working on Cordova, I realized that the project was far beyond my expectation. First, I configured JAVA and Android environment variables. It took me most of the day, but there were still some minor issues (solutions, version rollback of the old version of the compiler). Let’s talk about the Bug from yesterday. There was a Bug in the company’s requirement that android phones save pictures. When I was developing, I used my Own Samsung mobile phone and had no problem saving images. At that time, I thought that this function could be directly passed, but unexpectedly, when I came to the test, I found that her redmi mobile phone would report an error :error while saving image…..

Analyze the cause of the Bug oh my god, this Bug is as good as never, no hint at all. At that time, I carefully checked my front-end code. The plug-in is equivalent to new an image constructor, and then transform the place to be saved into Base64 through the plug-in, and then assign the value to the image SRC. I think there is no problem, and if there is a problem, by rights, my Samsung S6 should also have problems. So, I found another plugin for Cordova to save images, which is similar to a local phone that saves the image as canvers, sets the width and height of canvers, and saves the image. It was only then that I realized: this is not a regular bug… So I put down the keyboard and began to wonder if there was a difference… WTF —- Later on, I went to Baidu to check whether Cordova has an error in saving pictures or how cordova saves pictures. The two search topics switched back and forth. However, the community of Cordova is not popular at all. First of all, the content of the answer is very few, and secondly, the answer is 16 years, 17 years, it is too old. For the current development help, can not say a little with it, at least is useless (raptor tears —–) trial and error as long as the mind does not slide, the method is more than difficult. The problem should always be solved. Later, I checked how to change Cordova and android read and write permissions. In addition, we use a cordova-plugin-android-permission to check android write authorization. We find that the write authorization has been displayed on the mobile phone with the problem. Ah… Once again the jam…. At the end of my rope, I had no way to change my mind. I thought, since I failed to save pictures, I could see if I could take screenshots on mobile phones that could not save pictures (communicate with the product again on demand). Then download a Screenshot from cordova. The cordova plugin adds…. “Command, how can not download down. Then can not do, had to use a very stupid method. Git, pull the project down and add the project locally like this: cordova plugin add ‘D:\yottal_cordova\pluginsssss\cordova-screenshot’. Download down, this try does not matter, I in the screen shot, can calculate found the problem!! Although this screenshot did not succeed, but, but, it has an error message!! I looked at it and found that there was a string of paths in front of saving the information. In the following words, I noticed twice that permission-denied. It was also a permission problem, so I fell into deep thinking again. Later, I took a closer look at the Android version. It turned out to be an Android 10 version. So, through Android 10, I found the information of Android 10 at that time









The problem!



Please note article 6!!!!! No wonder my write permission, although also have, but just can’t take effect!!!!



At this moment, I finally have some ideas. So I started to query the android native code. There is a configuration in the Android code that solves this problem. However, it is cordova.



After checking the configuration principle of Cordova, I finally added the code in an Android file (Androidmanifest.xml). android:requestLegacyExternalStorage=”true”



Finally, the anticipation for Cordova Run Android. At last, at last, success!!!!!!!!



At the moment of success, I was really happy. This bug bothered me for more than 5 hours. Keep trying, keep trying…



The bug was not only finished, but also this event made me have a new perception of the bug.



1. Technology stack, must choose a community complete and real-time update, otherwise, really painful.. 2. To find problems, it is not limited to the front-end code, especially in this kind of mixed development. In many cases, it is necessary to get rid of the thinking inertia of the front-end people and get rid of thinking at the code level. Mixed development problem, must pay more attention to the version of the system, whether ios or Android to say a polite word this bug is over, later, I believe there will be more bugs waiting for me.. Sometimes, the Bug we encounter is not that it can be difficult, but more importantly, we need to have the courage to overcome the Bug! The first nuggets post, for the time being summarized so much… Hopefully, this process will help you…