1. 程式人生 > >android開發錯誤集錦

android開發錯誤集錦

  Error:Execution failed for task ':app:validateSigningBaiduDebug'.
  > Keystore file          D:\project_space\AgronetByGit3.08\app\Users\xiaoxian\Desktop\Agronet_andriod\AgronetByGit3.08\Agronet_Android.keystore not    found for signing config 'debug'.


原因是:缺少簽名檔案或簽名問檔案路徑有錯    ----------------------------------- >在android studiofile--->projecte structure ----------->app-------->signing------->store fie指定                     正確的簽名檔案路徑即可
二:Gradle sync failed:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.3/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
Consult IDE log for more details (Help | Show Log)

原因:Gradle Property的記憶體空間分配不夠  -----------------> 修改記憶體配置如下同步即可:
org.gradle.jvmargs=-Xmx536m -XX:MaxPermSize=536m
三:        Process: com.sunstar.cloudseeds, PID: 14437
                                                                        java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
需要移除父節點的子節點view
方法:if(parent!=null){parent.removeAllView();}
parent.addView(view);
四:Exception in thread "main" java.util.ConcurrentModificationException
    這個錯誤是在遍歷資料集時,刪除該集合的元素,資料集長度沒有重新整理,導致遍歷無法確定該資料集合的長度,因此報錯
    解決方法:方法1.新建一個集合儲存可能要刪除的資料,以原集合為遍歷的物件即可解決
                 List<String> aa=new ArrayList<>();
                 List<String> bb = new ArraList<>();
                 bb.addAll(aa);
                 for(int i=0;i<aa.size();i++){
                      String s=bb.get(i);
                     if(s1.equals(s)){
                       
bb.remove()
                         }
                 }
             方法2.以原集合為遍歷物件,每次移除原集合的元素後,重新整理資料在執行遍歷(這種方法我沒試,理論上可以)
                   每次remove後,呼叫notify();重新整理資料集
五:Caused by: libcore.io.ErrnoException: fcntl failed: EAGAIN (Try again)
    AndroidStudio 編譯異常java.lang.OutOfMemoryError: GC overhead limit exceeded
    一碰到這樣就腦袋大,錯誤無從下手,終於在google有人回答了這個,在build.gradle中的android{}新增如下指令碼就可以順利編譯了 
dexOptions { 
incremental true 
javaMaxHeapSize “4g” 
}
六.解決 app:transformClassesWithDexForDebug 錯誤