Skip to content

Commit

Permalink
添加 混淆配置
Browse files Browse the repository at this point in the history
  • Loading branch information
巫圣泰 committed Dec 24, 2019
1 parent f55ab9e commit f4c96fa
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ android {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
minifyEnabled true
useProguard true

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
81 changes: 81 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-optimizationpasses 5

# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames

# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses

# 这句话能够使我们的项目混淆后产生映射文件
# 包含有类名->混淆后类名的映射关系
-verbose

# 指定不去忽略非公共库的类成员
-dontskipnonpubliclibraryclassmembers

# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
-dontpreverify

# 保留Annotation不混淆
-keepattributes *Annotation*,InnerClasses

# 避免混淆泛型
-keepattributes Signature

# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable

# 指定混淆是采用的算法,后面的参数是一个过滤器
# 这个过滤器是谷歌推荐的算法,一般不做更改
-optimizations !code/simplification/cast,!field/*,!class/merging/*


# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
# 因为这些子类都有可能被外部调用
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Appliction
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.view.View
-keep public class com.android.vending.licensing.ILicensingService

-keep class * extends android.app.Fragment {
public void setUserVisibleHint(boolean);
public void onHiddenChanged(boolean);
public void onResume();
public void onPause();
}
-keep class android.support.v4.app.Fragment {
public void setUserVisibleHint(boolean);
public void onHiddenChanged(boolean);
public void onResume();
public void onPause();
}
-keep class * extends android.support.v4.app.Fragment {
public void setUserVisibleHint(boolean);
public void onHiddenChanged(boolean);
public void onResume();
public void onPause();
}

##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }


-dontwarn android.arch.**
-dontwarn io.flutter.**
2 changes: 1 addition & 1 deletion lib/member/LoanInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LoandInfo{
StringBuffer sb=new StringBuffer();
// sb.write("本金:"+Utils.formatNumber(baseMoney)+"元");
// sb.write("\n总的利息:"+ Utils.formatNumber(interestTotal)+"元");
sb.write("年利率:"+Utils.formatNumber(yearRate*100)+" %"+"元");
sb.write("年利率:"+Utils.formatNumber(yearRate*100)+" %");
if(interestYear!=0){
sb.write("\n一年的利息:"+Utils.formatNumber(interestYear)+"元");
}
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/Utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class Utils{

Expand All @@ -12,4 +13,10 @@ class Utils{

}


static void closeKeybord(BuildContext context){

FocusScope.of(context).requestFocus(FocusNode());
}

}
3 changes: 3 additions & 0 deletions lib/view/loan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:loan_calc/utils/ToastUtils.dart';
import 'package:loan_calc/utils/calc.dart';
import 'package:loan_calc/view/date_drop_down.dart';
import 'package:loan_calc/view/rate_drop_down.dart';
import 'package:loan_calc/utils/Utils.dart';

class LoanActivity extends StatelessWidget {
@override
Expand Down Expand Up @@ -49,6 +50,7 @@ class _MyLoadPageState extends State<MyLoadPage> {
String displayDetail = "";

void checkAndCalc(TapUpDetails details) {
Utils.closeKeybord(context);
if (moneyController.text.isEmpty) {
showTaost("金额不能为空");
return null;
Expand All @@ -64,6 +66,7 @@ class _MyLoadPageState extends State<MyLoadPage> {
return null;
}


double money = double.parse(moneyController.text);

int time = int.parse(timeController.text);
Expand Down

0 comments on commit f4c96fa

Please sign in to comment.