Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop keeping all androidx.** classes in generated ProGuard rules #7

Open
Goooler opened this issue Jul 10, 2024 · 5 comments
Open

Stop keeping all androidx.** classes in generated ProGuard rules #7

Goooler opened this issue Jul 10, 2024 · 5 comments

Comments

@Goooler
Copy link

Goooler commented Jul 10, 2024

The ProGuard file generated by this plugin is located at project_dir/.safedk/proguard-safedk.pro, it looks like:

-keep class androidx.** { *; }
-keep class android.support.multidex.** { *; }
-keep class android.support.v4.app.** { *; }
-keep class com.google.android.gms.location.FusedLocationProviderApi { *; }
-keep class com.google.android.gms.location.LocationListener { *; }
...

contains -keep class androidx.** { *; } to keep all AndroidX classes, significantly increasing the generated APK file sizes. Usually, rules are bundled in AndroidX packages, we don't need to add any extra ones. Please remove it.

@Goooler
Copy link
Author

Goooler commented Jul 10, 2024

Workaround for AppLovinQualityServiceGradlePlugin:4.13.6:

/**
 * TODO: remove this once https://github.com/AppLovin/AppLovin-MAX-Ad-Review-SDK-Android/issues/7 is fixed.
 */
def removeProguardRules = tasks.register('removeProguardRules') {
    def file = rootProject.file(".safedk/proguard-safedk.pro")
    if (file.exists()) {
        def newRules = file.readLines().findAll { !it.contains("androidx.**") }.join('\n')
        file.text = newRules
    }
}

tasks.withType(com.android.build.gradle.internal.tasks.R8Task).configureEach {
    dependsOn(removeProguardRules)
}

Workaround for AppLovinQualityServiceGradlePlugin:5.2.7:

def removeProguardRules = tasks.register('removeProguardRules') {
    def file = rootProject.file(".safedk/proguard-safedk.pro")
    if (file.exists()) {
        def redundantRules = [
            "-keep class androidx.** {",
            "*** startActivityForResult(***);",
            "*** startActivity(***);",
            "}",
        ]
        def newRules = file.readLines().collect { it.trim() }
        newRules.removeAll(redundantRules)
        file.text = newRules.join('\n')
    }
}

@Goooler Goooler changed the title Stop keeping all androidx.** classes in generated Proguard rules Stop keeping all androidx.** classes in generated ProGuard rules Jul 10, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This isue has been inactive label Nov 14, 2024
@Goooler
Copy link
Author

Goooler commented Nov 14, 2024

It's alive.

@github-actions github-actions bot removed the stale This isue has been inactive label Nov 15, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This isue has been inactive label Dec 15, 2024
@Goooler
Copy link
Author

Goooler commented Dec 15, 2024

It's alive.

@github-actions github-actions bot removed the stale This isue has been inactive label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant