GithubHelp home page GithubHelp logo

alimirzayev / proguard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from guardsquare/proguard

0.0 0.0 0.0 6.11 MB

ProGuard, Java optimizer and obfuscator

Home Page: https://www.guardsquare.com/en/products/proguard

License: GNU General Public License v2.0

Shell 0.06% Java 93.31% Kotlin 6.58% HTML 0.02% Batchfile 0.03%

proguard's Introduction



ProGuard


Quick StartFeaturesContributingLicense


ProGuard is a free shrinker, optimizer, obfuscator, and preverifier for Java bytecode:

  • It detects and removes unused classes, fields, methods, and attributes.

  • It optimizes bytecode and removes unused instructions.

  • It renames the remaining classes, fields, and methods using short meaningless names.

The resulting applications and libraries are smaller, faster, and a bit better hardened against reverse engineering. ProGuard is very popular for Android development, but it also works for Java code in general.

❓ Getting Help

If you have usage or general questions please ask them in the Guardsquare Community.
Please use the issue tracker to report actual bugs 🐛, crashes, etc.

🚀 Quick Start

ProGuard has its own Gradle plugin, allowing you to shrink, optimize and obfuscate Android projects.

ProGuard Gradle Plugin

You can apply the ProGuard Gradle plugin in AGP 4+ projects by following these steps:

  1. Add a classpath dependency in your root level build.gradle file:
buildscript {
    repositories {
        google()       // For the Android Gradle plugin.
        mavenCentral() // For the ProGuard Gradle Plugin and anything else.
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:x.y.z'    // The Android Gradle plugin.
        classpath 'com.guardsquare:proguard-gradle:7.3.0'  // The ProGuard Gradle plugin.
    }
}
  1. Apply the proguard plugin after applying the Android Gradle plugin as shown below:
 apply plugin: 'com.android.application'
 apply plugin: 'com.guardsquare.proguard'
  1. ProGuard expects unobfuscated class files as input. Therefore, other obfuscators such as R8 have to be disabled.
android {
    ...
    buildTypes {
       release {
          // Deactivate R8.
          minifyEnabled false
       }
    }
}
  1. Configure variants to be processed with ProGuard using the proguard block:
android {
    ...
}

proguard {
   configurations {
      release {
         defaultConfiguration 'proguard-android-optimize.txt'
         configuration 'proguard-project.txt'
      }
   }
}

You can then build your application as usual:

gradle assembleRelease

The repository contains some sample configurations in the examples directory. Notably, examples/android has a small working Android project that applies the ProGuard Gradle plugin.

Integrated ProGuard (AGP < 7.0)

If you have an older Android Gradle project you can enable ProGuard instead of the default R8 compiler:

  1. Disable R8 in your gradle.properties:
android.enableR8=false
android.enableR8.libraries=false
  1. Override the default version of ProGuard with the most recent one in your main build.gradle:
buildscript {
    //...
    configurations.all {
        resolutionStrategy {
            dependencySubstitution {
                substitute module('net.sf.proguard:proguard-gradle') with module('com.guardsquare:proguard-gradle:7.3.0')
            }
        }
    }
}
  1. Enable minification as usual in your build.gradle:
android {
    //...
    buildTypes {
        release {
            minifyEnabled   true
            shrinkResources true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
            proguardFile 'proguard-project.txt'
        }
    }
}
  1. Add any necessary configuration to your proguard-project.txt.

You can then build your application as usual:

gradle assembleRelease

The repository contains some sample configurations in the examples directory. Notably, examples/android-agp3-agp4 has a small working Android project that uses the old integration.

✨ Features

ProGuard works like an advanced optimizing compiler, removing unused classes, fields, methods, and attributes, shortening identifiers, merging classes, inlining methods, propagating constants, removing unused parameters, etc.

  • The optimizations typically reduce the size of an application by anything between 20% and 90%. The reduction mostly depends on the size of external libraries that ProGuard can remove in whole or in part.

  • The optimizations may also improve the performance of the application, by up to 20%. For Java virtual machines on servers and desktops, the difference generally isn't noticeable. For the Dalvik virtual machine and ART on Android devices, the difference can be worth it.

  • ProGuard can also remove logging code, from applications and their libraries, without needing to change the source code — in fact, without needing the source code at all!

The manual pages (markdown, html) cover the features and usage of ProGuard in detail.

💻 Building ProGuard

Building ProGuard is easy - you'll just need a Java 8 JDK installed. To build from source, clone a copy of the ProGuard repository and run the following command:

./gradlew assemble

The artifacts will be generated in the lib directory. You can then execute ProGuard using the scripts in bin, for example:

bin/proguard.sh

You can publish the artifacts to your local Maven repository using:

./gradlew publishToMavenLocal

🤝 Contributing

Contributions, issues and feature requests are welcome in both projects. Feel free to check the issues page and the contributing guide if you would like to contribute.

📝 License

Copyright (c) 2002-2022 Guardsquare NV. ProGuard is released under the GNU General Public License, version 2, with exceptions granted to a number of projects.

proguard's People

Contributors

mrjameshamilton avatar ericlafortune avatar ericsalemi-gs avatar maqsoodahmadjan avatar ericsalemi avatar bigdaz avatar gkv38 avatar rubenpieters avatar runningcode avatar jagogyselinck avatar nadeeshtv avatar robinlefever avatar dzan avatar sleticalboy avatar liaolintao avatar chevreto avatar anatawa12 avatar ulviyyamz avatar autonomousapps avatar tvoc-gs avatar simonschiller avatar pramitha-fernando avatar paulerickson avatar vorburger avatar lonedev6 avatar laurentferierguardsquare avatar jonnybbb avatar ingdas avatar britter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.