安卓奇葩問題之:運行OK,打包安裝崩潰(原因是:代碼不規範導致編譯出錯)

來源:互聯網
上載者:User

標籤:

咳咳,還是那句話,真是日了狗了

這個問題真的很難找,廢話不多少,上酸菜。

報錯資訊是這個方法返回的圖片找不到

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,編譯有問題,才會報錯的。

 

安卓奇葩問題之:運行OK,打包安裝崩潰(原因是:代碼不規範導致編譯出錯)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.