android 踩坑

本文解决Android Studio升级后与Gradle不兼容的问题,包括删除旧配置、更新依赖及解决注解处理器错误。

1. 报错提示Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.

2. 报错原因:经过查找发现,在Studio升级到3.0之后原来的配置方式apt与最新版本Gradle已经不兼容,推荐使用annotationProcessor,

3.解决报错

一、把project目录下的build.gradle中如果有添加配置:请classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8'删除掉;

二、把具体Module目录下的build.gradle中如果有添加配置:请apply plugin: ‘com.neenbedankt.android-apt’删除;

三、同时把dependencies中原来使用apt

implementation 'com.google.dagger:dagger:2.16'
apt 'com.google.dagger:dagger-compiler:2.16'

改为annotationProcessor

 

implementation 'com.google.dagger:dagger:2.16'
annotationProcessor 'com.google.dagger:dagger-compiler:2.16'

然后Sync Now即可。

 

 


2、java.lang.NoSuchMethodError: No static method with(Landroid/content/Context;)Lcom/squareup/picasso/Picasso;


As I figured out this is the actual problem, when develop the com.daimajia.slider.library they used  com.squareup.picasso inside their library, but com.daimajia.slider.library developer stop update after version 1.1.5@aar therefore this library required old version of com.squareup.picasso library

Therefoer you can't use com.daimajia.slider.library with latest (2.71828) com.squareup.picasso (If your using both library same time) you can use picasso 2.3.2 or 2.5.2 with daimajia library without any issues.

 

 

【ERROR】
Incremental annotation processing requested, but support is disabled because the following processors are not incremental: android.databinding.annotationprocessor.ProcessDataBinding
【解决方案】
这是 kotlin-gradle-plugin 1.3.50 版本的一个bug。
gradle.properties 文件中添加 kapt.incremental.apt = false 来禁用增量注解处理 或者 将 kotlin_version 版本降低。
【问题】如何查看kotlin-gradle-plugin的版本号
工程-builde.gradle-------------换成1.3.20
————————————————
版权声明:本文为优快云博主「乐玩兔」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/qq_34334548/article/details/101051361

### Android 升级到 35 版本常见问题及解决方案 #### Gradle 配置兼容性问题 在将项目升级至支持 Android 15(API 级别 35)时,开发者可能会遇到与 Gradle 插件版本不兼容的问题。这是因为新版本的 SDK 要求使用特定版本的 Gradle 和插件来确保最佳性能和稳定性。为了解决这个问题,需要检查项目的 `build.gradle` 文件中的插件版本是否符合官方文档推荐的最新稳定版本,并相应地更新 Gradle Wrapper 的版本。 ```gradle // 示例:更新 build.gradle 文件中的插件版本 plugins { id 'com.android.application' version '8.0.2' // 确保这是最新的稳定版本 } ``` 同时,更新 `gradle-wrapper.properties` 中的 distributionUrl 到对应的 Gradle 版本[^2]。 #### API 变更导致的编译错误 随着新版本的推出,某些旧的 API 可能会被弃用或移除,这可能导致现有代码无法正常工作。解决这类问题的方法是查阅官方迁移指南,找到受影响的 API 并替换为新的等效实现。例如,对于被弃用的功能,应该寻找并采用建议的新方法或者类。 #### 安全性和权限管理增强 Android 15 引入了更严格的安全策略和权限控制机制。应用程序可能需要调整其请求权限的方式,以适应运行时权限模型的变化。此外,针对 WebView 组件中 JavaScript 接口的安全性,在较低版本中通过 `setJavascriptMonitor` 接口内部判断 Android 版本来决定是否调用 `addJavascriptInterface` 接口的做法不再适用,需按照新版安全要求进行调整[^5]。 #### 用户界面布局调整 由于系统 UI 行为的改变,原有的布局文件可能不会按预期显示。此时,应审查所有涉及用户界面的部分,特别是那些依赖于特定系统行为的组件。熟悉最新的布局属性和最佳实践可以帮助快速定位并修复这些问题[^3]。 #### 数据库和持久化存储问题 当应用从早期版本升级而来时,数据库结构的变化可能引发数据访问层的问题。为了应对这种情况,应当仔细规划数据库迁移脚本,并测试所有 CRUD 操作的有效性。另外,考虑到 Android 对私有目录访问权限的限制加强,确保使用合适的上下文对象获取正确的文件路径变得尤为重要[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值