Skip to content

Commit

Permalink
Configure Proguard (#479)
Browse files Browse the repository at this point in the history
* feat: proguard configuration #476

Remove useless rules. Add safe consumers rules. Optimize shrinking.

* feat: update Prebid version to 2.0.2

Co-authored-by: Valentin Petrovych <valllentua9128@gmail.com>
  • Loading branch information
ValentinPostindustria and Valllent authored Jul 8, 2022
1 parent e10e018 commit 342ad3c
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 256 deletions.
4 changes: 1 addition & 3 deletions Example/PrebidDemoJava/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ android {
buildTypes {
debug {
minifyEnabled false
// minifyEnabled true
// proguardFiles 'proguard-rules.pro'
}
}
buildFeatures {
Expand All @@ -50,7 +48,7 @@ dependencies {
implementation project(':PrebidMobile')

// For testing staging releases
// implementation 'org.prebid:prebid-mobile-sdk:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk:2.0.2'

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.gms:play-services-ads:20.4.0'
Expand Down
Empty file.
1 change: 0 additions & 1 deletion Example/PrebidDemoKotlin/.gitignore

This file was deleted.

11 changes: 5 additions & 6 deletions Example/PrebidDemoKotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ android {
multiDexEnabled true
}
buildTypes {
release {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
Expand All @@ -36,10 +35,10 @@ dependencies {
implementation project(':PrebidMobile-maxAdapters')

// For testing staging releases
// implementation 'org.prebid:prebid-mobile-sdk:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-gam-event-handlers:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-admob-adapters:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-max-adapters:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-gam-event-handlers:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-admob-adapters:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-max-adapters:2.0.2'

// Standard libraries
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
1 change: 0 additions & 1 deletion Example/PrebidInternalTestApp/.gitignore

This file was deleted.

9 changes: 4 additions & 5 deletions Example/PrebidInternalTestApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ android {
prod {

}

}
testOptions {
animationsDisabled = true
Expand All @@ -87,10 +86,10 @@ dependencies {
implementation project(':PrebidMobile-maxAdapters')

// For testing staging releases
// implementation 'org.prebid:prebid-mobile-sdk:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-gam-event-handlers:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-admob-adapters:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk-max-adapters:2.0.1'
// implementation 'org.prebid:prebid-mobile-sdk:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-gam-event-handlers:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-admob-adapters:2.0.2'
// implementation 'org.prebid:prebid-mobile-sdk-max-adapters:2.0.2'

// Base dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
45 changes: 0 additions & 45 deletions Example/PrebidInternalTestApp/proguard-project.txt

This file was deleted.

1 change: 1 addition & 0 deletions PrebidMobile/PrebidMobile-admobAdapters/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class org.prebid.mobile.admob.*Adapter
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.Keep;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.mediation.MediationAdRequest;
import com.google.android.gms.ads.mediation.customevent.CustomEventBanner;
import com.google.android.gms.ads.mediation.customevent.CustomEventBannerListener;

import org.prebid.mobile.LogUtil;
import org.prebid.mobile.ParametersMatcher;
import org.prebid.mobile.api.data.AdFormat;
Expand All @@ -23,7 +25,6 @@

import java.util.HashMap;

@Keep
public class PrebidBannerAdapter extends PrebidBaseAdapter implements CustomEventBanner {

private static final String TAG = "PrebidBannerAdapter";
Expand Down
2 changes: 0 additions & 2 deletions PrebidMobile/PrebidMobile-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.google.android.exoplayer:exoplayer-core:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3'


}
106 changes: 12 additions & 94 deletions PrebidMobile/PrebidMobile-core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,94 +1,12 @@

# GAM
#pre GAMv20.0
-keep class com.google.android.gms.ads.doubleclick.PublisherAdRequest {
public android.os.Bundle getCustomTargeting();
}

-keep class com.google.android.gms.ads.doubleclick.PublisherAdRequest$Builder {
public com.google.android.gms.ads.doubleclick.PublisherAdRequest build();
public com.google.android.gms.ads.doubleclick.PublisherAdRequest$Builder addCustomTargeting(java.lang.String, java.lang.String);
}

#GAMv20.0
-keep class com.google.android.gms.ads.admanager.AdManagerAdRequest {
public android.os.Bundle getCustomTargeting();
}

-keep class com.google.android.gms.ads.admanager.AdManagerAdRequest$Builder {
public com.google.android.gms.ads.admanager.AdManagerAdRequest build();
public com.google.android.gms.ads.admanager.AdManagerAdRequest$Builder addCustomTargeting(java.lang.String, java.lang.String);
}


# From rendering

# This ProGuard configuration file illustrates how to process a program
# library, such that it remains usable as a library.
# Usage:
# java -jar proguard.jar @library.pro
#

# Specify the input jars, output jars, and library jars.
# In this case, the input jar is the program library that we want to process.


# Save the obfuscation mapping to a file, so we can de-obfuscate any stack
# traces later on. Keep a fixed source file attribute and all line number
# tables to get line numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.

# -printmapping out.map
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod

# Preserve all annotations.

-keepattributes *Annotation*

# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
public protected *;
}

# Preserve all .class method names.

-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
# You can comment this out if your library doesn't use serialization.
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}



# Save names for all Prebid classes
-keepnames class org.prebid.mobile.**
-keepnames interface org.prebid.mobile.**
-keepnames enum org.prebid.mobile.**

# Google Ad Manager and AdMob
-keep class org.prebid.mobile.PrebidNativeAd { *; }
-keep class com.google.android.gms.ads.admanager.AdManagerAdView { *; }
-keep class com.google.android.gms.ads.admanager.AdManagerAdRequest { *; }
-keep class com.google.android.gms.ads.admanager.AdManagerAdRequest$Builder { *; }
-keep interface com.google.android.gms.ads.nativead.NativeCustomFormatAd { *; }
-keep interface com.google.android.gms.ads.formats.NativeCustomTemplateAd { *; }
68 changes: 0 additions & 68 deletions PrebidMobile/PrebidMobile-gamEventHandlers/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
#
# This ProGuard configuration file illustrates how to process a program
# library, such that it remains usable as a library.
# Usage:
# java -jar proguard.jar @library.pro
#

# Specify the input jars, output jars, and library jars.
# In this case, the input jar is the program library that we want to process.


# Save the obfuscation mapping to a file, so we can de-obfuscate any stack
# traces later on. Keep a fixed source file attribute and all line number
# tables to get line numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.

-printmapping out.map
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod

# Preserve all annotations.

-keepattributes *Annotation*

# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
public protected *;
}

# Preserve all .class method names.

-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
# You can comment this out if your library doesn't use serialization.
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

1 change: 1 addition & 0 deletions PrebidMobile/PrebidMobile-maxAdapters/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class com.applovin.mediation.adapters.PrebidMaxMediationAdapter
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.applovin.mediation.adapters;

import android.app.Activity;
import androidx.annotation.Keep;

import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.adapter.MaxAdViewAdapter;
import com.applovin.mediation.adapter.MaxInterstitialAdapter;
Expand All @@ -17,12 +17,12 @@
import com.applovin.mediation.adapters.prebid.managers.MaxInterstitialManager;
import com.applovin.mediation.adapters.prebid.managers.MaxNativeManager;
import com.applovin.sdk.AppLovinSdk;

import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.TargetingParams;
import org.prebid.mobile.api.exceptions.InitError;
import org.prebid.mobile.rendering.listeners.SdkInitializationListener;

@Keep
public class PrebidMaxMediationAdapter extends MediationAdapterBase implements MaxAdViewAdapter, MaxInterstitialAdapter, MaxRewardedAdapter, MaxNativeAdAdapter {

public static final String TAG = PrebidMaxMediationAdapter.class.getSimpleName();
Expand Down
8 changes: 5 additions & 3 deletions PrebidMobile/android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ android {
targetSdkVersion rootProject.targetSDKVersion
versionCode rootProject.prebidVersionCode
versionName rootProject.prebidVersionName
consumerProguardFiles file('proguard-rules.pro')
}

buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles file('proguard-rules.pro')
}
release {
minifyEnabled false
// minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles file('proguard-rules.pro')
}
}

Expand Down
10 changes: 0 additions & 10 deletions PrebidMobile/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@

## Public API
#-keepattributes InnerClasses, Signature
#-keep public enum org.prebid.mobile.TargetingParams$** {
# *;
#}
#-keep public class * {
# public *;
#}

Loading

0 comments on commit 342ad3c

Please sign in to comment.