富贵竹三期文档介绍:
此文档为富贵竹三期(四期)第一个版本的文档,版本号为2.0,补充了出插件的注意事项,请每次出插件时,要仔细阅览此文档!
总体流程图概况:
富贵竹流程图.png项目下载的SVN地址
Sanderiana:https://172.18.0.18/repos/android/banner/branches/Sanderiana
ISBanner:https://172.18.0.18/repos/android/banner/branches/ISBanner
富贵竹三期插件对外提供的接口:
public interface IStartBanner {
void init(Context context, String path, String packName);
void show(Context context, String data);
void onDestroyWindow();
void onStop();
void setDebug(boolean debug);
}
客户端接口说明:
接口 | 调用时机及作用 | 参数说明 |
---|---|---|
init | [资源初始化方法,在Activity生命周期开始前调用 | 1.上下文(ApplicationContext);2.res资源路径;3.res资源文件的包名(给GetResource类初始化) |
show | 展示布局的方法,通过Window显示 | 1.上下文对象;2.从服务端请求的json数据 |
onDestroyWindow | 销毁Window时的调用 | 无参数 |
onStop | 解注册广播 | 无参数 |
setDebug | 设置调试模式,决定是否显示Log | boolean类型的参数 |
服务端Json数据格式说明:
{
"cnf": {
"dgfly": {
"adtype": "bb",
"name": "",
"show_type": "bb_inMode_jgz",
"icon_img": "http:\/\/tang123.oss-cn-shanghai.aliyuncs.com\/cayt\/aaec0be0.jpg",
"ad_img": [
"http:\/\/tang123.oss-cn-shanghai.aliyuncs.com\/bb\/aaec0be0\/image-0.jpg"
],
"desc": "",
"w": 2076,
"h": 1466,
"s_dur": 5000,
"down_url": "http:\/\/baidu.com",
"dplnk": "",
"rtp": false,
"rtp1": false,
"ia": 0,
"s_rpt": ["http:\/\/139.196.171.67:5678\/dgfly_rpt.php?act=s&adid=591029c6&cp=AA067&did=869552024567992&aid=4b09c31a51b68e0f"],
"c_rpt": [
"http:\/\/139.196.171.67:5678\/dgfly_rpt.php?reqid=1526452646.144426.51d29&act=c&dl_si=0&adci=0&is_wifi=1&ad=AdvTable&u_ad_type=1&adid=aaec0be0&cp=AA067&did=864664036476149&aid=1d2352423ddb4a20"
],
"d_rpt": [],
"dc_rpt": [],
"i_rpt": [],
"a_rpt": [
"http:\/\/139.196.171.67:5678\/dgfly_rpt.php?reqid=1526452646.144426.51d29&act=a&dl_si=0&adci=0&is_wifi=1&ad=AdvTable&adid=aaec0be0&cp=AA067&did=864664036476149&aid=1d2352423ddb4a20"
],
"o_rpt": [
"http:\/\/139.196.171.67:5678\/dgfly_rpt.php?act=o&dl_si=0&adci=0&is_wifi=1&ad=AdvTable&adid=aaec0be0&cp=AA067&did=864664036476149&aid=1d2352423ddb4a20"
],
"ad_pack": "banner",
"ad_ver": "",
"vsb": true,
"dlsign": true,
"logo": true,
"is_act": "1",
"ci": "1",
"in_broser": false,
"cl": 1,
"bb_area": true,
"aicnf": []
}
}
}
核心的字段是show_type,根据这个showType来确定需要显示的布局类型,代码如下:
void buildView(String type) {
switch (type) {
case VIDEO_AD:
mBannerView = new RichRollVideoView();
break;
case RichConstant.VIDEO_VIEW_AD:
mBannerView = new RichVideoView();
break;
case RichConstant.BB_BANNER:
case RichConstant.BB_BANNER_APP:
case RichConstant.BB_BANNER_WEB:
mBannerView = new RichFitView(ROLL);
break;
最终的调用代码是:FloatWindowManager.getInstance().show(this, object);//this就是上一步所生成的View(比如:RichChaferView),object是根据服务端json转换的类
富贵竹三期插件生成注意事项:
1.插件打进去的第三方包,前提是需要知道母包中是否存在,如果存在则不需要;
2.插件中不能包含有android.support.v4包的任何类,如果有,需要删除或者从源代码中扣出来;
3.res资源文件中不能有Android5.0以上的新控件,比如RecyclerVIew,另外这些新控件需要自定义,同时在代码中动态添加;
4.插件中的类不应该有需要在清单文件中注册的类,比如FileProvider,如果有这样的类,就不能生成插件;
5.混淆的类需要搞清除哪些需要混淆,哪些不需要混淆;
6.富贵竹三期的插件应该包含二期的功能,也就是SDK支持下载类的广告,所以生成三期插件时候,应该把downloader.jar这个包也打进去;
7.富贵竹整个插件是采取版本覆盖的方式,所以出最新的插件时候,一定要自己测试下以前插件所包含的内容,另外要确保插件需要的jar包都打进去了,因此测试用例一定要跑;
8.给晓军的资源文件res必须再他提供的基础上增加或替换,图片资源要压缩以便减少插件体积;
富贵竹三期打包的核心代码:
BuildJar {
//输出目录
outputFileDir = "./jar"
//输出原始jar包名
outputFileName = "lp-depend.jar"
//输出混淆jar包名
outputProguardFileName = "lp-depend-proguard.jar"
//混淆配置
proguardConfigFile = "proguard-rules.pro"
//是否需要默认的混淆配置proguard-android.txt
needDefaultProguard = true
applyMappingFile = "originMapping/mapping.txt"
//不需要输出jar的jar包列表,如['baidu.jar','baidu1.jar'...]
excludeJar = []
//需要输出jar的包名列表,当此参数为空时,则默认全项目输出,支持多包,如 includePackage=['com/adison/testjarplugin/include','com/adison/testjarplugin/include1'...]
includePackage = ['com/sanderiana/banner', 'com/aigestudio', 'cn/aigestudio', 'com/tencent', 'com/stkj/launchminilib','de/hdodenhof','com/nostra13']
//不需要输出jar的类名列表,如['baidu.calss','baidu1.class'...]
// excludeClass=['android/support/v4/util/ArrayMap.class']
//不需要输出jar的包名列表,如 excludePackage=['com/adison/testjarplugin/exclude','com/adison/testjarplugin/exclude1'...]
// excludePackage=['android','com/stkj/test','cn/aigestudio','com/aigestudio']
}
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
implementation project(':UI')
// implementation files('libs/lp-depend-proguard.jar')
// implementation files('libs/banner1.jar')
}
富贵竹三期插件混淆的核心代码:
-keep class com.sanderiana.banner.handlers.bean.** { *;}
-keep class com.sanderiana.banner.handlers.bean.**.$*{ *;}
-keep class com.sanderiana.banner.startmanager.StartBanner{ public *; }
-keep class com.sanderiana.banner.startmanager.IStartBanner{ *; }
#-keep class com.sanderiana.banner.startmanager.*{ *; }
-keep class com.sanderiana.banner.brazen.Brazen{ *; }
-keep class com.sanderiana.banner.brazen.*{ *; }
-keep class com.sanderiana.banner.view.** { *; }
-keep class com.sanderiana.banner.api.** { *; }
-keep class com.sanderiana.banner.myswiperl.** { *; }
-keep class com.sanderiana.banner.progressbar.MyProgressBar { *; }
-keep class com.sanderiana.banner.localbcmanager.MyLocalBroadcastManager { *; }
-keep class com.sanderiana.banner.view.adapters.ChaferImageView{ *; }
-keep class com.sanderiana.banner.view.adapters.ChaferLargeImageView{ *; }
-keep class com.sanderiana.banner.view.movieadapter.** { *; }
#微信sdk
-keep class com.tencent.mm.opensdk.** {*;}
-keep class com.tencent.wxop.** {*;}
-keep class com.tencent.mm.sdk.** {*;}
#-keep class com.mediatek.*{ *; }
-keep class com.sanderiana.banner.handlers.api.*{*;}
-keepclassmembers class * {
public <init> (org.json.JSONObject);
}
-keep public class com.sanderiana.banner.R$*{
public static final int *;
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses 'com.sanderiana.banner'
-keepattributes *Annotation*
#-dontwarn sun.misc.**
#-dontwarn okio.**
-keepattributes Signature
网友评论