0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

proguardで動作しない時の確認事項

Last updated at Posted at 2017-10-15

 javaFXプロジェクトをエクスポートして、作成されたjarファイルを難読化しようとしてハマった話。
 結論から言うと、proguardで難読化した際にアノテーションが消えていたのが原因。対策としては、まず、下記の様な何もしない設定で難読化してみた。

# sample.pro
# 何もしない設定

-injars  'C:\******\input.jar'
-outjars 'C:\******\output.jar'

# 外部jar
-libraryjars 'C:\Program Files\Java\jdk1.8.0_144\jre\lib\rt.jar'
-libraryjars 'C:\****\*****.jar'
-libraryjars 'C:\****\*****.jar'

# 属性設定
-keepattributes *Annotation*, Signature, Exceptions, InnerClass

# クラス設定
-keep class * {
    *;
}

これで動作しない場合は、jarファイルの設定が間違っている可能性がある。
動作する場合は、ここから難読化する部分を除いていく。
例えば、下記の様にパッケージごとに分類して、それぞれ個別に設定するなど。

$sample2.pro
# パッケージごとに個別設定

-injars  'C:\******\input.jar'
-outjars 'C:\******\output.jar'

# 外部jar
-libraryjars 'C:\Program Files\Java\jdk1.8.0_144\jre\lib\rt.jar'
-libraryjars 'C:\****\*****.jar'
-libraryjars 'C:\****\*****.jar'

# 属性設定
-keepattributes *Annotation*, Signature, Exceptions, InnerClass

# クラス設定
-keep class package1.* { *;}
-keep class package2.* { *;}
-keep class package3.* { *;}
-keep class package4.* { *;}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?