Android接入Replugin插件框架

1.新建Android项目

   1.1修改Android项目中gradle版本

    点击Android studio左上角的File菜单,选中Project structure,如下图所示:

   

 将Android Gradle Plugin Version的版本修改为3.5.4,并且将Gradle Version的版本修改为6.5,如下图所示:

 1.2修改Android项目中gradle版本(项目下的)

 在项目下的build.gradle中添加Replugin的仓库地址,代码如下所示:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    //添加kotlin的支持
    ext.kotlin_version = "1.6.10"
    repositories {
        google()
        mavenCentral()
        //replugin地址
        maven {url "http://maven.geelib.360.cn/nexus/repository/replugin/"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        //replugin插件插件
        classpath 'com.qihoo360.replugin:replugin-plugin-gradle:3.0.0'
        //replugin宿主插件
        classpath "com.qihoo360.replugin:replugin-host-gradle:3.0.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        //replugin的地址
        maven {url "http://maven.geelib.360.cn/nexus/repository/replugin/"}
    }
}

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

 Android studio中右上角会提示sync,点击更新一下。

1.3修改App下的gradle版本

    在Android闭包下添加:

apply plugin: 'replugin-host-gradle'

dependencies闭包中添加replugin的依赖

implementation "com.qihoo360.replugin:replugin-host-lib:3.0.0"

所有代码如下所示:

plugins {
    id 'com.android.application'
    id 'kotlin-android-extensions'
    id 'kotlin-android'
}

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.0"

    defaultConfig {

        applicationId "com.hong.replugin360"
        minSdkVersion 16
        targetSdkVersion 28
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
//必须在Android的闭包下
apply plugin: 'replugin-host-gradle'

dependencies {

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin
  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值