记录Android Studio 3.1.2 编译运行SparkYuan的开源项目meizi(常见解决方法就不记录了)

SparkYuan的CSDN博客地址:https://blog.csdn.net/L664675249/article/details/50783923
meizi的GitHub地址:https://github.com/SparkYuan/Meizi

1、android-apt plugin is incompatible with the Android Gradle plugin. Please use ‘annotationProcessor’ configuration instead.

第一个注释:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
//apply plugin: 'android-apt'

第二个修改:

//apt rootProject.ext.butterknifeCompiler
annotationProcessor rootProject.ext.butterknifeCompiler

第三个注释:

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "io.realm:realm-gradle-plugin:1.1.0"
    //classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}

然而Error仍然存在,从网上搜索,可能是realm的版本太低,于是升级到:

classpath "io.realm:realm-gradle-plugin:2.2.0"

这个Error终于消失。(其实还有另外的坑,继续往下看)

2、Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.

原代码:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile rootProject.ext.appcompatV7
    compile rootProject.ext.supportV4
    compile rootProject.ext.androiddesign
    compile rootProject.ext.recyclerview
    compile (rootProject.ext.realm){
       exclude group: 'org.ow2.asm', module: 'asm'
        exclude group: 'org.ow2.asm', module: 'asm-commons'
        exclude group: 'org.ow2.asm', module: 'asm-tree'
        exclude group: 'org.ow2.asm', module: 'asm-analysis'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-runtime'
    }
    compile rootProject.ext.retrofit
    compile rootProject.ext.retrofitgson
    compile rootProject.ext.rxJava
    compile rootProject.ext.rxAndroid
    compile rootProject.ext.rxAdapter
    compile rootProject.ext.glide
    compile rootProject.ext.cardview
    compile rootProject.ext.butterknife
    compile rootProject.ext.multidex
    //apt rootProject.ext.butterknifeCompiler
    annotationProcessor rootProject.ext.butterknifeCompiler
    compile (rootProject.ext.photoview) {
        exclude module: 'support-v4'
    }
    compile 'com.umeng.analytics:analytics:latest.integration'
}

修改后:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation rootProject.ext.appcompatV7
    implementation rootProject.ext.supportV4
    implementation rootProject.ext.androiddesign
    implementation rootProject.ext.recyclerview
    implementation (rootProject.ext.realm){
       exclude group: 'org.ow2.asm', module: 'asm'
        exclude group: 'org.ow2.asm', module: 'asm-commons'
        exclude group: 'org.ow2.asm', module: 'asm-tree'
        exclude group: 'org.ow2.asm', module: 'asm-analysis'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-runtime'
    }
    implementation rootProject.ext.retrofit
    implementation rootProject.ext.retrofitgson
    implementation rootProject.ext.rxJava
    implementation rootProject.ext.rxAndroid
    implementation rootProject.ext.rxAdapter
    implementation rootProject.ext.glide
    implementation rootProject.ext.cardview
    implementation rootProject.ext.butterknife
    implementation rootProject.ext.multidex
    //apt rootProject.ext.butterknifeCompiler
    annotationProcessor rootProject.ext.butterknifeCompiler
    implementation (rootProject.ext.photoview) {
        exclude module: 'support-v4'
    }
    implementation 'com.umeng.analytics:analytics:latest.integration'
}

然而这个Error仍然存在,网上搜索良久无果,今天突然灵光一闪,是不是跟realm版本还是有关系,于是注释掉realm相关验证一下:
第一个注释:

 //apply plugin: 'realm-android'

第二个注释:

//classpath "io.realm:realm-gradle-plugin:2.2.0"

果然Error消失了,但是我们仍然需要使用realm怎么办,那就升级realm版本吧,通过官网找一下最新版本:

https://realm.io/docs/java/latest
2019.09.14 Realm Lastest版本:5.15.1
还原前面两个注释,修改如下:

classpath "io.realm:realm-gradle-plugin:5.15.1"

好了,问题解决!

另外在搜索过程中还有人发现google-services的版本也会导致上述问题,同样可以升级到最新版本来解决,比如(这里的3.2.0不是google-services的最新版本):

classpath 'com.google.gms:google-services:3.2.0'
这种解决问题的思路,希望对你有帮助!

---------------------------------------------------------------结束分割线----------------------------------------------------------------

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值