Top Related Projects
A library for performance traces from production.
Android and Java bytecode viewer
smali/baksmali
Tools to work with android .dex and java .class files
Dex to Java decompiler
A Java 8+ Jar & Android APK Reverse Engineering Suite (Decompiler, Editor, Debugger & More)
Quick Overview
ReDex is an Android bytecode optimizer developed by Facebook. It's designed to improve the performance of Android applications by optimizing DEX files, which are the compiled Android application code. ReDex applies various optimization techniques to reduce app size, improve runtime performance, and enhance overall app efficiency.
Pros
- Significantly reduces APK size, leading to faster downloads and less storage usage
- Improves app startup time and overall runtime performance
- Offers a wide range of optimization passes that can be customized
- Actively maintained by Facebook and the open-source community
Cons
- Can potentially introduce bugs if not used carefully or if the app relies on specific bytecode structures
- Requires careful testing after optimization to ensure app functionality is not affected
- May increase build times due to the additional optimization step
- Some optimizations might conflict with certain Android features or libraries
Getting Started
To use ReDex, follow these steps:
-
Clone the repository:
git clone https://github.com/facebook/redex.git
-
Build ReDex:
cd redex ./build.sh
-
Run ReDex on your APK:
./redex.py path/to/your/app.apk -o path/to/output/optimized_app.apk
-
Install the optimized APK on your device:
adb install path/to/output/optimized_app.apk
Note: It's recommended to thoroughly test your app after applying ReDex optimizations to ensure all functionality remains intact.
Competitor Comparisons
A library for performance traces from production.
Pros of Profilo
- Focused on mobile app performance profiling and monitoring
- Provides real-time insights into app behavior and performance
- Supports both Android and iOS platforms
Cons of Profilo
- More specialized tool compared to Redex's broader optimization capabilities
- Requires integration into the app for data collection
- May have a slight performance overhead during profiling
Code Comparison
Profilo (Java):
TraceOrchestrator.getInstance()
.startTrace("MyCustomTrace")
.markEvent("ImportantEvent")
.stopTrace();
Redex (C++):
DexStore root_store("classes.dex");
PassManager manager(root_store, config);
manager.run_passes(passlist, config);
Key Differences
- Profilo focuses on runtime performance analysis, while Redex optimizes Android apps statically
- Profilo is designed for continuous monitoring, whereas Redex is typically used during the build process
- Redex directly modifies bytecode, while Profilo collects performance data without altering the app's code
Use Cases
- Use Profilo for identifying performance bottlenecks and monitoring app behavior in production
- Use Redex for reducing app size, improving startup time, and optimizing overall performance before release
Both tools can be valuable in an Android development workflow, with Redex optimizing the app pre-release and Profilo helping to monitor and improve performance post-release.
Android and Java bytecode viewer
Pros of ClassyShark
- User-friendly GUI for analyzing Android APKs and DEX files
- Supports multiple file formats including APK, AAR, and JAR
- Provides a command-line interface for integration into build processes
Cons of ClassyShark
- Limited optimization capabilities compared to Redex
- Primarily focused on analysis rather than code modification
- May not be as effective for large-scale app optimization
Code Comparison
ClassyShark (command-line usage):
java -jar ClassyShark.jar -open path/to/your/app.apk
Redex (basic usage):
redex input.apk -o output.apk
Key Differences
ClassyShark is primarily an analysis tool for Android applications, offering both GUI and CLI interfaces. It excels at providing insights into app structure, dependencies, and potential issues.
Redex, on the other hand, is a powerful bytecode optimizer designed to improve Android app performance. It focuses on code transformation and optimization rather than analysis.
While ClassyShark is excellent for developers who need to inspect and understand Android apps, Redex is better suited for those looking to optimize app performance and reduce APK size through advanced bytecode manipulation techniques.
smali/baksmali
Pros of smali
- Focused on disassembling and assembling Android DEX files
- Lightweight and easy to use for specific Android reverse engineering tasks
- Well-established in the Android development community
Cons of smali
- Limited scope compared to Redex's broader optimization capabilities
- Lacks advanced optimization features for Android apps
- Primarily a command-line tool without extensive GUI support
Code Comparison
smali:
.method public onCreate(Landroid/os/Bundle;)V
.locals 1
invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
const v0, 0x7f030001
invoke-virtual {p0, v0}, Lcom/example/MyActivity;->setContentView(I)V
return-void
.end method
Redex:
DexClass* cls = type_class(type::get_class_type("Lcom/example/MyActivity;"));
auto method = cls->get_vmethods().begin();
method->get_code()->build_cfg();
optimize_method(method);
method->get_code()->clear_cfg();
The smali code shows disassembled DEX bytecode, while the Redex example demonstrates programmatic manipulation of DEX classes and methods for optimization.
Tools to work with android .dex and java .class files
Pros of dex2jar
- Simpler and more focused tool for converting DEX to JAR files
- Lightweight and easy to integrate into existing workflows
- Supports both DEX to JAR and JAR to DEX conversions
Cons of dex2jar
- Limited optimization capabilities compared to Redex
- Lacks advanced features for code analysis and manipulation
- Not actively maintained, with fewer recent updates
Code Comparison
dex2jar:
DexFileReader reader = new DexFileReader(dexBytes);
DexFileWriter writer = new DexFileWriter();
reader.accept(writer);
byte[] newDexBytes = writer.toByteArray();
Redex:
DexStore root_store(input_dexes);
PassManager manager(root_store, config);
manager.run_passes(passes, config);
write_dexes(output_filename, root_store);
dex2jar focuses on straightforward DEX to JAR conversion, while Redex offers more comprehensive optimization and analysis capabilities. dex2jar is simpler to use for basic conversion tasks, but Redex provides more advanced features for optimizing Android applications. The code examples illustrate the difference in complexity and functionality between the two projects.
Dex to Java decompiler
Pros of JADX
- More actively maintained with frequent updates and bug fixes
- Supports both GUI and command-line interfaces, offering flexibility for different use cases
- Capable of decompiling both DEX and APK files, providing broader Android app analysis capabilities
Cons of JADX
- Limited to Java decompilation, while Redex supports optimizations for Android apps
- Lacks advanced optimization features found in Redex, such as method inlining and class merging
- May produce less optimized output compared to Redex's ability to reduce APK size
Code Comparison
JADX (decompilation output):
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Redex (optimization example):
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Redex may inline method calls or remove unused code
}
}
Note: The code comparison is illustrative, as Redex focuses on optimization rather than decompilation. The actual differences would be more apparent in the compiled bytecode or APK size reduction.
A Java 8+ Jar & Android APK Reverse Engineering Suite (Decompiler, Editor, Debugger & More)
Pros of bytecode-viewer
- User-friendly GUI for easy bytecode analysis and manipulation
- Supports multiple Java decompilers (e.g., Procyon, CFR, JD-GUI)
- Allows real-time editing and recompilation of bytecode
Cons of bytecode-viewer
- Primarily focused on Java bytecode, while Redex supports Android DEX files
- Less optimized for large-scale Android app optimization compared to Redex
- May have slower processing times for complex applications
Code Comparison
bytecode-viewer (Java decompilation):
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Redex (Android optimization):
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
While bytecode-viewer focuses on Java bytecode analysis and manipulation, Redex is specifically designed for optimizing Android applications. bytecode-viewer provides a more interactive and visual approach to bytecode analysis, making it suitable for educational purposes and smaller-scale projects. Redex, on the other hand, excels in optimizing large Android applications, reducing their size and improving performance through various optimization techniques.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ReDex: An Android Bytecode Optimizer
ReDex is an Android bytecode (dex) optimizer originally developed at Facebook. It provides a framework for reading, writing, and analyzing .dex files, and a set of optimization passes that use this framework to improve the bytecode. An APK optimized by ReDex should be smaller and faster than its source.
Go to https://fbredex.com for full documentation.
Contributions
See CONTRIBUTING.md to understand how to contribute to this project.
License
The ReDex repository is available under the MIT License.
Top Related Projects
A library for performance traces from production.
Android and Java bytecode viewer
smali/baksmali
Tools to work with android .dex and java .class files
Dex to Java decompiler
A Java 8+ Jar & Android APK Reverse Engineering Suite (Decompiler, Editor, Debugger & More)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot