android筆記,android學習筆記

來源:互聯網
上載者:User

android筆記,android學習筆記

1. 不要把int值傳參給textview控制項的setText函數,因為當你傳int類型的時候,它會以為要傳的是一個resource的id。

這種時候報的錯是:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ndktest/com.example.ndktest.MainActivity}: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x4

注意最後那個4,其實就是我想傳給setText函數的值


2. java.lang.UnsatisfiedLinkError: Native method not found兩種可能解決方案

a. Jni方法頭部大小寫問題:在C++中,方法名:Java_com_XXX,而不是java_com_XXX。建議直接從產生的.h標頭檔直接複製方法名到C或者C++檔案中。

b. C++檔案問題:如果是C++檔案(.cpp或者.cc),要使用extern "C" {   } 把本地方法括進去。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.