Qihoo360/RePlugin 简单项目构建

本示例基于Qihoo360/RePlugin tag v2.2.0 GIT地址

新建2个项目在同一个工程里面app,appplugin

主项目的build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.qihoo360.replugin:replugin-host-gradle:2.2.0'
        classpath 'com.qihoo360.replugin:replugin-plugin-gradle:2.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

app/build.gradle 配置如下

apply plugin: 'com.android.application'


android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "energy.trinabess.com.retest"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
apply plugin: 'replugin-host-gradle'
repluginHostConfig {
    useAppCompat =true
    countNotTranslucentStandard =6
    countNotTranslucentSingleTop =2
    countNotTranslucentSingleTask =3
    countNotTranslucentSingleInstance =2
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.qihoo360.replugin:replugin-host-lib:2.2.0'
}

appplugin/build.gradle 配置如下

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"

    defaultConfig {
        applicationId "energy.trinabess.com.appplugin"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.qihoo360.replugin:replugin-plugin-lib:2.2.0'
}

// 这个plugin需要放在android配置之后,因为需要读取android中的配置项
apply plugin: 'replugin-plugin-gradle'
repluginPluginConfig {

    //插件名
    pluginName = "appplugin"
    //宿主app的包名
    hostApplicationId = "energy.trinabess.com.retest"
    //宿主app的启动activity
    hostAppLauncherActivity = "energy.trinabess.com.appplugin.MainActivity"
}

同时appplugin/AndroidManifest.xml 配置如下

   data
            android:name="com.qihoo360.plugin.name"
            android:value="appplugin" />
        data
            android:name="com.qihoo360.plugin.version.ver"
            android:value="100" />

同时也要给予一些基本权限给予主项目:

   
    
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

至此项目基本配置完成,可以运行项目了。

开始Replugin之旅!!!!!!!!!!!!!!!

你可能感兴趣的:(Android)