關於安卓一些報錯的解決方法(隨時更新)


1.Program type already present

依賴包沖突

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.3.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:design:25.3.0 less... (Ctrl+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

若按提示加入

//noinspection GradleCompatible

  編譯不會出現問題但在調試的時候就會報錯

看提示應該是com.android.support:design版本和com.android.support:appcompat中顯示的版本沖突,這時候把design版本置換即可,在dependencies中加入:

implementation 'com.android.support:design:27.1.1'

 

2.Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

textview綁定錯誤,檢查xml文件下id或xml文件是否綁定正確

 

3.Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference

原因:定義了 List<E> lists;   但並沒有初始化

解決方法:

在使用前加入:

List<E> lists = new ArrayList<>();

 

4.Error: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.

解決方法:

找到gradle.properties文件,將為注釋掉的內容更換為:

org.gradle.jvmargs=-Xmx512m

 然后重啟項目


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM