- SDK "Pit not pit"?
- SDK "Hard not hard"?
- How do I encapsulate the user interface?
- Android Studio Packaging confuses AAR
1. SDK "Pit not pit"?
People who have not been in touch with SDK development may not feel that SDK development is time-consuming and less fulfilling. What you write, the end result you can't see. Most importantly, when an SDK is finished, you feel like you're not getting anything? (a little exaggerated) when it comes to normal apk development, the SDK is still a bit of a pit.
2. SDK "Hard not hard"?
In the Eclipse era, how do I load classes? How do I load resources? How to make developers faster and easier to access? is still more difficult.
3. How do I encapsulate the user interface?
The above two points are all in the pull. So, how do you make your SDK more secure? Make your logic completely transparent to the user?
* Make good use of confusion
* Builder mode
Let's look at the directory structure of my sdkdemo.
The overall architecture uses MVP. Recently, like using this model, better understanding than MVC, decoupling is better, is the interface to write a bit more. Focus on the admin package. The main function of this package is to expose to the user. This means that all API interfaces provided to the user in the SDK are written in this package. When confusing, just ignore this one package. Builder mode to build user interface, the pros and cons don't have to say much. The only key point to mention is a small detail.
@OverridePublicvoidGotoactvity (Context context) {if (Constant.sdkInstance.getUserAppName () = = null) throw new illegalargumentexception ( " Userappname can not be null "); if (Constant.sdkInstance.getUserChannel () = = null) throw new illegalargumentexception ( " Userchannel can not be null "); if (Constant.sdkInstance.getUserKey () ==null) throw new illegalargumentexception (new Intent (context, sdkactivity.class); context.startactivity (Intent);}
Like this anomaly must run out to let the caller see, will make you save a lot of trouble. Demo I'll post it at the end.
4.Android Studio Packaging confuses AAR
First configure the confusion, configure it in your SDK project Build.gradle,
Next Configure your Proguard-rules.pro file, here to provide a template Oh, http://www.jianshu.com/p/f3455ecaa56e very good. Then you can generate the AAR package, first you can run the next project (this is too low). Or you can enter Gradlew under the console.
Eventually your AAR will spawn here ...
By the way, how to use AAR?
For specific code details, see GitHub reprint: David_dyk
: Https://github.com/duanyikang/Develop-SDK
Overview of the Android SDK authoring process