Proguard 混淆时保持类“实现”
Posted
技术标签:
【中文标题】Proguard 混淆时保持类“实现”【英文标题】:Keep class "implements" when Proguard obfuscating 【发布时间】:2015-08-16 14:44:30 【问题描述】:我的问题是在 Proguard 混淆 运行后更改了类定义 (注意当 -dontobfuscate 开启时它不会改变!)。
package com.google.ads.mediation.inmobi;
...
import com.google.ads.AdSize;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.mediation.MediationAdRequest;
import com.google.ads.mediation.MediationBannerAdapter;
import com.google.ads.mediation.MediationBannerListener;
import com.google.ads.mediation.MediationInterstitialAdapter;
import com.google.ads.mediation.MediationInterstitialListener;
import com.google.ads.mediation.inmobi.InMobiAdapterExtras;
import com.google.ads.mediation.inmobi.InMobiAdapterServerParameters;
import com.inmobi.commons.AnimationType;
import com.inmobi.commons.GenderType;
import com.inmobi.commons.InMobi;
import com.inmobi.monetization.IMBanner;
import com.inmobi.monetization.IMBannerListener;
import com.inmobi.monetization.IMErrorCode;
import com.inmobi.monetization.IMIncentivisedListener;
import com.inmobi.monetization.IMInterstitial;
import com.inmobi.monetization.IMInterstitialListener;
import com.inmobi.monetization.IMInterstitial.State;
...
public final class InMobiAdapter implements MediationInterstitialAdapter<InMobiAdapterExtras, InMobiAdapterServerParameters>, MediationBannerAdapter<InMobiAdapterExtras, InMobiAdapterServerParameters>
变成:
package com.google.ads.mediation.inmobi;
...
import com.google.ads.AdSize;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.mediation.MediationAdRequest;
import com.google.ads.mediation.MediationBannerListener;
import com.google.ads.mediation.MediationInterstitialListener;
import com.google.ads.mediation.inmobi.InMobiAdapterExtras;
import com.google.ads.mediation.inmobi.InMobiAdapterServerParameters;
import com.inmobi.commons.AnimationType;
import com.inmobi.commons.GenderType;
import com.inmobi.commons.InMobi;
import com.inmobi.monetization.IMBanner;
import com.inmobi.monetization.IMBannerListener;
import com.inmobi.monetization.IMErrorCode;
import com.inmobi.monetization.IMIncentivisedListener;
import com.inmobi.monetization.IMInterstitial;
import com.inmobi.monetization.IMInterstitialListener;
import com.inmobi.monetization.IMInterstitial.State;
...
public final class InMobiAdapter
我的 proguard 设置如下,这就是为什么 InmobiAdapter 类的代码没有被混淆的原因。但是我的 MediationInterstitialAdapter 接口等被丢弃:
> -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
> -optimizationpasses 3
> -allowaccessmodification
...
> -keep class com.google.** *;
我应该设置什么来保留 “实现 ...” 部分
【问题讨论】:
【参考方案1】:对所有界面执行此操作
-keep interface com.google.ads.mediation.MediationBannerAdapter
<methods>;
【讨论】:
以上是关于Proguard 混淆时保持类“实现”的主要内容,如果未能解决你的问题,请参考以下文章
Java 混淆 - ProGuard/yGuard/其他? [关闭]