Android 自学杂记 - 异常

  • Caused by: org.litepal.exceptions.InvalidAttributesException: dbname is empty or not defined in litepal.xml file

assets 目录下的 litepal 忘了加后缀

  • 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference

findViewById 不能在 setContentView(R.layout.activity_main) 的前面

  • Recyclerview 子项间距差了一个 match_parent 距离

Recyclerview 的 item 视图时,把 layout_height 写成 match_parent

  • listview 滚动时顶部不能填充

添加配置android:clipToPadding="false"

参考: https://blog.csdn.net/litefish/article/details/52471273

  • java.lang.NullPointerException: Attempt to get length of null array

添加读写SD卡的权限, 另外记得权限申请需要放在读写操作之前

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEM"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  • 编译不通过

添加其他仓库

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        google()
        mavenCentral() 
        mavenLocal()
    }
}

猜你喜欢

转载自blog.csdn.net/Arsenic_Tuco/article/details/85046219
今日推荐