Small插件化疯狂踩坑

万恶的插件化

大体上照着Small官网的教程走,踩坑无数
http://code.wequick.net/Small/cn/quickstart
我用的Small版本是1.5.0-beta2,恶心的是这个版本不支持gradle3.0以上的版本,于是第一个坑出现了

好的,我把gradle版本降低(gradle版本可以从这里找 https://jcenter.bintray.com/com/android/tools/build/gradle/)
在这里插入图片描述
p.s. gradle为3.0以下时dependencies里的implementation要改为compile,testImplementation->testCompile,androidTestImplementation->androidTestImplementation
此处也要降低,我从原本的6.1.1改成了4.6
在这里插入图片描述

接下来MainActivity编译报错,于是我把MainActivity改为继承Activity(gradle降低连AndroidX都不配拥有了吗)
在这里插入图片描述

然后我发现在MainActivity里打Small不会import库啊,md我手动输入也不行,cannot resolve symbol Small,可是明明在build.gradle里面已经加了 apply plugin: ‘net.wequick.small’ 这句了哈,怎么肥四!经过我反复试验发现 apply plugin: ‘net.wequick.small’ 一定要写到最前面去!!! md文档太坑了还跟我说让我写到末尾!

好了,总算synchronize成功了,接下来在Terminal输入gradlew small
在这里插入图片描述信息都打印出来了,莫得问题,继续在Terminal输入gradlew buildLib,报错
在这里插入图片描述
乖乖地把minSdkVersion改成14以上,接着报错
在这里插入图片描述
具体原因我也不知道为啥,反正把依赖 androidx.constraintlayout:constraintlayout:2.0.4 改成 com.android.support.constraint:constraint-layout:1.1.3就行了,然后,继续报错(情绪逐渐崩溃)
在这里插入图片描述
还好这篇博客救了我,感谢它 https://blog.csdn.net/zxccxzzxz/article/details/82986956
在这里插入图片描述
到这一步我已经感动得快哭了
继续在terminal输入gradlew buildBundle
在这里插入图片描述
加入bundle.json文件
运行插件,md又报错
在这里插入图片描述
删掉了插件里的依赖 androidx.appcompat:appcompat:1.2.0,好了
运行主程序
在这里插入图片描述
把主程序里的依赖 androidx.appcompat:appcompat:1.2.0 也删掉

到此,贴一下代码记录一下

build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'net.wequick.small'
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:2.3.3"
        classpath 'net.wequick.tools.build:gradle-small:1.5.0-beta2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

small {
    aarVersion = '1.5.0-beta2'
    strictSplitResources = false
}

build.gradle(app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.example.mysmall"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

configurations.all {
    resolutionStrategy.force 'com.android.support:support-v4:26.1.0'
    resolutionStrategy.force 'com.android.support:appcompat-v7:26.1.0'
    resolutionStrategy.force 'com.android.support:recyclerview-v7:26.1.0'
    resolutionStrategy.force 'com.android.support:cardview-v7:26.1.0'
    resolutionStrategy.force 'com.android.support:design:26.1.0'
    resolutionStrategy.force 'androidx.lifecycle:lifecycle-common:2.0.0'
    resolutionStrategy.force 'androidx.annotation:annotation:1.0.0'
}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile ('com.android.support:appcompat-v7:26.1.0'){
        exclude group:'com.android.support',module:'support-v4'
    }
    compile ('com.android.support.constraint:constraint-layout:1.1.3'){
        exclude group:'com.android.support',module:'support-v4'
    }
    compile ('com.android.support:recyclerview-v7:26.1.0'){
        exclude group:'com.android.support',module:'support-v4'
    }
    testCompile 'junit:junit:4.12'
    androidTestCompile 'androidx.test.ext:junit:1.1.2'
    androidTestCompile 'androidx.test.espresso:espresso-core:3.3.0'
}

build.gradle(module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

    defaultConfig {
        applicationId "com.example.mysmall.app.main"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    testCompile 'junit:junit:4.12'
    androidTestCompile("com.android.support.test.espresso:espresso-core:3.0.2", {
        exclude group: "com.android.support", module: "support-annotations"
    })
}

SmallApplication.java

package com.example.mysmall;

import android.app.Application;

import net.wequick.small.Small;

public class SmallApplication extends Application {

    public SmallApplication() {
        Small.preSetUp(this);
    }

}

AndroidManifest.xml(app)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.mysmall">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:name=".SmallApplication"
        android:theme="@style/AppTheme"
        android:appComponentFactory="test"
        tools:replace="android:appComponentFactory">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

kotlin不知道能不能兼容,ARouter暂时没搞,这俩看以后有没有心情搞吧
菜鸡遁走。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值