Android开发问题集

1. 项目拉取下来,开启小飞机,更新远程仓库aar失败

解决方案:先关闭科学上网小飞机,然后注释掉项目中gradle.properties最后配置的代理信息,重新make项目,待其它远程库aar拉取完成后,再次打开小飞机解开刚才注释掉的代理信息,make就成功了

2. org.gradle.internal.resolve.ArtifactResolveException: Could not download kotlin-compiler-embeddable-1.6.10-RC.jar

Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.6.10-RC/kotlin-compiler-embeddable-1.6.10-RC.jar'
问题原因:新创建module是kotlin版本的,会自动创建最新版本1.6.10kt插件,可能是资源不那么优,下载该插件及其缓慢,报错后,建议修改自己之前项目用的kt版本
解决方案:根目录build.gradle修改kotlin-gradle-plugin版本,改成之前可运行项目的kt版本即可

3. Execution failed for task ':app:processDebugGoogleServices'.

No matching client found for package name 'com.jitu.station.malaysia'
Execution failed for task ':app:kaptDebugKotlin'
解决方案:
(1)、对比gradle版本 和 kotlin版本是否一致
(2)、看一下项目的jdk版本是否是11 一般默认是选择的jdk8 把jdk版本换成jdk11编译一下(步骤:Settings-Build,Execution,Deployment-Build Tools-Gradle)
(3)、如果集成google相关的功能,配置文件google-services.json中的包名 也就得修改成项目环境对应的

4. Invocation failed Unexpected end of file from server

java.lang.RuntimeException: Invocation failed Unexpected end of file from server
Caused by: java.net.SocketException: Unexpected end of file from server
由于服务器文件意外结束导致调用失败
解决方案:
AS-Settings-Git-Use credential helper勾选该选项 应用即可

5. javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

http://127.0.0.1:1080/pac?hash=aP9esBdy1Q_7XzF69LAkKQ2&secret=UrdRGSbv_v7MIZ5MO3sRXFinh-N9wmuop4jMwTo3w201

6. loading style failed: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.












Execution failed for task ':app:processDebugMainManifest'.

Manifest merger failed with multiple errors, see logs

hideSoftInputFromWindow ignore mServedView == null or mServedView.getWindowToken() != windowToken, mServedView :androidx.appcompat.widget.AppCompatEditText{45e7489 VFED..CL. .F...... 0,0-296,161 #7f090182 app:id/etInputWidth}

7.

android:inputType="textPassword"
android:imeOptions="actionDone"
android:singleLine="true"

imeOptions 配合 singleLine一起使用生效 其它不生效

8. // 不混淆 Hawk 过滤掉包名 com.orhanobut.hawk

-keep class com.orhanobut.hawk.** { *; }
java.lang.AssertionError: illegal type variable reference
at libcore.reflect.TypeVariableImpl.resolve(TypeVariableImpl.java:111)
at libcore.reflect.TypeVariableImpl.getGenericDeclaration(TypeVariableImpl.java:125)
at libcore.reflect.TypeVariableImpl.hashCode(TypeVariableImpl.java:47)
at java.util.Arrays.hashCode(Arrays.java:4071)
at com.google.gson.internal.TypesGsonTypes.java:1) at com.google.gson.reflect.TypeToken.<init>(TypeToken.java:4) at m8.j.<init>(HawkConverter.java:1) at m8.m.a(HawkConverter.java:24) at m8.d.get(DefaultHawkFacade.java:34) at m8.g.b(Hawk.java:1) at com.jitu.station.malaysia.ui.search.SearchOrderActivity.init(SearchOrderActivity.kt:28) at com.jitu.android.common.base.JTBaseViewBindActivity.onCreate(JTBaseViewBindActivity.kt:15) at com.jitu.station.malaysia.base.MalayBaseActivity.onCreate(MalayBaseActivity.kt:3) at android.app.Activity.performCreate(Activity.java:7894) at android.app.Activity.performCreate(Activity.java:7883) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1353) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3655) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3835) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThreadH.handleMessage(ActivityThread.java:2291)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:230)
at android.app.ActivityThread.main(ActivityThread.java:8024)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)

9. java.lang.IllegalStateException: Fragment XXX not attached to an activity

判断页面是否被添加 isAdded
初始化的数据,可以延迟加载(关键词修饰:lateinit),在页面加载后,记得初始化所需数据

10. Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager

解决方案:
(1). Sdk\build-tools\31.0.0 - 将 d8.bat 重命名为 dx.bat
(2). Sdk\build-tools\31.0.0\lib - 将 d8.jar 重命名为 dx.jar

11. DSBridge

定义的异步或同步方法中,携带参数的需要类型Any指定

12. android11 系统 蓝牙适配、获取存储权限

13. 标签/别名设置相关问题:

https://go48pg.yuque.com/docs/share/b0c4a80d-635d-4f5b-99fd-c9dec8edd038#ybAXn
集成极光推送错误码常见问题:https://docs.jiguang.cn/jpush/client/Android/android_code
错误码:6011 短时间内操作过于频繁-10s 内设置 tag/alias/property 大于 10 次,或 10s 内设置手机号码大于 3 次
错误码:6021、6022 tags或alias-操作正在进行中暂时不能进行其他 tags或alias 操作,多次调用 tags或alias 相关的 API,请在获取到上一次调用回调后再做下一次操作;在未取到回调的情况下,等待 20 秒后再做下一次操作
错误码:6017、6027 别名上限,最多允许绑定 10 个设备,一般情况下会在测试账号上面出现此问题,但是也难免业务测试时遇到,解决方案,就是后台暴露一个检测别名绑定设备数量、清除别名的相关接口,具体的可以查看极光后台对接文档
别名相关操作:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device
查询别名:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device#%E6%9F%A5%E8%AF%A2%E5%88%AB%E5%90%8D
删除设备的别名:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device#%E5%88%A0%E9%99%A4%E8%AE%BE%E5%A4%87%E7%9A%84%E5%88%AB%E5%90%8D

14. com.alibaba.android.arouter.exception.HandlerException ARouter::Parameter is invalid!

源码中:
if (TextUtils.isEmpty(path)) {
    throw new HandlerException(Consts.TAG + "Parameter is invalid!");
}
private String extractGroup(String path) {
    if (TextUtils.isEmpty(path) || !path.startsWith("/")) {
        throw new HandlerException(Consts.TAG + "Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!");
    }

    try {
        String defaultGroup = path.substring(1, path.indexOf("/", 1));
        if (TextUtils.isEmpty(defaultGroup)) {
            throw new HandlerException(Consts.TAG + "Extract the default group failed! There's nothing between 2 '/'!");
        } else {
            return defaultGroup;
        }
    } catch (Exception e) {
        logger.warning(Consts.TAG, "Failed to extract default group! " + e.getMessage());
        return null;
    }
}

路由path为空,或没有指定两层路径
解决方案:路由path为空检测,是否是包含两个“/”

15. Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

出现上面两个问题的原因及解决方案:
(1). 新增表字段或者新增表,数据库没有升级版本号(99%是此原因)
(2). 项目组件化时,两个module创建了相同的两个数据库导致,修改下其中一个库名
(3). 还有个自欺欺人的解决方案,是网上一片文章(https://blog.51cto.com/xxx)说的,应用卸载重装(上去就想给他一个大嘴巴子唉-_-唉)

16.

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)
* or
> Task :app:kaptUatKotlin FAILED

Execution failed for task ':app:kaptUatKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

解决方案:
方法:一般涉及的库(Room、ARouter同时确认下,自己项目是kt还是java 确认相应的引入方式),接着确认项目Gradle JDK版本,使用11版本,然后Invalidate Caches重启AS

17. class com.bumptech.glide.load.engine.GlideException: Failed to load resource

解决方案:
(1). 先确认加载图片的地址是否正确,浏览器是否可打开,如果浏览器可以预览,再次检查链接前后是否有空格
(2). 加载的图片是否有请求头相关参数的校验,如果有的话,加载图片时携带服务器指定的请求头参数
(3). 如果是低系统手机可以加载http链接,9.0开始的系统默认是不支持http,需要支持给application添加属性usesCleartextTraffic="true"

你可能感兴趣的:(Android开发问题集)