@BindView使用遇到的一些坑 2020-09-02

2023-12-06 12:58
文章标签 2020 使用 02 遇到 09 bindview

本文主要是介绍@BindView使用遇到的一些坑 2020-09-02,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

@BindView使用遇到的一些坑

  • 先介绍使用方法
    引入包build.gradle
    如果你的项目使用的是 support包

    api ‘com.android.support:recyclerview-v7:27.1.1’
dependencies {implementation 'com.jakewharton:butterknife:8.8.1'annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'}

使用方法
@BindView(R.id.frameLayout01)
FrameLayout frameLayout01;

重要的一步
ButterKnife.bind(this);此行代码必须加不然会导致程序崩溃

报错
xxxx has stopped
logcat报错

Caused by: java.lang.ClassNotFoundException: Didn’t find class “android.view.View$OnUnhandledKeyEventListener” on path: DexPathList[[zip file “/data/app/com.xiaocaoer.canvaspath-XsbIg-aFj-9UpfkK9ZBpHQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.xiaocaoer.canvaspath-XsbIg-aFj-9UpfkK9ZBpHQ==/lib/x86, /system/lib, /vendor/lib]]

Caused by: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xb0ab2640: I/O error during system call, Connection reset by peer

Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
at com.google.android.apps.gsa.speech.audio.Tee.f(SourceFile:103)

如果你项目中使用的是androidx包
implementation ‘androidx.appcompat:appcompat:1.2.0’
implementation ‘androidx.constraintlayout:constraintlayout:2.0.0’
报错
The given artifact contains a string literal with a package reference ‘android.support.v4.content’ that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
解决办法
那么你引入的包需要改一下版本,因为10.1.0以下版本依赖使用的support包
修改引入10.1.0版本以上

  implementation 'com.jakewharton:butterknife:10.1.0'annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

报错2
com.android.tools.r8.a: Static interface methods are only supported starting with Android N (–min-api 24): void butterknife.Unbinder.lambda$static$0()

com.android.tools.r8.a: Static interface methods are only supported starting with Android N (–min-api 26): void butterknife.Unbinder.lambda$static$0()

原因
仅从Android N开始支持静态接口方法。需要指定java编译版本
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

本人java开发人员,最近因为公司中android需要改一些bug所以学习一些dndroid知识遇到的坑,希望能帮助到你,不对的地方希望android大神指点。

这篇关于@BindView使用遇到的一些坑 2020-09-02的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/461913

相关文章

Python的端到端测试框架SeleniumBase使用解读

《Python的端到端测试框架SeleniumBase使用解读》:本文主要介绍Python的端到端测试框架SeleniumBase使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录SeleniumBase详细介绍及用法指南什么是 SeleniumBase?SeleniumBase

Java继承映射的三种使用方法示例

《Java继承映射的三种使用方法示例》继承在Java中扮演着重要的角色,它允许我们创建一个类(子类),该类继承另一个类(父类)的所有属性和方法,:本文主要介绍Java继承映射的三种使用方法示例,需... 目录前言一、单表继承(Single Table Inheritance)1-1、原理1-2、使用方法1-

Android DataBinding 与 MVVM使用详解

《AndroidDataBinding与MVVM使用详解》本文介绍AndroidDataBinding库,其通过绑定UI组件与数据源实现自动更新,支持双向绑定和逻辑运算,减少模板代码,结合MV... 目录一、DataBinding 核心概念二、配置与基础使用1. 启用 DataBinding 2. 基础布局

Android ViewBinding使用流程

《AndroidViewBinding使用流程》AndroidViewBinding是Jetpack组件,替代findViewById,提供类型安全、空安全和编译时检查,代码简洁且性能优化,相比Da... 目录一、核心概念二、ViewBinding优点三、使用流程1. 启用 ViewBinding (模块级

SpringBoot中使用Flux实现流式返回的方法小结

《SpringBoot中使用Flux实现流式返回的方法小结》文章介绍流式返回(StreamingResponse)在SpringBoot中通过Flux实现,优势包括提升用户体验、降低内存消耗、支持长连... 目录背景流式返回的核心概念与优势1. 提升用户体验2. 降低内存消耗3. 支持长连接与实时通信在Sp

python使用库爬取m3u8文件的示例

《python使用库爬取m3u8文件的示例》本文主要介绍了python使用库爬取m3u8文件的示例,可以使用requests、m3u8、ffmpeg等库,实现获取、解析、下载视频片段并合并等步骤,具有... 目录一、准备工作二、获取m3u8文件内容三、解析m3u8文件四、下载视频片段五、合并视频片段六、错误

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

nginx启动命令和默认配置文件的使用

《nginx启动命令和默认配置文件的使用》:本文主要介绍nginx启动命令和默认配置文件的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录常见命令nginx.conf配置文件location匹配规则图片服务器总结常见命令# 默认配置文件启动./nginx

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4