The two functions of Flutter are wechat login and wechat pay. This requires access to the SDK related to wechat. A corresponding plug-in, Fluwx, is implemented in Flutter. There were no major problems in the development and integration, and the testing was perfect. Wechat login and wechat pay went well. But here’s the thing: iOS phones are fine, and so are most Android models, except OPPO and some OnePlus models. The phenomenon is: cannot arouse the wechat login, cannot carry on the wechat pay.

Problem orientation

As you know as a developer, compatibility issues can be the most head-turning.

First of all, in the case that there is no problem with iOS and most Android, it indicates that there is no problem with the configuration of wechat AppID and signature, otherwise it should all fail.

Second, the problem is that there is no OPPO or OnePlus phone that can reproduce the problem. So I can’t use the real machine to link to the computer to see the output log, which is the problem.

So it’s just a matter of checking the code repeatedly to see how it differs from other people’s code, from the FluwX example code.

Code review

// Post only the key code
import 'package:fluwx/fluwx.dart';
void init() {
  // Initialize wechat SDK
  registerWxApi(appId: "mine appId",universalLink: "https://mine.test.com/xxx")
      .then((value) {
        print("To register wechat:$value");
      });
  isWeChatInstalled.then((value) {
    setState(() {
      Constants.isWeChatInstalled = value;
    });
  });
}
Copy the code

From a code point of view, it’s no different than the FluwX example, because if the code is wrong and it doesn’t work, then all the models should fail. So can’t get the real machine, can only be through the pop-up output log way to see where the problem is. So I’m doing a pop-up output in the registerWxApi callback, the isWeChatInstalled callback, and the last pop-up output is isWeChatInstalled False. Check whether the installation of wechat fails.

Here I made the mistake of not delaying my popup, so the output from the registerWxApi callback was overwritten by the popup from the isWeChatInstalled callback. So I thought the registerWxApi callback was not executed, so I didn’t pay much attention to this place.

When the isWeChatInstalled callback is deleted, only the registerWxApi callback is left. When the registerWxApi callback is displayed, the registered wechat: false is output. That doesn’t make sense. Why are other phones able to register successfully? Some OPPO models will also succeed.

At this time, I was still guessing whether there was a problem with the version of FluwX. I found my friend’s app, which was also developed with Fluwx, and there was no problem with his wechat login on the faulty OPPO. Therefore, the FluwX version has been degraded and upgraded, respectively tried, or not. My friend missed something while doing a code comparison.

In fact, at this point should be considered is the Android system version of the incompatible problem. For the same machine, some can take effect, and some fail, indicating that the Android system must be compatible with the problem.

This period also look for friends of friends borrowed a OPPO phone, carries on the real machine debugging, finally can see WeChat register output error messages, signature verification failed: E/MicroMsg SDK. WXApiImplV10 (17142) : register app failed for wechat app signature check failed

Problem solving

Later, I found a similar problem when SEARCHING in the open community of wechat:

Found the answer in the comment section, but not the official reply, haha! However, the official wechat document is indeed written in this case.

In the end, we solved the problem by adding the

tag to the main project’s Androidmanifest.xml and configuring the wechat package name. This is what I mentioned above, my friend did not pay attention to this configuration file when doing code comparison!

<manifest package="com.example.app">
    <queries>
        <! -- Specify the wechat package name -->
        <package android:name="com.tencent.mm" />
    </queries>
</manifest>
Copy the code

The problem summary

  • Real machine debugging efficiency is the highest, can the fastest location of the problem where
  • When you encounter problems, start with the official documents involved, which is the most first-hand information