Skip to content

Repository files navigation

一、打包加固说明

1.多渠道打包加固 -> 爱加密:http://www.ijiami.cn 2.腾讯乐固 https://console.cloud.tencent.com/ms/reinforce/tool

gradle签名打包:https://blog.csdn.net/xuwb123xuwb/article/details/78195315 V1:可对签名后的文件,作适当修改,并重新压缩。 V2:不能对签名后的 APK作任何修改,包括 zipalign。因为它是针对字节进行的签名,所以任何改动都会影响最终结果。 Signature Versions不能只选择 V2(Full APK Signature),应该选择V1(Jar Signature),或者选择 V1和 V2。

多渠道打包:

apk体积优化:

比较打包的签名MD5的值是否一致:

gradle config.gradle 全局配置 (参考:https://www.jianshu.com/p/246542472cf3)

// 其他模块引入(头部声明)
def ext = rootProject.ext
def android = ext.android
def dependVersion = ext.dependVersion
//v7包和v4包
// Support库
api rootProject.ext.supportLibs
// 网络请求库
api rootProject.ext.networkLibs
// RxJava2
api rootProject.ext.rxJavaLibs
// commonLibs
api rootProject.ext.commonLibs
ext {
android = [
compileSdkVersion: 28,
buildToolsVersion: "28.0.3",
minSdkVersion : 16,
targetSdkVersion : 27,
versionCode : 1,
versionName : "1.0.0"
]
dependVersion = [
androidSupportSdkVersion: "28.0.0",
espressoSdkVersion : "3.0.2",
retrofitSdkVersion : "2.4.0",
glideSdkVersion : "4.8.0",
rxJava : "2.2.2",
rxAndroid : "2.1.0",
rxKotlin : "2.3.0",
anko : "0.10.7"
]
supportDeps = [
"supportv4" : "com.android.support:support-v4:${dependVersion.androidSupportSdkVersion}",
"appcompatv7" : "com.android.support:appcompat-v7:${dependVersion.androidSupportSdkVersion}",
"cardview" : "com.android.support:cardview-v7:${dependVersion.androidSupportSdkVersion}",
"design" : "com.android.support:design:${dependVersion.androidSupportSdkVersion}",
"constraint-layout": "com.android.support.constraint:constraint-layout:1.1.3",
"annotations" : "com.android.support:support-annotations:${dependVersion.androidSupportSdkVersion}"
]
retrofit = [
"retrofit" : "com.squareup.retrofit2:retrofit:${dependVersion.retrofitSdkVersion}",
"retrofitConverterGson" : "com.squareup.retrofit2:converter-gson:${dependVersion.retrofitSdkVersion}",
"retrofitAdapterRxjava2" : "com.squareup.retrofit2:adapter-rxjava2:${dependVersion.retrofitSdkVersion}",
"okhttp3LoggerInterceptor": 'com.squareup.okhttp3:logging-interceptor:3.11.0',
"retrofitConverterMoshi" : 'com.squareup.retrofit2:converter-moshi:2.4.0',
"retrofitKotlinMoshi" : "com.squareup.moshi:moshi-kotlin:1.7.0"
]
rxJava = [
"rxJava" : "io.reactivex.rxjava2:rxjava:${dependVersion.rxJava}",
"rxAndroid": "io.reactivex.rxjava2:rxandroid:${dependVersion.rxAndroid}",
"rxKotlin" : "io.reactivex.rxjava2:rxkotlin:${dependVersion.rxKotlin}",
"anko" : "org.jetbrains.anko:anko:${dependVersion.anko}"
]
testDeps = [
"junit" : 'junit:junit:4.12',
"runner" : 'com.android.support.test:runner:1.0.2',
"espresso-core" : "com.android.support.test.espresso:espresso-core:${dependVersion.espressoSdkVersion}",
"espresso-contrib" : "com.android.support.test.espresso:espresso-contrib:${dependVersion.espressoSdkVersion}",
"espresso-intents" : "com.android.support.test.espresso:espresso-intents:${dependVersion.espressoSdkVersion}",
"leakcanary-debug" : 'com.squareup.leakcanary:leakcanary-android:1.6.1',
"leakcanary-release" : 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1',
"leakcanary-debug-fragment": 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.1',
"debug-db" : 'com.amitshekhar.android:debug-db:1.0.4'
]
commonDeps = [
"multidex": 'com.android.support:multidex:1.0.3',
"logger" : 'com.orhanobut:logger:2.2.0',
"glide" : 'com.github.bumptech.glide:glide:4.8.0',
"eventbus": 'org.greenrobot:eventbus:3.1.1',
"spinkit" : 'com.github.ybq:Android-SpinKit:1.2.0',
"arouter" : 'com.alibaba:arouter-api:1.4.0'
]
otherDeps = [
"arouter-compiler": 'com.alibaba:arouter-compiler:1.2.1'
]
supportLibs = supportDeps.values()
networkLibs = retrofit.values()
rxJavaLibs = rxJava.values()
commonLibs = commonDeps.values()
}

php提供的下载apk接口无法获取apk总大小的问题(gzip 导致 无法返回 Content-Length) // 链接说明:https://blog.csdn.net/CodeTraveller/article/details/84850218 1.Apache: httpd.conf 如果是虚拟服务服务器.htaccess

 <IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json #对指定的内容进行压缩,压缩方式为默认的一个方法
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary
</IfModule>

2.nginx:

 gzip on; #开启gzip
gzip_min_length 1k; #低于1kb的资源不压缩
gzip_comp_level 3; #压缩级别【1-9】,越大压缩率越高,同时消耗cpu资源也越多,建议设置在4左右。
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; #需要压缩哪些响应类型的资源,多个空格隔开。不建议压缩图片,下面会讲为什么。
gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
gzip_vary on; #是否添加“Vary: Accept-Encoding”响应头

3.文件下载

 public function download() {
$fileURL = ROOT_PATH."public/apk/test.apk";
$this -> downloads($fileURL);
// return $this ->fetch();
}
//下载apk
function downloads($filename) {
$file = fopen($filename, 'r');
$size = filesize($filename);
$showname = "download.apk";
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Content-Disposition: attachment; filename=".$showname);
header("Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header("Pragma: public" );
header("Accept-Length:".$size);
header('Content-Length: ' . $size);
echo readfile($filename);
// echo fread($file, $size);
// fcolse($file);
exit;
}

二、第三方框架整理

平板应用
热更新
Github app 实现 Redux
MVP的变形
代码模板
面向AOP切面编程
支付
框架
拍照、图片选择
常用的小组件
组件化
使用引导
状态栏
popupWindow&Dialog
下载器
二维码扫描
动态权限
分页tab查看
多状态提示
日志写法方案
刷新框架:
工具库:
数据库
侧滑菜单:
弹窗:
图片:
布局:
pickerView
轮播图:
跑马灯
webView
角标
文件下载框架:
图片或视频选择
视频播放器:
蓝牙
日志打印:
fragment:
注解:
Rx
事件总线
图表
JSON
动画

三、优化

四、具有参考性的项目

五、适配

屏幕适配
约束布局(减少嵌套,提高性能)
全面屏和刘海屏适配

1.全面屏适配 AndroidManifest.xml中的application配置 android:resizeableActivity="true"

<meta-data android:name="android.notch_support" android:value="true"/>
<meta-data
android:name="android.max_aspect"
android:value="2.4" />

2.刘海屏适配

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (getWindow() != null) {
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(lp);
}
}

布局调整 参考:https://github.com/LuckyYangChen/AdaptNotch

android 9.0 (Build.VERSION_CODES.P)适配

参考:https://www.jianshu.com/p/9e9e902ea039

1.网络适配 res下添加xml目录,并添加network_security_config.xml文件, 最后在AndroidManifest.xml中的application配置 android:networkSecurityConfig="@xml/network_security_config"

<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
android 8.0适配
android 7.0适配
android 6.0适配
软键盘适配
jdk 8 的新特性
模拟器

六、进阶

七、面试

八、串口通信

九、NDK环境安装

About

安卓电商通用框架

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages