Experience summary after two years of android SDK development


Talking about SDK development experience:
1. What is SDK? Software development kits that contain specific functionality.
2. What characteristics should this toolkit have?
1- Concise and easy
to use   ①A good SDK should let users not spend too much time learning how to use it. The interface should be as simple and easy to understand as possible, including interface naming, formal parameter naming, and exception throwing. It is best to have corresponding annotations for each API. It is convenient to enter the source code to view.
  ②In addition, an SDK package (such as aar in android), it is best to have only one class open to the outside world, which is used as the entrance of the entire SDK.
  Anyway, in a word, the SDK needs to be foolish.
2- Security
  ①The SDK should not invade the host code, that is to say, the main function of the SDK should be to receive parameters and output results, and cannot modify some objects passed in when calling the API. (For example, an ArrayList is passed in, and the list is added or deleted inside the SDK. It is best not to do similar actions);
  ② Because the android apk or the aar package of the SDK can be decompiled, although Obfuscation can be used to resist decompilation a little, but it is still possible to leak core code. In this case, it is a good solution to use JNI to call the core code and put the core code in the dynamic library file so.
  ③Principle of least permissions, the permissions that do not need to be used in this SDK should not be written in the registration file.
3- Stable
  ① The iteration cycle of the SDK is relatively long, which means that a version of the SDK may be maintained for a long time. During this period, the interface should always be available.
  ② Another point, if you encounter SDK iteration, you need to delete some APIs, and you can't delete them immediately. Instead, you must first mark the method as obsolete, and then @hide it in the next iteration, or delete it directly.
  ③There are many versions of android. In order to make the SDK compatible with lower versions, sometimes it is necessary to add the minimum SDK version number that can be called to the top of some methods, or determine the current SDK version in the java code, and then go through different programs according to different versions. branch.
4- Efficient
  ① If the program runs into a certain interface of the SDK, the execution efficiency of this interface is quite low, which slows down the efficiency of the entire program execution. Then this SDK is ineligible.
  ② When writing the internal code of the SDK, you should pay attention to minimize memory loss, power loss, CPU usage, etc.; of course, if memory leaks are caused directly inside the SDK, then the SDK is definitely unqualified.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324927670&siteId=291194637