問題總結

安卓錯誤經驗累積

 1、當出現下面錯誤時候
    08-21 03:43:16.679: E/AndroidRuntime(1087): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragment/com.example.fragment.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
    肯定是那個MainActivity.xml文件出了問題,就在第五行,我用的fragment,裏面的一個class="com.sss.TitleFragment" 原來是這個寫錯了,
    那個包名寫錯了,改了就好,然後再xml裏面寫時候要注意是<fragment/>第一個是小寫,不是大寫,要記住


2、mTabWeixin.setOnClickListener((OnClickListener) this);  這樣寫會報錯
08-21 04:06:16.920: E/AndroidRuntime(1274): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragment/com.example.fragment.MainActivity}: java.lang.ClassCastException: com.example.fragment.MainActivity cannot be cast to android.view.View$OnClickListener
 
 後來改成mTabWeixin.setOnClickListener(new OnClickListener(){ @Override 
        public void onClick(View arg0) {
             // TODO Auto-generated method stub
              stopService(intent);
          }});就可以了
3、 emulator: ERROR: This AVD's configuration is missing a kernel file!!
        以博客形式解決

4、emulator: ERROR: ANDROID_SDK_ROOT is undefined

      以博客形式解決
5 、ADB not responding. If you'd like to retry, then please manually kill "adb.exe" and click 'Restart'

     以博客形式解決
6、android studio 裏面修改sdk other setting default project ……
   以博客形式解決

7、CPU acceleration status: HAX kernel module is not installed!
解決方法:
  以博客形式解決

1)打開sdk manager-》Extras,勾選Intel x86 Emulator Accelerator(HAXM installer),並點擊
以博客形式解決

install packages。


2)安裝完後,進入


/Users/username/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager,路徑可能不同
,以root權限對silent_install.sh加可執行權限,chmod +x silent_install.sh
3)運行,./silent_install.sh,就ok了


8 、在andorid studio 出現了亂碼 
    File-->setting-->Appearance-->name-->修改 就可以了,還以爲是電腦問題,找了半天才搞好


9、 Gradle project sync failed. Please fix your project and try again.
    Error:failed to find Build Tools revision 23.0.0
    <a href="install.build.tools">Install Build Tools 23.0.0 and sync project</a>
     我把那個Build Tools revision 23.0.0拷貝到sdk裏面的build-tools裏面就可以了


10、當在學習binder的時候 客戶端沒有執行那個ServiceConnetion裏面的連接的時候 報了空指針的錯誤,原來我沒有在AndroidMainfest.xml配置文件寫上<service android:name=""> 下次要注意,不然連接不到服務端.


11、a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    不是主Activity啓動的,所以會報錯
    
12、ViewHolder holder=null;
    holder.img= (ImageView) convertView.findViewById(R.id.img);出現空指針異常
    要這樣寫
    ViewHolder holder=new ViewHolder();就不會報錯了
13 android:support.v4.view.ViewPager   錯了
   android.support.v4.view.ViewPager


14、Installation failed since the device possibly has stale dexed jars that don't match the current version (dexopt error). In order to proceed, you have to uninstall the existing application.


WARNING: Uninstalling will remove the application data!


Do you want to uninstall the existing application?


已運行就是這樣,死活沒辦法,最後搞了一晚上,終於找到了答案,AndroidStudio-> Build -> Clean Projects  然後等下面任務完成後,重新運行就可以了。


INSTALL_FAILED_INSUFFICIENT_STORAG
原因:空間不夠用


解決辦法:


     第一種辦法:在反覆安裝android apk的時候,有的時候可能會遇到adb install錯誤,內容是:Failure           [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
這很可能是因爲你在以前uninstall應用的時候,沒有做徹底,只是簡單的rm /data/app/下面的apk文件了,一個補救的辦法如下:
啓動模擬器,然後進入菜單
settings->applications->mange
applications-> select the application->select "unistall".
這樣就能徹底刪除了,然後再重新安裝這個apk就沒問題了


   第二種辦法:你用的是emulator?如果是的話可以在起emulator啓動的時候加個參數 例:emulator -avd android22 -partition-size 200


表示內存大小爲200M




最後我用eclipse也打開項目,同樣還是報這個install-failed insuffient storag
應該是手機內存不足了,然後我就把手機刪掉一些程序就可以了
以博客形式解決



15 getActionBar得到的actionBar是空指針異常
解決辦法 


1 getActionBar()這個方法需要放在setContentView(args)之後


2 getActionBar()這個方法是在3.0以上版本纔有的,所以在manifest清單文件中需要標註下


<uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />


3 menifest清單文件中對應的該activity的主題設置


android:theme="@style/AppTheme.FullScreen"或者
android:theme="@android:style/Theme.NoTitleBar"


都需要取消,因爲這樣就無法找到actionBar




或者父類基類ACTIVITY中需要註釋如下代碼:




//requestWindowFeature(Window.FEATURE_NO_TITLE);
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);




16、java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'java.lang.Runtime
那是因爲我在MainActivity裏面繼承了ListActivity,然後我在MainActivity裏面通過R.id.listview 得到的listview和ListActivity裏面衝突了


17、java.lang.SecurityException: Permission denied (missing INTERNET permission?) even with adding this permission in android manifest


加上<uses-permission android:name="android.permission.INTERNET"/>
記住不是加上<uses-permission android:name="android.permission.internet"/>
不然也是無效的


18、Error:Timeout waiting to lock buildscript class cache for settings file 'H:\android\ImageLoader\settings.gradle' (C:\Users\Think\.gradle\caches\2.4\scripts\settings_8kjkk683u0p1beph8uxo3q5nf\SettingsScript\buildscript). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 15396
Owner Operation: unknown
Our operation: Initialize cache
Lock file: C:\Users\Think\.gradle\caches\2.4\scripts\settings_8kjkk683u0p1beph8uxo3q5nf\SettingsScript\buildscript\cache.properties.lock


解決辦法:找到紅色標識部分文件然後刪除文件。刪除的時候會提示文件被佔用。開打進程管理器把關於java的進程結束後,在Android Stuido中重新build就可以。


19、Error:Could not run build action using Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.4'.


20、Error:(45, 0) Could not read script 'H:\android\ImageLoader\lib\gradle\maven_push.gradle' as it does not exist.
<a href="openFile">Open File</a>


解決辦法:打開所導入庫的build.gradle文件,將 apply from: ‘../maven_push.gradle’ 這行給註釋掉,同步一下就ok。


21、java.lang.IllegalStateException: ImageLoader must be init with configuration before using
imageLoader.init(ImageLoaderConfiguration.createDefault(MainActivity.this));


public ImageLoader imageLoader = ImageLoader.getInstance();


然後在Oncreate中添加imageLoader.init(ImageLoaderConfiguration.createDefault(this));

ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(MainActivity.this));


22 Unable to find the layout for Action Bar. Consider updating to a more recent version of appcompat, or switch the rendering library in the IDE down to API 21


下載Android 21放到platforms裏面就可以 


23 Can't create handler inside thread that has not called Looper.prepare()
沒有在主線程裏面創建Handler
應該加上
//初始化Looper對象
Looper.prepare();
handler1=new Handler(){
@Overide
public void handleMessge(Message msg){


}
};
//啓動Looper
Looper.loop();




24    Java.lang.NullPointerException
            at com.example.administrator.view.MainActivity$1.handleMessage(MainActivity.java:41)


    
    原來是我自己R.id.img 搞錯了 應該是R.id.imageView
25、Target device: xiaomi-mi_2-1fd295bc
Uploading file
  local path: E:\android-client\build\outputs\apk\android-client-arm-debug.apk
  remote path: /data/local/tmp/com.hztcl.quickshopping.ui
Installing com.hztcl.quickshopping.ui
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.hztcl.quickshopping.ui"
pkg: /data/local/tmp/com.hztcl.quickshopping.ui
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]


從新啓動手機




26、Android gradle build時出現Duplicate resources錯誤
項目由eclipse轉到Android studio時, 在eclipse中編譯正常, 用gradle編譯出出現Duplicate resources報錯, 項目中有部分字符串資源存在重複定義, 能不能在不刪除重複定義文件的情況下, 使gradle能正常編譯不報錯




27  android6.0 PullToRefreshWebView中的FloatMath.floor()不能用瞭如何替換
  Android6.0使用 Math.floor 代替 FloatMath.floor 即可;


28  Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 2

(1)如果是初搭環境,運行失敗。可能是安裝包路徑有空格的原因。
(2)如果以前運行項目正常,樓主標紅部分,我不知道問題出在哪。但只看問題標題的話,有的是因爲項目路徑爲漢字的問題(我今天就遇到了,把項目換個全英文的路徑就可以了)
        刪掉v4包就行了 有相同包了,注意finished這句話,刪除包,

如果還不行的話加上multiDex的配置

[html] view plain copy
 print?
  1. defaultConfig {  
  2.        applicationId "com.kuyu.kuxianghui"  
  3.        minSdkVersion 14  
  4.        targetSdkVersion 22  
  5.        versionCode 1  
  6.        versionName "1.0"  
  7.        multiDexEnabled true  
  8.    }  
就是下面的這段代碼結局我的問題
[html] view plain copy
 print?
  1. multiDexEnabled true  

29java.lang.IllegalArgumentException: Wrong arguments were passed to displayImage() method (ImageView reference must not be null)

一看到這個錯誤,頭腦裏面第一條件反射就是參數傳錯了,但是我的確傳了URL和imageView ,url有值,但是imageView那肯定沒有值,原來我只把imageView定義了,沒有初始化,沒有findviewById(R.id.imageView);下次要記得


30 org.json.JSONException: End of input at character 0 of


[html] view plain copy
 print?
  1. 10-23 21:28:11.288    7528-7528/com.kuyu.kuxianghui I/treeMapToString﹕ 199cf7bdf2dd4ea0da93cb53558e79a7  
  2. 10-23 21:28:11.288    7528-7528/com.kuyu.kuxianghui D/MD5Util﹕ BAC23EF0AEDF28F7D4CE38A9D620A75D  
  3. 10-23 21:28:11.298    7528-7528/com.kuyu.kuxianghui I/postUrl﹕ http://10.68.5.30/api/distributorCall?jsonParam={"sign":"BAC23EF0AEDF28F7D4CE38A9D620A75D","map":{},"openType":"getCaptcha"}  
  4. 10-23 21:28:11.298    7528-7528/com.kuyu.kuxianghui I/kuxianghui﹕ url:http://10.68.5.30/api/distributorCall?jsonParam={"sign":"BAC23EF0AEDF28F7D4CE38A9D620A75D","map":{},"openType":"getCaptcha"}  
  5. 10-23 21:28:11.318   7528-10533/com.kuyu.kuxianghui I/kuxianghui﹕ post Params:{jsonParam={"sign":"BAC23EF0AEDF28F7D4CE38A9D620A75D","map":{},"openType":"getCaptcha"}}  
  6. 10-23 21:28:11.338    7528-7528/com.kuyu.kuxianghui I/errorMessage﹕ org.json.JSONException: End of input at character 0 of  

原來我把opeType寫成了openType 該死的 找了好久才找到錯誤


31

[html] view plain copy
 print?
  1.     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)  
  2.     at com.android.dx.command.dexer.Main.main(Main.java:245)  
  3. UNEXPECTED TOP-LEVEL EXCEPTION:  
  4.     at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)  
  5.     at com.android.dx.command.Main.main(Main.java:106)  
  6.     at com.android.dx.command.dexer.Main.run(Main.java:277)  
  7.     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)  
  8. Error:Execution failed for task ':app:dexDebug'.  
  9. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_60\bin\java.exe'' finished with non-zero exit value 2  
  10.     at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)  
  11.     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)  
  12.     at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)  
  13.     at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)  
  14. com.android.dex.DexException: Multiple dex files define Lcom/tencent/a/a/a/a/a;  
解決辦法


[html] view plain copy
 print?
  1. defaultConfig {  
  2.     applicationId "com.kuyu.kuxianghui"  
  3.     minSdkVersion 14  
  4.     targetSdkVersion 22  
  5.     versionCode 1  
  6.     versionName "1.0"  
  7.     multiDexEnabled true  
  8. }  
就是下面這行代碼起到了作用,驚歎吧
[html] view plain copy
 print?
  1. multiDexEnabled true  


32

[html] view plain copy
 print?
  1. res\drawable-mdpi-v4\guide_1.png:0: error: Resource entry guide_1 is already defined.  
  2. res\drawable-mdpi-v4\guide_1.jpg:0: Originally defined here.  
  3.   
  4. Error:Execution failed for task ':app:processDebugResources'.  
  5. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Android\sdk\build-tools\23.0.0\aapt.exe'' finished with non-zero exit value 1  

資源一開始就有

解決辦法

build ->clean project

33 

爲什麼

[html] view plain copy
 print?
  1. <pre name="code" class="html">Toast.makeText(RegisterActivity.this, "註冊成功", Toast.LENGTH_SHORT)  

沒反應

我插,我在最後忘記寫.show()了,媽的,下次一定要記得,忘記了要打死自己。

34、

[html] view plain copy
 print?
  1. java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()  

原來是我寫的 

[html] view plain copy
 print?
  1. Toast.makeText(RegisterActivity.this, "註冊成功", Toast.LENGTH_SHORT).show()  
沒有放在ui線程裏面,所以出現這個異常,用handler去處理然後再調用就可以。

35、java.NET.SocketTimeoutException: Read timed out

原因:客戶端沒有在限定的時間內將數據發送給服務器,服務器爲了保證服務性能,認定那個連接已經失效,所以出現上述異常。 


解決辦法:增大客戶端的超時時間。

[html] view plain copy
 print?
  1. System.setProperty("sun.net.client.defaultConnectTimeout", String     
  2.                     .valueOf(10000));// (單位:毫秒)     
  3.             System.setProperty("sun.net.client.defaultReadTimeout", String     
  4.                     .valueOf(10000)); // (單位:毫秒)    


36、android:showAsAction="never"在as裏面的menu.xml裏面不可以用

解決辦法:改成 app:showAsAction="never"就可以了


37、當我們把github裏面的模塊拷貝到項目的時候,發現那個導入的包 前面是白色 後面是紅色 ,一直找不到原因,後來終於找到了 

解決辦法:

在app build.gradle裏面忘記添加 compile project(':mplib')

[html] view plain copy
 print?
  1. dependencies {  
  2.     compile fileTree(dir: 'libs', include: ['*.jar'])  
  3.     compile 'com.android.support:appcompat-v7:23.0.0'  
  4.     compile project(':mplib')  
  5. }  


38、

[html] view plain copy
 print?
  1. Error:Execution failed for task ':app:processDebugResources'.  
  2. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Think\AppData\Local\Android\sdk\build-tools\23.0.0\aapt.exe'' finished with non-zero exit value 1  

資源文件錯了,不能識別pd

39、

[html] view plain copy
 print?
  1. java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43557be8 8101:com.kuyu.kuyucontact/u0a81} (pid=8101uid=10081) requires android.permission.CALL_PHONE  

[html] view plain copy
 print?
  1. 分析原因:  
  2. 由於我的應用要撥打電話,所以需要配置相應的權限信息  
  3. 解決辦法:  
  4. 需要在(功能清單文件中)AndroiManifest.xml    Application外添加<uses-permission android:name="android.permission.CALL_PHONE"/>  
  5.       


40、今天程序報了這個異常

[html] view plain copy
 print?
  1. Unable to start activity ComponentInfo{com.kuyu.kuyucontact/com.kuyu.kuyucontact.ui.UserInfoActivity}: java.lang.NullPointerException  
空指針啊,沒有拿到數據,我還以爲是我的bundle出了問題,媽的,原來findViewById(R.id.tv_name),tv_name 這個id在其它地方命名了,所以纔會出現

Unable to start activity {.ui.UserInfoActivity}這個異常啊,麻痹的,以後切記。 

41

[html] view plain copy
 print?
  1. have you declared this activity in your AndroidManifest.xml  

沒有註冊Activity


42

[html] view plain copy
 print?
  1. duplicate registration for activity  

重複註冊了Activity,認真檢查哪個地方已經註冊了


43

[html] view plain copy
 print?
  1. android.view.InflateException: Binary XML file line #13: Error inflating class com.wingsofts.simplelinechart.SimpleLineChart  

自定義的時候,上面那個包名寫錯了


44

用eclipse 開發 android應用時出現個錯誤,“your project contains error(s),please fix them before running your application”

解決辦法:

使用eclipse寫好Android的代碼,代碼沒有報錯。想在AVD中運行測試時,總是會彈出錯誤框,提示信息爲: 


“Your project contains error(s),please fix them before running your application.” 


不管是重啓AVD 重啓eclipse 甚至創建一個新的Android工程項目都不能運行 


上網查找原因,有幾種可能: 


1.在不同的電腦下開發,而且文件存放路徑不同,錯誤的主要原因是  “.classpath”  文件的載三方類庫包路徑錯誤。 


2.也可能是你的SDK版本不存在或者沒有。 


3.編譯的class、apk文件有問題:執行清除一下就可以了。Project→Clean→Clena Projects Selected Below 選擇你出錯的項目就可以了。 


4.有可能就是最重要的這一點: 
在Program提示框中會提示: 
“Error generating final archive: Debug Certificate expired on 12-7-25 下午7:52” 




原因分析: 


android要求所有的程序必須有簽名,否則就不會安裝該程序。在我們開發過程中,adt使用debug keystore,在 preference->android->buid中設置。debug的keystore默認有效期爲一年,如果你是從一年前開始完android程序,那麼在一年後導入這個app的時候很可能出現debug keystore過期,導致你無法生成apk文件。 


此時你只要刪除debug keystore就行,系統又會爲你生成有效期爲一年的私鑰。 




解決方法: 


進入C:\Documents and Settings\Administrator\.android 刪除路徑下的debug.keystore及ddms.cfg。 


(不同環境下的目錄可能略有不同,可在eclipse中查找此路徑:Window->Preferences->Android->Build下 Default debug keystore) 


我出錯的原因是第4種,我直接刪除了.android 文件,成功解決問題 


45 

 [2016-02-20 09:38:37 - aWork] Unable to resolve target 'android-22'

解決辦法:

出現 “Unable to resolve target 'android-XX'”,解決辦法進入你的android project跟目錄,找到此文件 project.properties(或default.properties),找到target=android-XX出現此錯是因爲你的android環境跟此處不對應,那麼,你只需要將此處的android版本改成你機器上配置的android版本即可,例如target=android-15

進入activity類中,一些重寫的方法的地方總是出現 "Remove @Overrideannotation",解決辦法:出現此錯誤的原因主要是 編譯器 版本的 的問題,Java 1.5的編譯器默認對父類的方法進行覆蓋,採用@Override進行說明;但1.6已經擴展到對接口的方法;所以如果還是以java 1.5的編譯器來編譯的話,會出現錯誤,默認是java1.5的,你需要將它設置到1.6打開你的eclipse,進入 window->Preferences->Java->Compiler 把它改爲 Java1.6即可


46 把項目導入eclipse出現亂碼問題

解決辦法:

1.編碼不對
a.對某文件或某工程更改編碼:
  鼠標移到工程名或文件名,右鍵->Properties->Resource->Text file enCoding ->更改編碼(GBK、UTF-8等)->Apply->OK退出
b.修改整個命名空間的編碼
   eclipse菜單欄->Window->Preferences(preferences一般就是修改各種eclipse設置的地方)->General->Workspace->text file encoding ->更改編碼(GBK、UTF-8等)->Apply->OK退出
c.修改某個特定類型的文件(如xml文件、java文件類型)的編碼(不會受命名空間編碼的影響)
  eclipse菜單欄->Window->Preferences->General->Content types->在右視圖中選在文件類型->在Default enCoding中選擇語言->Update->Ok退出
注意:若下拉菜單欄裏面沒有你要的語言類型,可以自己用鍵盤打一個進去。如果沒有改語言類型,eclipse自然會報錯,沒有報錯就說明可以用改語言類型。
2.maven的問題
 eclipse菜單欄->Window->Preferences->Maven->Installations->User Settings->導入maven的settings.xml文件->Refresh
 但是目前maven爲什麼會導致亂碼不知道- -
3.兩個工程不同編碼方式放到一個工作空間裏面有可能會有衝突。可以嘗試着別放到一個工作空間裏面看看可不可以解決問題


47、[2016-02-20 17:13:44 - aWork] ERROR: Application requires API version 21. Device API version is 16 (Android 4.1.1).
[2016-02-20 17:13:44 - aWork] Launch canceled!


解決辦法:

原因是應用程序的版本跟模擬器的版本不一致導致的。

解決方法:修改兩個配置文件

1:在AndroidManifest.xml裏,  <uses-sdk android:minSdkVersion="8" />找到這一行,這行是表示要執行這個應用程序所需要的最低版本,把數字改成低於模擬器上面的版本。

2:在default.propertiestarget=android-14把target改爲要運行模擬器的版本就OK了。


48   Failed to install*.apk on device '': timeout

解決辦法:

前提:
1.adb shell是沒問題,排除數據線
2.eclipse的ddms中是有設備的
3.模擬器安裝N個程序是沒問題的,排除程序問題

自己找到解決方法:
1.替換數據線
2.去掉延長線
3.修改windows-per-android-DDMS     5000改爲10000,50000
4.工程文件clean


5.因爲使用的是真機,所以不存在刪掉C盤中的某些*.lock文件夾

天調試android,突然報了這個錯誤,很是鬱悶,

意思是:把程序安裝到設備失敗,超時了。

研究無果,一陣搜索,最後可以通過設置eclipse解決問題,

如下設置 

在window->preferences->Android->DDMS->ADB connection time out (ms): 

設置這一項,把值設高一些  我設置了1000000

49 adb  logcat -v threadtime > xxx.log

C盤-》用戶-》C裏面

50 The connection to adb is down,a severe error

解決辦法:adb kill-server

 adb -startserver


51 判斷遊標是否爲空

SQLite中的Cursor千萬不能使用Cursor == null 來判斷是否爲空,即便Cursor中什麼記錄都沒有,他也不會是空(已測試)。

判斷是否爲空的方法是 Cursor.getCount()這麼一個簡單的函數,如果是0,表示Cursor爲空;如果非0,則表示Cursor不爲空。


51 我們用SimpleDateFormat 需要注意的問題

SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日hh:mm");表示是12小時制

SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH:mm");表示是24小時制


52 在相對佈局裏面 如果要把一個控件放在另一個控件的左邊 記得使用 android:layout_toLeftOf="@+id/scan_code_image"


53 android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 5

自己寫遊標的時候,明明需要循環便利遊標,而我沒有加上循環,所以就出現了這個問題

if(cursor != null) {  
            // 循環遍歷cursor 
          while (cursor.moveToNext()) { 



53  android.app.application cannot be case to package.ShotApplication

錯在 AndroidManifest.xml裏面

<application 

        android:name ="com.wang.capurescreen.ShotApplication"

我沒有寫name,所以錯了,要記得加上


54 今天運行代碼的時候出現了missingFormatArgumentException異常

原因:

使用string.format("aaa%d, dsaa,""%d",a)

很明顯多了一個d%.

匹配不正確 。


55 java.net.socketimeoutexception

設置超市時間短了,settimeout時間久點就可以了

56 stException: com.example.dexclassloaderactivity.MyApplication cannot be cast to android.app.Activity

原因:我把在Android配置文件裏面application裏面的聲明改到了activity裏買去了,下次不要犯這個錯誤,寫了applicaiion一定要記得寫配置切記。

4
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章