Difference Between Proguard and R8 in Android
Last Updated :
23 Feb, 2021
Proguard and R8 both are similar tools that are used for reducing the size of our APK and increase the performance of our APK by shrinking the unused resources. In this article, we will take a look at:
- What is Proguard?
- What is R8?
- Difference between Proguard and R8.
What is Proguard?
Proguard is a java tool in Android that helps to do the following things such as:
- It removes the unused classes and methods from your app which helps to reduce the size of your APK.
- It makes your application difficult to reverse engineer by obfuscating the code.
- It reduces the size of your application.
How to enable Proguard in your Application?
To enable proguard in your application Navigate to the Gradle Scripts > build.gradle(:app) and then you will get to see a method called buildTypes.
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt’), ‘proguard-rules.pro’
}
}
In this block of code, we have to change minifyEnabled to true to activate our Proguard. This code of Proguard is written under the release block so it will only work on the release build of your APK. It will activate the proguard which will take it from the file named as
‘proguard-android.txt’.
What is R8?
R8 is another tool that will convert your java byte code into an optimized format of dex code. It will check the whole application and will remove the unused classes and methods. It helps us to reduce the size of our APK and to make our app more secure. R8 uses similar proguard rules to modify its default behavior.
How to enable R8 in your Application?
R8 is already present in your application you just have to enable it. To enable it just Navigate to the Gradle Scripts > build.gradle(:app) and then you will get to see a method called buildTypes.
buildTypes {
release {
minifyEnabled true
}
}
In this block of code, we have to change minifyEnabled to true to activate R8. This code for R8 is written under the release block which is only working on the release build of your APK.
Difference Between Proguard and R8.
- R8 has more Kotlin support than that of Proguard.
- R8 is having a faster processing time than Proguard which reduces build time.
- R8 gives better output results than Proguard.
- R8 reduces the app size by 10 % whereas Proguard reduces app size by 8.5 %.
- The android app having a Gradle plugin above 3.4.0 or above then the project uses R8 by default with Proguard rules only.
Proguard

In Proguard java compiler converts Apps code into JAVA bytecode and proguard will converts this bytecode into the optimized java bytecode. This java bytecode is then optimized by dex into Optimized Dalvik bytecode. The conversion process of apps code to optimized Dalvik bytecode is a four steps process.
R8

In R8 java compiler converts Apps code in JAVA bytecode and then R8 will directly convert JAVA bytecode into Optimized Dalvik bytecode. The conversion process of apps code to Optimized Dalvik bytecode is a three steps process that is faster in comparison with proguard.
Difference Table
|
Proguard
|
R8
|
| Proguard is having lesser speed in comparison with R8 which affects the build time. |
R8 is having a faster processing time which helps developers in reducing build time. |
| The output quality by using proguard is not superior. |
The output quality using R8 is superior. |
| Proguard reduces app size by 8.5 %. |
R8 reduces app size by 10 %. |
|
The conversion process of converting apps code to Optimized Dalvik bytecode is as follows :
Apps Code > Java bytecode > Optimized java bytecode > Optimized Dalvik bytecode.
|
The conversion process of converting apps code to Optimized Dalvik bytecode is as follows :
Apps code > Java bytecode > Optimized Dalvik bytecode.
|
| Proguard is only supported for the gradle plugin which is below 3.4.0 |
R8 is only supported for the gradle plugin of 3.4.0 and above. |
| Peephole Optimizations in Proguard is around 520. |
Peephole Optimizations in R8 is around 6. |
| No of the steps in converting of Apps code to Optimized Dalvik code is 4. |
No of the steps in converting Apps code to Optimized Dalvik bytecode is 3. |
| Proguard is not having Kotlin specific optimizations. |
R8 is having Kotlin specific optimizations. |
| Proguard does not propagate constant arguments. |
R8 propagate constant arguments. |
Conclusion
While R8 is faster than proguard as there are fewer number steps. It reduces the size of the app in an optimized manner with a default compile-time optimizer.
Similar Reads
Difference between iOS and Android
1. iOS: iOS is a mobile operating system that is provided by Apple Incorporation. It is mainly designed for Apple mobile devices like iPhone and iPod Touch. It was earlier known as iPhone OS. It is a Unix-like operating system that is based on Darwin's (BSD) operating system. It is the worldâs secon
3 min read
Difference Between Linux and Android
Linux and Android are important Operating systems in the tech global, each serving distinct functions and catering to one-of-a-kind user needs. The majority of individuals believe that Android and Linux are operating systems. Android is a mobile phone OS, whereas Linux is used on servers and desktop
6 min read
Difference between Windows and Android
1. Windows : Windows is a group of various proprietary graphical operating systems which is provided by Microsoft Incorporation. It is also known as Microsoft Windows. It currently includes Windows NT and Windows IoT as members of its family. Earlier it included Windows 9x, Windows Mobile and Window
4 min read
Whatâs difference between Linux and Android ?
Many folks consider both of these as operating systems. Linux OS is for Desktops & Servers while Android OS is for Mobiles. Is that completely correct? Linux OS, precisely speaking Linux kernel is the most popular OS while Android is a framework built on top of the Linux kernel. So every Android
3 min read
Difference between FreeBSD and Android
1. FreeBSD : FreeBSD is a free and open source operating system which is provided The FreeBSD Project. It was designed on the basis of the two Unix-like operating systems Berkeley Software Distribution (BSD) and Research Unix. It has quite similarities with Linux operating system. It was one of the
2 min read
Difference Between View and ViewGroup in Android
In Android Layout is used to describe the user interface for an app or activity, and it stores the UI elements that will be visible to the user. An android app's user interface is made up of a series of View and ViewGroup elements. In most cases, android apps will have one or more operations, each o
5 min read
Difference between Android Toast and SnackBar
1. Toast : It is an Android UI component that is used to show message or notification that does not require any user action. It is independent to the activity in which it is being shown and disappears automatically after the set duration. 2. SnackBar : It is Android material design UI component. It
1 min read
Difference Between ActionBar and Toolbar in Android
ActionBar ActionBar is the element present at the top of the activity screen. It is a salient feature of an android application that has a consistent presence over all its activities. It provides a visual structure to the app and contains some of the frequently used elements for the users. Android A
3 min read
Difference Between Android Studio and Flutter
Android Studio is a part of the IDE (Integrated Development Environment) technology stack. It describes it as an Android Development Environment and is based on the IntelliJ IDEA. It was formerly known as Android Development Tools (ADT), which adds additional capabilities and improvements to the ecl
2 min read
Difference between AIX and Android
1. AIX : AIX is a series of proprietary operating systems which is provided by IBM. AIX stands for Advanced Interactive eXecutive. Initially it was designed for the IBM RT PC RISC workstation and later it was used for various hardware platforms like IBM RS/6000 series, PowerPC-based systems, System-
2 min read