Shadow Project Introduction
Overview
Shadow is an Android plugin framework independently developed by Tencent, demonstrating exceptional reliability with user testing that spans hundreds of millions of users. Unlike many other plugin frameworks available on the market, Shadow offers a unique set of features aimed at simplifying and enhancing the plugin development process.
Key Features
-
Reuse of Standalone App Source Code: The source code for plugin apps is originally designed to run as standalone apps without any modification.
-
Zero Reflection Without Hacks: Shadow implements its plugin technology without relying on reflection or hacks. This approach ensures compatibility with various systems without requiring changes for different versions and adheres strictly to Google's policies restricting the use of non-public SDK interfaces.
-
Fully Dynamic Plugin Framework: Shadow embraces a fully dynamic approach to plugin management, allowing the plugin framework's code to be part of the plugin itself. This means updates to plugins are not restricted by hosting older versions of the plugin framework.
-
Minimal Host Increment: The dynamic design ensures that only a minimal amount of code is integrated into the host program, approximately 15KB with around 160 methods.
-
Kotlin Implementation: The core components, such as
core.loader
andcore.transform
, are fully implemented in Kotlin. This results in a codebase that is concise and easier to maintain.
Supported Features
- Four main Android components (Activities, Services, Broadcast Receivers, and Content Providers)
- Support for Fragments, both added via code and declared in XML
- Seamless DataBinding support
- Plugins can utilize services across processes
- Custom Theme support
- Plugins can access host classes
- Loading of native libraries (So files)
- Incremental plugin loading (multiple APKs loaded separately or dependently)
- Loading of Views from multiple APKs in a single Activity
Development and Environment
Developers are encouraged to use the latest stable version of Android Studio (Arctic Fox | 2020.3.1) to work with Shadow. Sample projects, such as sample-app
and sample-host
, are available to demonstrate the code's execution in both regular installation and plugin modes.
The Shadow project is organized into three main directories within the projects
folder:
sdk
contains all the SDK codetest
includes automated testing code for the SDKsample
features demonstration code
The sample
directory serves as the best environment for experiencing Shadow. Detailed information can be found in the README within the sample
directory.
Compatibility
Shadow boasts comprehensive automated testing to ensure compatibility with varying external environment versions. The project's compatibility details can be found in the automated test configurations:
pr-check.yml
outlines VM-based automated tests, including Android device versions and compilation environments.pr-check-gradle-plugin.yml
focuses on Android Gradle Plugin (AGP) compatibility testing.
Troubleshooting Your Test Code
Given the complexities of plugin environments, perfect out-of-the-box solutions are rare. As such, some degree of adaptation for individual business needs is expected. Shadow's current framework is tailored to meet its existing internal needs. Its fully dynamic design allows for simultaneous development of new plugin framework features alongside new plugins.
If a method isn’t found, as in the case of ShadowActivity, simply implementing the needed method in ShadowActivity often resolves the issue. Most methods just require straightforward delegation to function as expected. Developers facing complex implementation challenges can file an issue, ideally with accompanying test code.
Future Developments
Shadow aims to further enhance its documentation and examples, such as:
- Explanation of principles and design documentation
- Sample projects demonstrating support for multiple plugins
- Additional automated test cases
- An open-source manager with downloading capabilities
Contributing
Contributors interested in improving Shadow can find details in the CONTRIBUTING.md document.
License
Tencent Shadow is licensed under the BSD 3-Clause License, as detailed in the LICENSE file.
Personal Information Protection
For details on personal information protection measures, refer to the PRIVACY.md document.