• 安卓奇葩问题之:运行OK,打包安装崩溃(原因是:代码不规范导致编译出错)


    咳咳,还是那句话,真是日了狗了

    这个问题真的很难找,废话不多少,上酸菜。

    报错信息是这个方法返回的图片找不到

    public static int getImgID(boolean isBig, int id) {
            if (id == -2)
                return R.mipmap.tianjia;
            if (id == -1)
                return R.mipmap.jiahao;
            if (isBig) {
                switch (id) {
                    case 0:
                        return R.mipmap.jrfu;
                    case 1:
                        return R.mipmap.meishi;
                    case 2:
                        return R.mipmap.shenghuo;
                    case 3:
                        return R.mipmap.yule;
                    case 4:
                        return R.mipmap.dying;
                    case 5:
                        return R.mipmap.chuxing;
                    case 6:
                        return R.mipmap.jingdian;
                    case 7:
                        return R.mipmap.gouwu;
                    case 8:
                        return R.mipmap.jiudian;
                    case 9:
                        return R.mipmap.zhiyuan;
                    case 10:
                        return R.mipmap.xsyl;
                    case 11:
                        return R.mipmap.jrfu;
                }
                return R.mipmap.guanggao;
            } else {
                switch (id) {
                    case 0:
                        return R.mipmap.jrfw;
                    case 1:
                        return R.mipmap.ms;
                    case 2:
                        return R.mipmap.shfw;
                    case 3:
                        return R.mipmap.yl;
                    case 4:
                        return R.mipmap.dy;
                    case 5:
                        return R.mipmap.cx;
                    case 6:
                        return R.mipmap.jingdian_xiao;
                    case 7:
                        return R.mipmap.gw;
                    case 8:
                        return R.mipmap.jd;
                    case 9:
                        return R.mipmap.zyhn_xiao;
                    case 10:
                        return R.mipmap.xsyl_xiao;
                    case 11:
                        return R.mipmap.jrfw;
                }
                return R.mipmap.logo;
            }
        }

    问题来了,运行代码是OK的。

    然后天空一声巨响,醍醐灌顶。代码写的不规范,没有用break,编译有问题,才会报错的。

  • 相关阅读:
    排列组合
    从$a_n=f(n)$的角度理解数列中的表达式$a_{n+1}=frac{k}{a_n}$
    洛必达法则的应用
    三角函数专题
    和差角公式的证明
    利用导数证明不等式
    常用数学模型整理
    教给学生知识的本源
    争鸣|两个易混概率题
    es6数组的复制
  • 原文地址:https://www.cnblogs.com/a446276468/p/5955912.html
Copyright © 2020-2023  润新知