Top Related Projects
A powerful Android Dynamic Component Framework.
A powerful and lightweight plugin framework for Android
A small framework to split app into small parts
WMRouter是一款Android路由框架,基于组件化的设计思路,有功能灵活、使用简单的特点。
demos to help understand plugin framwork
零反射全动态Android插件框架
Quick Overview
Amigo is a lightweight, high-performance Java framework for developing microservices. It provides a simple and efficient way to build scalable and maintainable applications, with features like dependency injection, aspect-oriented programming, and easy integration with various middleware components.
Pros
- Lightweight and fast, with minimal overhead
- Easy to use and configure, reducing development time
- Supports both annotation-based and XML-based configurations
- Seamless integration with popular middleware and tools
Cons
- Limited documentation, especially for advanced features
- Smaller community compared to more established frameworks like Spring
- Fewer third-party libraries and extensions available
- May require more manual configuration for complex scenarios
Code Examples
- Creating a simple REST controller:
@RestController
@RequestMapping("/api")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/users/{id}")
public User getUser(@PathVariable Long id) {
return userService.getUserById(id);
}
}
- Configuring dependency injection:
@Configuration
public class AppConfig {
@Bean
public UserService userService() {
return new UserServiceImpl();
}
}
- Using aspect-oriented programming:
@Aspect
@Component
public class LoggingAspect {
@Around("execution(* com.example.service.*.*(..))")
public Object logMethodExecution(ProceedingJoinPoint joinPoint) throws Throwable {
Logger logger = LoggerFactory.getLogger(joinPoint.getTarget().getClass());
logger.info("Executing: " + joinPoint.getSignature().getName());
return joinPoint.proceed();
}
}
Getting Started
To start using Amigo in your project, follow these steps:
- Add Amigo dependency to your
pom.xml
:
<dependency>
<groupId>me.ele.amigo</groupId>
<artifactId>amigo-core</artifactId>
<version>1.0.0</version>
</dependency>
- Create a main application class:
@EnableAmigoAutoConfiguration
public class Application {
public static void main(String[] args) {
AmigoApplication.run(Application.class, args);
}
}
- Start developing your microservices using Amigo's annotations and features.
Competitor Comparisons
A powerful Android Dynamic Component Framework.
Pros of Atlas
- More comprehensive documentation and examples
- Larger community and more active development
- Supports dynamic loading of components and plugins
Cons of Atlas
- Steeper learning curve due to complexity
- Heavier resource usage for smaller projects
- Less flexibility for customization in some areas
Code Comparison
Atlas:
Atlas atlas = Atlas.getInstance();
atlas.loadBundle("com.example.bundle");
BundleClassLoader classLoader = atlas.getBundleClassLoader("com.example.bundle");
Class<?> clazz = classLoader.loadClass("com.example.MyClass");
Amigo:
Amigo.init(this);
Amigo.loadPatch();
Class<?> clazz = Class.forName("com.example.MyClass");
Summary
Atlas offers a more robust and feature-rich solution for large-scale Android projects, with better documentation and community support. It excels in dynamic component loading and plugin management. However, this comes at the cost of increased complexity and resource usage.
Amigo, on the other hand, provides a simpler and more lightweight approach to hot-fixing and dynamic code loading. It's easier to integrate into existing projects and offers more flexibility for customization. However, it may lack some advanced features and has a smaller community compared to Atlas.
The choice between the two depends on the project's scale, requirements, and the development team's expertise. Atlas is better suited for large, complex applications, while Amigo may be preferable for smaller projects or those requiring quick integration of hot-fixing capabilities.
A powerful and lightweight plugin framework for Android
Pros of VirtualAPK
- More flexible plugin management, allowing dynamic loading and unloading of plugins
- Better support for resource isolation between host and plugin apps
- More comprehensive documentation and examples for implementation
Cons of VirtualAPK
- Higher complexity in setup and integration compared to Amigo
- Potentially larger runtime overhead due to more extensive virtualization
Code Comparison
VirtualAPK:
PluginManager pluginManager = PluginManager.getInstance(context);
pluginManager.loadPlugin(pluginPath);
Intent intent = new Intent();
intent.setClassName("com.example.plugin", "com.example.plugin.MainActivity");
startActivity(intent);
Amigo:
Amigo.loadPatch(this, patchFile);
Intent intent = new Intent();
intent.setClassName(this, "com.example.patch.PatchedActivity");
startActivity(intent);
Key Differences
- VirtualAPK focuses on running entire plugin apps, while Amigo is primarily for hot-fixing and patching
- VirtualAPK provides more granular control over plugin lifecycle and resources
- Amigo offers a simpler API for quick patching scenarios
Use Cases
- VirtualAPK: Ideal for modular app development and dynamic feature delivery
- Amigo: Better suited for rapid bug fixes and small updates without full app redeployment
A small framework to split app into small parts
Pros of Small
- Lightweight and efficient, focusing on minimizing APK size
- Supports hot-fixing and dynamic loading of plugins
- Provides a gradle plugin for easy integration
Cons of Small
- Less actively maintained (last update 4 years ago)
- Limited documentation and examples available
- Smaller community and fewer contributors
Code Comparison
Small:
Small.setBaseUri("https://example.com/updates/");
Small.setUp(this);
Small.openUri("main", this);
Amigo:
Amigo.init(this);
Amigo.loadPatch(this, patchFile);
Amigo.work(this);
Key Differences
- Small focuses on modularization and dynamic loading, while Amigo specializes in hot-fixing and patching
- Small aims to reduce APK size, whereas Amigo prioritizes seamless app updates
- Small uses a URI-based approach for module loading, while Amigo uses a more traditional patching mechanism
Use Cases
Small is better suited for:
- Apps requiring modular architecture
- Projects aiming to minimize APK size
- Developers needing plugin-based functionality
Amigo is more appropriate for:
- Large-scale apps requiring frequent updates
- Projects needing robust hot-fixing capabilities
- Teams with complex deployment processes
Both projects offer unique solutions for Android app development, with Small emphasizing modularity and size optimization, and Amigo focusing on efficient app updates and hot-fixing.
WMRouter是一款Android路由框架,基于组件化的设计思路,有功能灵活、使用简单的特点。
Pros of WMRouter
- More comprehensive documentation and examples
- Supports both URI and custom scheme routing
- Offers advanced features like interceptors and middleware
Cons of WMRouter
- Steeper learning curve due to more complex API
- Requires more setup and configuration
- May be overkill for simpler projects
Code Comparison
WMRouter:
@RouterUri("http://example.com/user/{id}")
public class UserActivity extends Activity {
@Param
String id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Use the 'id' parameter
}
}
Amigo:
@Route("/user/:id")
public class UserActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String id = getIntent().getStringExtra("id");
// Use the 'id' parameter
}
}
Key Differences
- WMRouter uses annotations for parameter injection, while Amigo requires manual extraction from Intent
- WMRouter supports full URIs, Amigo uses simplified path patterns
- WMRouter's routing configuration is more verbose but offers greater flexibility
- Amigo's setup is simpler and more straightforward for basic use cases
Both libraries aim to simplify Android app navigation, but WMRouter offers more advanced features at the cost of increased complexity, while Amigo focuses on simplicity and ease of use for common routing scenarios.
demos to help understand plugin framwork
Pros of understand-plugin-framework
- More focused on educational purposes, providing detailed explanations and examples
- Offers a deeper understanding of Android plugin frameworks
- Includes comprehensive documentation and tutorials
Cons of understand-plugin-framework
- Less actively maintained compared to Amigo
- Fewer features and tools for production-level plugin development
- Smaller community and less widespread adoption
Code Comparison
understand-plugin-framework:
public class PluginClassLoader extends DexClassLoader {
private final String mPluginPackageName;
public PluginClassLoader(String dexPath, String optimizedDirectory,
String librarySearchPath, ClassLoader parent,
String pluginPackageName) {
super(dexPath, optimizedDirectory, librarySearchPath, parent);
mPluginPackageName = pluginPackageName;
}
}
Amigo:
public class AmigoClassLoader extends PathClassLoader {
private final String mDexPath;
private final File mOptimizedDirectory;
public AmigoClassLoader(String dexPath, File optimizedDirectory, String libraryPath, ClassLoader parent) {
super(dexPath, libraryPath, parent);
mDexPath = dexPath;
mOptimizedDirectory = optimizedDirectory;
}
}
Both frameworks implement custom ClassLoaders to handle plugin loading, but Amigo's implementation extends PathClassLoader, while understand-plugin-framework uses DexClassLoader as its base class.
零反射全动态Android插件框架
Pros of Shadow
- More comprehensive plugin framework with support for dynamic loading and unloading
- Better documentation and examples for developers
- Larger community and more active development
Cons of Shadow
- Steeper learning curve due to more complex architecture
- Potentially higher resource usage for smaller projects
- Less flexibility in terms of customization compared to Amigo
Code Comparison
Shadow:
@PluginApplication(application = "com.example.host.MyApplication")
class PluginApplication : Application() {
override fun onCreate() {
super.onCreate()
// Plugin-specific initialization
}
}
Amigo:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Amigo.init(this);
// Additional initialization
}
}
Both frameworks aim to provide plugin functionality for Android applications, but Shadow offers a more robust and feature-rich solution at the cost of increased complexity. Amigo, on the other hand, provides a simpler approach that may be more suitable for smaller projects or developers new to plugin architectures.
Shadow's code example demonstrates its plugin-specific application class, while Amigo's example shows a more straightforward initialization process within the main application class. This reflects the difference in complexity and flexibility between the two frameworks.
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
wiki (deprecated)
Amigo Service Platform (Amigo backend service is no longer supported)
Amigo is a hotfix library which can fix everything for your Android app
How to use
Download
In your project's build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'me.ele:amigo:0.6.8'
}
}
In your module's build.gradle
apply plugin: 'me.ele.amigo'
android {
...
}
dependencies {
...
compile 'me.ele:amigo-lib:0.6.7'
}
//if you don't want use amigo in dev, set this value to true
//you can define this extension in your mybuild.gradle as to distinguish debug & release build
amigo {
disable false //default false
autoDisableInInstantRunMode true // default false
}
Compatibility
- Supports All Devices From ECLAIR
2.1
to Nougat7.1
- Even support next Android version, no matter small or big change. So Cool, Aha :v:
- Android 3.0 isn't supported
Customize loading page(optional)
Some time-consuming tasks are handled in a separate process to avoid ANR, you can customize the loading activity by add the follow code into your AndroidManifest.xml:
<meta-data
android:name="amigo_layout"
android:value="{your-layout-name}" />
<meta-data
android:name="amigo_theme"
android:value="{your-theme-name}" />
<meta-data
android:name="amigo_orientation"
android:value="{your-custom-orientation}"/>
Note:
- These three
meta-data
is defined in your personalAndroidManifest.xml
of app module if necessary - orientation's value must be in screenOrientation
Make hotfix work
There are two ways to make hotfix work.
-
if you don't need hotfix work immediately
you just need to download new apk file, hotfix apk will be loaded as fresh as new when app restarts next time
Amigo.workLater(context, patchApkFile, callback);
-
work immediately, App will restart immediately
Amigo.work(context, patchApkFile);
Remove patch
Amigo.clear(context);
noteï¼All patch files would be deleted on the next start up.
Demo
And there is an Demo page in the app demonstrating how to apply patch apk.
Run the task ./gradlew runHost preparePatch
, and navigate to the demo
page.
Development
Amigo gradle plugin
The plugin was put into buildSrc directory, which means the plugin code change will work immediately each time you build.
Amigo lib
The amigo plugin will select the right amigo lib automatically.
Run tests
There are two gradle tasks provided in the app/build.gradle, :app:runHost
, :app:preparePatch
, which can accelerate development.
./gradlew runHost
, launch the host app./gradlew preparePatch
, build and push the patch apk to the device- apply the patch apk in the Demo page
Limits
-
have to change the way using a content provider
-
declare a new provider: the authorities string must start with "${youPackageName}.provider"
<provider android:name="me.ele.demo.provider.StudentProvider" android:authorities="${youPackageName}.provider.student" />
-
change the uri used to do the query, insert, delete operations:
// 1. inside your app process, no modifications need: Cursor cursor = getContentResolver().query(Uri.parse("content://" + getPackageName() + ".provider.student?id=0"), null, null, null, null); // 2. in another process, have to change the authorities uri like the following : Cursor cursor = getContentResolver().query(Uri.parse("content://" + targetPackageName + ".provider/student?id=0"), null, null, null, null);
-
-
Instant Run conflicts with Amigo, so disable Instant Run when used with amigo(Or use
autoDisableInInstantRunMode
to auto disable amigo in instant run mode) -
Amigo doesn't support Honeycomb
3.0
- Android 3.0 is a version with full of bugs, & Google has closed Android 3.0 Honeycomb.
-
RemoteViews
's layout change innotification
&widget
is not support- any resource id in here should be used with
java RCompat.getHostIdentifier(Context context, int id)
- any resource id in here should be used with
Retrieve hotfix file
-
make it simple, you just need a fully new apk
-
to save the internet traffic, you may just want to download a diff file bspatch (
support whole apk diff & fine-grained diff in apk
)is an option for you
Inspired by
Android Patch æ¹æ¡ä¸æç»äº¤ä»
License
Copyright 2016 ELEME Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Top Related Projects
A powerful Android Dynamic Component Framework.
A powerful and lightweight plugin framework for Android
A small framework to split app into small parts
WMRouter是一款Android路由框架,基于组件化的设计思路,有功能灵活、使用简单的特点。
demos to help understand plugin framwork
零反射全动态Android插件框架
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