「Android/開発環境/AndroidStudio/proguard」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==プロガードとは== コードをjarやaarにしたときにプロパティ名や、メソッド名などを難読化するもの ==サンプル== プロジェク...」) |
(→サンプル) |
||
| (同じ利用者による、間の3版が非表示) | |||
| 行1: | 行1: | ||
| − | == | + | ==proguard(プロガード)とは== |
| − | + | *コードをjarやaarにしたときにプロパティ名や、メソッド名などを難読化するもの。 | |
| + | *jarやaarを配布する際に使う。 | ||
| + | *unityやcocos2dなどで使うjarやaarを難読化しないためにする際に使う。 | ||
==サンプル== | ==サンプル== | ||
| 行15: | 行17: | ||
proguard-rules.pro | proguard-rules.pro | ||
| + | #ExampleClassのメソッド・プロパティの難読化を除外する | ||
| + | -keep public class jp.co.example.ExampleClass { | ||
| + | public *; | ||
| + | } | ||
| + | #KzLogのメソッド・プロパティの難読化を除外する | ||
| + | -keep public class jp.co.example.sample.log.KzLog { | ||
| + | public *; | ||
| + | } | ||
| + | # protectedの難読化を除外する | ||
| + | -keep public class jp.co.example.sample.log.AbstructDao { | ||
| + | protected *; | ||
| + | } | ||
| + | # KZ_CONST_VERSIONのconstの難読化を除外する | ||
| + | -keep public class jp.co.example.sample.const.KzConstants { | ||
| + | public static final ** KZ_VERSION; | ||
| + | } | ||
| + | # interfaceの難読化を除外する | ||
| + | -keep public interface * { | ||
| + | *; | ||
| + | } | ||
2019年8月23日 (金) 12:38時点における最新版
proguard(プロガード)とは
- コードをjarやaarにしたときにプロパティ名や、メソッド名などを難読化するもの。
- jarやaarを配布する際に使う。
- unityやcocos2dなどで使うjarやaarを難読化しないためにする際に使う。
サンプル
プロジェクト直下のbuild.gradle
android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
proguard-rules.pro
#ExampleClassのメソッド・プロパティの難読化を除外する
-keep public class jp.co.example.ExampleClass {
public *;
}
#KzLogのメソッド・プロパティの難読化を除外する
-keep public class jp.co.example.sample.log.KzLog {
public *;
}
# protectedの難読化を除外する
-keep public class jp.co.example.sample.log.AbstructDao {
protected *;
}
# KZ_CONST_VERSIONのconstの難読化を除外する
-keep public class jp.co.example.sample.const.KzConstants {
public static final ** KZ_VERSION;
}
# interfaceの難読化を除外する
-keep public interface * {
*;
}
