AndroidStudio升级到3.6之后有各种问题,这里就一点点收集,之前也有这个想法但是没有写出来,今天趁着隔离期间整理一下.
1.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.
截图如下:
问题描述:
(1).我的 Android 项目采用的是 AndroidX;
(2).我首先使用的是butterknife 8.58.1版本,报错,提示我用butterknife 9.0 以上;
(3).我使用butterknife 9.0,继续报上面的错误;
(4).解决方法:我升级到最新的butterknife 10.2.1 即可.
修改后重新运行项目,可以看到下图项目运行成功:
2.项目运行时报错,错误信息如下:java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
错误原因:项目中同时使用了butterknife和view这2中方式进行视图绑定时,addIv.setOnClickListener(v ->{})使用了java8新特性.
View view = inflater.inflate(R.layout.dialog_add_cart, null);
@BindView(R.id.tv_day)
TextView tvDay;
解决方法:
build.gradle中添加以下代码:
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
重新编译项目发现问题已经解决!未完待续,后面收集到新的问题会及时更新.