feat:引入xmlclassguard插件及混淆辅助脚本
This commit is contained in:
@@ -4,6 +4,7 @@ apply from: '../mob.gradle'
|
||||
apply plugin: 'android-junk-code'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: "xml-class-guard"
|
||||
|
||||
android {
|
||||
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
|
||||
@@ -290,4 +291,13 @@ android.applicationVariants.all { variant ->
|
||||
stringCount = 300 //生成string数量
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//以下均为非必须
|
||||
xmlClassGuard {
|
||||
findAabConstraintReferencedIds = false
|
||||
//用于增量混淆的 mapping 文件
|
||||
mappingFile = file("xml-class-mapping.txt")
|
||||
//更改manifest文件的package属性,即包名
|
||||
packageChange = ["com.nnbc123.app": "app.yinm.chat"]
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ buildscript {
|
||||
classpath "com.github.qq549631030:android-junk-code:1.0.7"
|
||||
classpath 'com.google.gms:google-services:4.3.15'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
|
||||
classpath "com.github.liujingxing:XmlClassGuard:1.2.6"
|
||||
}
|
||||
}
|
||||
|
||||
|
18
find_same_name_file.sh
Normal file
18
find_same_name_file.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
sh gradlew clean
|
||||
all_java_file=$(find ./ -name \*.java)
|
||||
echo "\n**********"
|
||||
echo "$all_java_file"
|
||||
echo "\n**********"
|
||||
same_name_file=$(echo "$all_java_file" | awk -F "/" '{print $NF}' | awk 'a[$0]++{print}' | sort | uniq)
|
||||
echo "\n**********"
|
||||
echo "$same_name_file"
|
||||
echo "\n**********"
|
||||
touch same_name_file.txt
|
||||
cat /dev/null > same_name_file.txt
|
||||
for n in ${same_name_file[*]}
|
||||
do
|
||||
echo "$all_java_file" | grep '/'"$n" >> same_name_file.txt
|
||||
done
|
||||
|
53
gen_move_dir.sh
Normal file
53
gen_move_dir.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
same_name_files=$(cat same_name_file.txt)
|
||||
touch move_dir_map.txt
|
||||
cat /dev/null > move_dir_map.txt
|
||||
echo "[" >> move_dir_map.txt
|
||||
|
||||
end_with=(' ' '{' '.')
|
||||
|
||||
cp proguard_rules.txt proguard_rules_after_move_dir.txt
|
||||
|
||||
for file in ${same_name_files[*]}
|
||||
do
|
||||
echo "**********\n"
|
||||
|
||||
echo '文件 - '"$file"
|
||||
|
||||
split_str="/java"
|
||||
is_contain=$(echo "$file" | grep "$split_str")
|
||||
if [[ "$is_contain" == "" ]]
|
||||
then
|
||||
split_str="/src"
|
||||
fi
|
||||
|
||||
import_str=$(echo "$file" | awk -F "${split_str}/" '{print $2}' | awk -F "." '{print $1}' | sed 's/\//\./g')
|
||||
class_name=$(echo "$import_str" | awk -F "." '{print $NF}')
|
||||
package_path=$(echo "$import_str" | awk -F ".${class_name}" '{print $1}' )
|
||||
echo '包名 - '"$package_path"
|
||||
|
||||
is_gen=$(cat move_dir_map.txt | grep "$package_path")
|
||||
if [[ "$is_gen" != "" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
file_md5=$(echo "$file" | md5 | sed 's/[0-9]//g')
|
||||
|
||||
echo '新包名 - '"$file_md5"
|
||||
|
||||
for endStr in ${end_with[*]}
|
||||
do
|
||||
sed_format_package_path=$(echo "$package_path""$endStr" | sed 's/\./\\\./g')
|
||||
replace_str=$(echo "$file_md5""$endStr" | sed 's/\./\\\./g')
|
||||
sed -i "" "s/${sed_format_package_path}/${replace_str}/g" proguard_rules_after_move_dir.txt
|
||||
done
|
||||
|
||||
echo '"'"$package_path"'" : "'"$file_md5"'",' >> move_dir_map.txt
|
||||
|
||||
echo "\n**********"
|
||||
done
|
||||
|
||||
echo "]" >> move_dir_map.txt
|
26
map_bean_proguard_rules.sh
Normal file
26
map_bean_proguard_rules.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
grep_result=$(cat app/xml-class-mapping.txt | grep bean)
|
||||
|
||||
touch bean_proguard_rules.txt
|
||||
|
||||
cat /dev/null > bean_proguard_rules.txt
|
||||
|
||||
echo "$grep_result" | while read LINE
|
||||
do
|
||||
classes=$(echo "$LINE" | awk -F ".bean -> " '{print $2}')
|
||||
for c in ${classes[*]}
|
||||
do
|
||||
echo '-keep class '"$c"'.** {*;}' >> bean_proguard_rules.txt
|
||||
done
|
||||
|
||||
classes2=$(echo "$LINE" | awk -F " -> " '{print $2}')
|
||||
for c in ${classes2[*]}
|
||||
do
|
||||
containDot=$(echo "$c" | grep '\.')
|
||||
if [[ "$containDot" != "" ]]
|
||||
then
|
||||
echo '-keep class '"$c"' {*;}' >> bean_proguard_rules.txt
|
||||
fi
|
||||
done
|
||||
done
|
33
search_proguard_rules.sh
Normal file
33
search_proguard_rules.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
project_proguard_file=./app/proguard-rules.pro
|
||||
package_list=('com.nnbc123' 'com.chu' 'com.zhihu.matisse' 'com.tongdaxing' 'com.example' 'com.soundcloud' 'com.netease.nim.uikit')
|
||||
|
||||
echo ' '
|
||||
echo '***** search proguard rules *****'
|
||||
echo ' '
|
||||
echo 'search proguard rules in '"$project_proguard_file"
|
||||
echo ' '
|
||||
echo 'search this packages:'
|
||||
echo "$package_list"
|
||||
echo ' '
|
||||
|
||||
touch proguard_rules.txt
|
||||
cat /dev/null > proguard_rules.txt
|
||||
|
||||
for p in ${package_list[*]}
|
||||
do
|
||||
echo "********************"
|
||||
echo 'search '"$p"':'
|
||||
echo ' '
|
||||
cat "$project_proguard_file" | grep "$p" >> proguard_rules.txt
|
||||
echo "********************"
|
||||
echo ' '
|
||||
done
|
||||
|
||||
echo ' '
|
||||
echo '***** search proguard rules finished *****'
|
||||
echo ' '
|
||||
echo 'check search result in proguard_rules.txt'
|
||||
echo ' '
|
||||
|
0
xml-class-mapping.txt
Normal file
0
xml-class-mapping.txt
Normal file
Reference in New Issue
Block a user