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

记录Android Studio 3.1.2 编译运行SparkYuan的开源项目meizi(常见解决方法就不记录了)SparkYuan 的 CSDN 博客地址 https blog csdn net L article details meizi 的 GitHub 地址 https github com SparkYuan Meizi 1 android apt plugin is incompatible with the Android

大家好,我是讯享网,很高兴认识大家。
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' 
这种解决问题的思路,希望对你有帮助!

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

小讯
上一篇 2025-04-10 22:56
下一篇 2025-02-27 07:12

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/88725.html