Skip to content

Commit

Permalink
加入代码混淆
Browse files Browse the repository at this point in the history
  • Loading branch information
ddz-mark committed Jan 16, 2017
1 parent 83bae38 commit 374a5a1
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 35 deletions.
25 changes: 23 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,33 @@ android {
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
storeFile file(StoreFile)
storePassword StorePassWord
keyAlias KeyAlias
keyPassword KeyPassword
}
}
buildTypes {
release {
minifyEnabled false
// 不显示Log
buildConfigField "boolean", "LOG_DEBUG", "false"
//混淆
minifyEnabled true
//Zipalign优化
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources true
//加载默认混淆配置文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}

repositories {
flatDir {
dirs 'libs'
Expand Down Expand Up @@ -84,7 +105,7 @@ dependencies {
provided 'javax.annotation:jsr250-api:1.0'
//数据库
compile files('libs/systembartint-1.0.3.jar')
//内存检测,界面卡顿
//检测库
debugCompile 'com.github.moduth:blockcanary-android:1.2.1'
releaseCompile 'com.github.moduth:blockcanary-no-op:1.2.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
Expand Down
220 changes: 220 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,223 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
################gson##################
#-libraryjars libs/gson-2.3.1.jar
#-keep class com.google.gson.** {*;}
#-keep class com.google.**{*;}
#-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }
#-keep class com.google.gson.examples.android.model.** { *; }
#-keep class com.google.** {
# <fields>;
# <methods>;
#}

-ignorewarnings # 忽略警告,避免打包时某些警告出现
-optimizationpasses 5 # 指定代码的压缩级别
-dontusemixedcaseclassnames # 是否使用大小写混合
-dontskipnonpubliclibraryclasses # 是否混淆第三方jar
-dontpreverify # 混淆时是否做预校验
-verbose # 混淆时是否记录日志

-keepattributes EnclosingMethod

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-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 com.android.vending.licensing.ILicensingService

-keep public class * extends cn.owen.consultant.bean.BaseBean
-keep public class cn.owen.consultant.bean.** {*;}
-keep public class cn.owen.consultant.R$*{
public static final int *;
}

-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class * implements java.io.Serializable{
public protected private *;
}

-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Dialog
-keep public class * extends android.view

-keepattributes *Annotation*
-dontwarn com.google.gson.**
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }

# 自己应用下的domain包下所有类都要过滤
-keep class com.dudaizhong.news.modules.gank.domain.**{*;}
-keep class com.dudaizhong.news.modules.login.domain.**{*;}
-keep class com.dudaizhong.news.modules.main.domain.**{*;}
-keep class com.dudaizhong.news.modules.zhihu.domain.**{*;}

-keep class com.google.gson.** { *;}
#这句非常重要,主要是滤掉 com.bgb.scan.model包下的所有.class文件不进行混淆编译
-keep class com.bgb.scan.model.** {*;}

#############leancloud###################
-keepattributes Signature
-dontwarn com.jcraft.jzlib.**
-keep class com.jcraft.jzlib.** { *;}

-dontwarn sun.misc.**
-keep class sun.misc.** { *;}

-dontwarn com.alibaba.fastjson.**
-keep class com.alibaba.fastjson.** { *;}

-dontwarn sun.security.**
-keep class sun.security.** { *; }

-dontwarn com.google.**
-keep class com.google.** { *;}

-dontwarn com.avos.**
-keep class com.avos.** { *;}

-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient

-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient

-dontwarn android.support.**

-dontwarn org.apache.**
-keep class org.apache.** { *;}

-dontwarn org.jivesoftware.smack.**
-keep class org.jivesoftware.smack.** { *;}

-dontwarn com.loopj.**
-keep class com.loopj.** { *;}

-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *;}
-keep interface com.squareup.okhttp.** { *; }

-dontwarn okio.**

-dontwarn org.xbill.**
-keep class org.xbill.** { *;}

-keepattributes *Annotation*

################BugTags##################
-keepattributes LineNumberTable,SourceFile
-keep class com.bugtags.library.** {*;}
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.bugtags.library.**
-dontwarn com.bugtags.library.vender.**
-keepattributes LineNumberTable,SourceFile

################APPSEE##################
-keep class com.appsee.** { *; }
-dontwarn com.appsee.**

-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

# ========== support-v4 ==========
#-libraryjars libs/android-support-v4.jar
-dontwarn android.support.v4.**
-keep class android.support.v4.** {*;}
-keep interface android.support.v4.app.** {*;}
# ================================


# 第三方 jar 包
#-dontwarn retrofit.**
#-keep class retrofit.** { *; }
#-keepattributes Signature
#-keepattributes Exceptions
#
#-dontwarn com.squareup.okhttp.**
#-keep class com.squareup.okhttp.** { *;}
-dontwarn okio.**

-dontwarn retrofit2.**
-keep class retrofit2.**{*;}
-keepattributes Signature
-keepattributes Exceptions

-dontwarn okhttp3.**
-keep class okhhtp3.**{*;}

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}

-keep class com.github.mikephil.charting.** { *; }

# ================================

-keep class com.dudaizhong.news.common.widget.LoadMoreRecyclerView.**{*;}
-keep class com.dudaizhong.news.common.widget.AutoPlayViewPager.**{*;}
-keep class com.dudaizhong.news.common.widget.CharAvatarView.**{*;}
-dontwarn com.readystatesoftware.systembartint.SystemBarTintManager.**
-keep class com.readystatesoftware.systembartint.SystemBarTintManager.**{*;}

# webview + js
-keepattributes *JavascriptInterface*
# keep 使用 webview 的类
-keepclassmembers class com.veidy.activity.WebViewActivity {
public *;
}
# keep 使用 webview 的类的所有的内部类
-keepclassmembers class com.veidy.activity.WebViewActivity$*{
*;
}
# Glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-dontwarn com.bumptech.glide.**
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
Expand All @@ -12,11 +11,10 @@
import com.dudaizhong.news.base.BaseActivity;
import com.dudaizhong.news.base.utils.ToastUtil;
import com.dudaizhong.news.base.utils.rxUtils.RxBus;
import com.dudaizhong.news.modules.login.domain.event.RefreshEvent;
import com.dudaizhong.news.modules.event.RefreshEvent;
import com.dudaizhong.news.modules.login.presenter.contract.LoginContract;
import com.dudaizhong.news.modules.login.presenter.LoginPresenter;
import com.dudaizhong.news.modules.main.activity.MainActivity;
import com.orhanobut.logger.Logger;

import butterknife.Bind;
import butterknife.OnClick;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
import android.os.Bundle;
import android.os.Process;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.dudaizhong.news.R;
import com.dudaizhong.news.app.Constants;
import com.dudaizhong.news.base.BaseActivity;
Expand All @@ -31,13 +26,11 @@
import com.dudaizhong.news.common.widget.CharAvatarView;
import com.dudaizhong.news.modules.gank.fragment.GankFragment;
import com.dudaizhong.news.modules.login.activity.LoginActivity;
import com.dudaizhong.news.modules.login.domain.event.RefreshEvent;
import com.dudaizhong.news.modules.event.RefreshEvent;
import com.dudaizhong.news.modules.setting.SettingActivity;
import com.dudaizhong.news.modules.zhihu.fragment.ZhihuFragment;

import butterknife.Bind;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.CropCircleTransformation;
import rx.Subscription;
import rx.functions.Action1;

Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
StoreFile=sign.jks
StorePassWord=ddz19960605!
KeyAlias=markable
KeyPassword=ddz19960605!

0 comments on commit 374a5a1

Please sign in to comment.