#### i. Description

Use Small as a plug-in. Currently, Small does not support 3.0, but 2.3.3 is still supported, so do not upgrade it to use. Small


Use method is the method that the official provides, go down according to the step that he explains ok

https://github.com/wequick/Small/tree/master/Android

  1. How to open a path:
// Open the Detail page and go to Small. OpenUri ("detail? from=app.home", view.getContext());
Copy the code
  1. If you want to redirect a plugin fragment, note that the name of the plugin must be MainFragment. The plugin only recognizes MainFragment. Otherwise, the redirect will not be found.
Small.createObject("fragment-v4"."Fragment name", MainActivity.this)
Copy the code


To recompile everything, follow these steps

/gradlew buildLib -q // Build the module for lib./gradlew buildBundle -q // build the bundle./gradlew small // Show all the bundle descriptionsCopy the code

If you compile one bundle, you don’t have to compile all the bundles

./gradlew -p web.about assembleRelease
Copy the code

The build.gradle code in the root directory of the project, which specifies 2.3.0, also executes all versions of the bundles

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
//        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com. Android. Tools. Build: gradle: 2.3.0'
        classpath The 'net. Wequick. Tools. Build: gradle - small: 1.3.0 -beta3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
//        mavenLocal()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

apply plugin: 'net.wequick.small'

small {
    buildToAssets = false
    android {
        compileSdkVersion = 26
        buildToolsVersion = "25.0.2"
        supportVersion = "25.1.0"}}Copy the code


Please check if your lib is declared in your App’s bundle.json file. If it is not declared, it may cause problems.

FAQ description of Small

####1. Error not found when referring to a class in the lib library. This is because the bundle name is not specified in the bundle.json file. Something like the following

//都必须是lb.ehome.com开头的,后面的随意,可能他查找就是按这个规则查找的。
{
      "uri": "lib.utils"."pkg": "lb.ehome.com.lib.utils"
    },
    {
      "uri": "main"."pkg": "lb.ehome.com.app.main"
    }
Copy the code


Solution: This may be because your host build.gradle does not add the following declaration

 dataBinding {
        enabled true
    }
Copy the code


./gradlew buildLib -q
[Small] building library 1 of 3 - app (0x7f)
[Small] building library 2 of 3 - lib.style (0x79)
        [lib.style] split library res files...                          [  OK  ]

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':lib.style:processReleaseResources'.
> No support deleting resources on lib.* now

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Copy the code

Solution: This error indicates that the public. TXT file in your lib module was loaded with resource A, but was not loaded the second time.

Please do not make this copy to the host. If the host has these resources, the lib module ignores them.

What you can do now is:

Delete public.txt and retype all: CleanLib, buildLib, cleanBundle, buildBundle checks for resources that already exist in public.txt and removes those copies from the host. Note that in production, (1) means that all plug-ins may need to be updated. ####4. 错 误 You need to use a Theme.AppCompat Theme (or descendant) with this activity 解决 : I tried to modify values/styles. XML and values-v21/styles. XML in lib.style, and the Sample project ran normally.

The specific results are as follows:

###values/styles.xml###<! -- Base application theme. --> <style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="AppTheme.Base"> <! -- Customize your theme here. --> <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
###values-v21/styles.xml###

<style name="AppTheme.NoActionBar" parent="AppTheme.Base">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
Copy the code

Change all references to lib.style plug-ins to the new theme name accordingly.

####5. How to check whether the Debug mode is enabled

Public static Boolean isDebug(context context) {/** * public static Boolean isDebug(context context) {if(isDebug == null) { isDebug = context.getApplicationInfo() ! = null && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) ! = 0; }return isDebug;
  }
Copy the code
  1. When adding aar file, import failed. I added AAR file in app+ Stub lib, other modules will report this error

Solution: Add the following code to each Moudle build.gradle. Specify the AAR directly to load the LIbs directory of app+ Stub.

// Add code repositories {flatDir {dirs project(':app+stub').file('libs'< span style = "box-sizing: border-box; line-height: 21px;'libs', include: '*.jar')
    compile(name: 'xxx-debug', ext: 'aar')
    compile(name: 'xxx-sit-debug', ext: 'aar')}Copy the code

Aar problem

  1. Description uses- SDK :minSdkVersion 15 cannot be smaller than version 21 declared in library

Solution: Change build.gradle of all modules to 16 minSdkVersion

  1. om.android.dex.DexException: Multiple dex files define Landroid/support/multidex/BuildConfig;

Solution: Add the following code to the build.gradle file

android { 
defaultConfig { 
    multiDexEnabled true}}Copy the code
  1. MultiDex.class

Solution: Add the following to build.gradle

compile 'com. Android. Support: multidex: 1.0.1'
Copy the code

# # # 5 learning website http://www.jianshu.com/p/c696acb74bd2 http://code.wequick.net/Small/cn/home http://www.jianshu.com/p/07f88d4924db