Android plugin (using the Small framework)
Android plug-in (using the Small framework) Framework Source Code 1. Create Project
File-> New Project...
1.1 Configure your new project
Assume that the host package is namedcom.example.mysmall
- Set Application name
MySmall
Modify Company Domaincom.example.mysmall
This step is a tip. When step 3 creates a Module, it will automatically carry this prefix.
Modify Package namecom.example.mysmall
1.2 Add an activity to mobileWe recommend that you use Fullscreen Activity as the startup interface. On the Activity configuration page, we recommend that you change the Activity Name to LaunchActivity (to validate the Name ).
2. Configure SmallModify build. gradle of a Project
2.1 Add to the Small compilation Librarybuildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'net.wequick.tools.build:gradle-small:0.1.1' }}...apply plugin: 'net.wequick.small'
2.2 configure Small DSL (optional)
Currently, only one attribute exists.aarVersion
Indicates the version of the Small aar code base. If not set, the default value isgradle-small
.
small { aarVersion = '0.1.2'}
The latest version number can be seen on Bintray.
3. Create Module
File-> New-> Module:
- The module name is shown as follows:
app.*
,lib.*
Orweb.*
Package name includes:.app.
,.lib.
Or.web.
Why? Because Small classifies the plug-ins according to the package name, special domain name space such as ". app." makes this easy.
Pairlib.*
Choose Android Library for the Module, and Phone & Tablet Module for other modules.
Create a plug-in module, suchapp.main
:
- Modify Application/Library name
App.main
Change Package namecom.example.mysmall.app.main
4. Configure UI routeRight-clickapp
Module-> New-> Folder-> Assets Folder, Newassets
Directory,
Right-clickassets
Directory-> New-> File, Newbundles.json
File, add:
{ "version": "1.0.0", "bundles": [ { "uri": "main", "pkg": "com.example.mysmall.app.main" } ]}
5. Setup Small5.1 configure the signatureSwitchProject
Directory tree, right-clickMySmall
, Newsign
Directory, addrelease.jks
Signature file.
Inapp
Modulebuild.gradle
Add the signature configuration (change the password to your own ):
signingConfigs { release { storeFile file('../sign/release.jks') storePassword "5mall@ndro!d" keyAlias "small" keyPassword "5mall@ndro!d" }}buildTypes { release { signingConfig signingConfigs.release }}
5.2 configure basic DependenciesInapp
The module adds shared dependent libraries, such:
compile 'com.android.support:design:23.1.1'
5.3 load plug-insInapp
ModuleLaunchActivity
Heavy LoadonStart
Method:
@Overrideprotected void onStart() { super.onStart(); Small.setBaseUri("http://example.com/"); Small.setUp(this, new net.wequick.small.Bundle.OnLoadListener() { @Override public void onStart(int bundleCount, int upgradeBundlesCount, long upgradeBundlesSize) { } @Override public void onProgress(int bundleIndex, String bundleName, long loadedSize, long bundleSize) { } @Override public void onComplete(Boolean success) { Small.openUri("main", LaunchActivity.this); } });}
6. Compile Small
Build libraries (prepare the Basic Library)
[./] Gradlew buildLib-q (-q is a quiet mode, which can make the output look better or not)
Build bundles (package all components)
[./] Gradlew buildBundle-q (-q is a quiet mode, which can make the output look better or not)
If you like the two steps, you can also run
You can use [./] gradlew-p web. about javaserelease to compile a component separately.
Or
7. Run SmallIn the toolbar, select the app module to run.
. Directory structure Exception Handling 1. the above steps are provided, but note that when creating a plug-in module, for example, the input is app. in this case, the package name must be changed to com. example. small. app. main instead of com. example. small. if appmain runs like this, problems may occur. 2. If the compilation fails, run./gradlew cleanLib first.