报错

1.当写数据库出现这个错时
Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase
先看看有没有注册Application
2.java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.content.ContextWrapper.getCacheDir()' on a null object reference
没有注册Application
3.Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $;
解决方法:“build >> clean project”
4.Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
意思是:无法将用JVM目标1.8生成的字节码内联到用JVM目标1.6生成的字节码中。请指定正确的'-jvm target'选项
解决办法:kotlinOptions { jvmTarget = 1.8}把这句话添加到 android 下面 然后 Sync Now一下就OK了

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.mykotlin"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    kotlinOptions { jvmTarget = 1.8}

5.用adb安装Apk时报INSTALL_FAILED_UPDATE_INCOMPATIBLE
解决办法:debug包没删除。debug包和正式包签名不一致

你可能感兴趣的:(报错)