1.Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
解决办法:发现是构建项目时引入的第三方仓库jcenter和google被屏蔽了,改为aliyun之后,项目恢复正常
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/jcenter/' }
2.java.lang.StackOverflowError
StackOverflow 这个问题一般是你的程序里头可能是有死循环或递归调用所产生的;
3.java.io.NotSerializableException
外部类序列化的情况下,内部类也要序列化,不然就会出现NotSerializableException异常
4.Program type already present: io.jsonwebtoken.io.OrgJsonSerializer
运行项目突然出现,网上试了各种方法都不行,后来rebuild项目之后好了
5. java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
解决办法:使用glide,又踩了一次坑,iv使用settag时一定要记得调用 ----》》public void setTag(int key, final Object tag),切记
6.编辑项目出现transformClassesWithDexForDebug异常
解决办法:经过一轮筛查发现是build gradle 版本的问题,从3.2.1升级到3.3.1解决问题
classpath 'com.android.tools.build:gradle:3.3.1'
7.Invalid escape sequence at line
解决办法:升级build gradle到3.3.1的时候出现的,因为gradle编译文件格式出现的问题,在gradle.properties 文件中加上
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 同步一下就ok
之前项目运行正常,后来突然出现这个问题,rebuild project和run都提示报错,但是gradlew命令没问题,好奇怪,寻找答案中。。。
8.修复沉浸式状态栏黑条问题
/** * @param activity 隐藏Android p黑条的问题(三星A30s) */ private static void hideBlackBar(Activity activity){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){ WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; activity.getWindow().setAttributes(lp); } }
9.INSTALL_FAILED_TEST_ONLY的原因及解决方案
Android Studio 3.0会在debug apk的manifest
文件application
标签里自动添加 android:testOnly="true"
属性,所以只需要在gradle.property文件中设置“android.injected.testOnly=false”就可以
10.输入法弹出时把整体界面往上顶设置:
第一步:清单文件activit配置为:
android:windowSoftInputMode="adjustResize"
第二部:activity初始化方法内设置setFitsSystemWindows(true);
例如:getBinding().rlvRoomBg.setFitsSystemWindows(true);
11.运行网络请求报错,提示:CLEARTEXT communication to sjpint-rancher.xiu361.cn not permitted by network security policy
解决办法:
在9.0中默认情况下启用网络传输层安全协议 (TLS),默认情况下已停用明文支持。也就是不允许使用http请求,要求使用https。比如okhttp,会报错:
|
解决方法:是需要我们添加网络安全配置。首先在res目录下新建xml文件夹,添加network_security_config.xml文件:
|
AndroidManifest.xml中的application添加:
|
12.AAPT: error: resource android:attr/lStar not found
原因:升级了一个sdk,里面包含了appcompat:1.4.0版本,
解决办法:把版本改成1.2.0就可以
implementation 'androidx.appcompat:appcompat:1.2.0
13.SQL 语句查询出现异常:
select * from( select * from ( select ifnull(t2.money,0) as money,t.* from T_newuser t left join Chat_temporary t2 on t._from=t2.fuid and t.uid=t2.uid where t.uid=30243899 and t.notreadnum>0 order by t2.money desc,t.dateline desc ) t1 union all select * from ( select 0 as money,t3.* from T_newuser t3 where t3.uid= 30243899 and t3.notreadnum=0 order by t3.dateline desc ) t5 ) t6 limit 0,20
本来这个语句是要查询索引为0开始的20条记录,但是结果给我了21条,一直没明白为啥会这样?
14. java.lang.SecurityException: Writable dex file '/data/data/sh.stream.assistant/code_cache/.overlay/base.apk/classes4.dex' is not allowed.
解决办法:禁用Android Studio动态加载的打包优化在Run/Debug Configurations中勾选
Always install with package manager (disables deploy optimizations on Android11 and later。缺点是会减慢一点打包安装速度
、、、