Tag Archives: boiler

Android activity Fail to Switch to androidx AppCompatActivity Error

java.lang.IllegalStateException: You need to use a Theme. AppCompat theme (or descendant) with

Error reason:

1, style.xml file has properties that are inherited from ordinary android, however, your activity has inherited AppCompatActivity, so the properties of style should also be changed to the properties below androidx.


Find the properties of the normal android package in the style.xml file and replace them with the properties of androidx.

Room DB Error: AppDatabase_Impl does not exist [How to Solve]

Kotlin tests the use of Android Room, and when calling Room.databaseBuilder in coroutine, it reports an error:

AppDatabase_Impl does not exist

After checking the developer documentation, you can configure it according to the documentation. After thinking deeply, you find that there is a problem with the developer documentation

dependencies {
    val room_version = "2.4.3"


    // To use Kotlin annotation processing tool (kapt)
    // To use Kotlin Symbol Processing (KSP)

    // optional - Kotlin Extensions and Coroutines support for Room

    // optional - RxJava2 support for Room

    // optional - RxJava3 support for Room

    // optional - Guava support for Room, including Optional and ListenableFuture

    // optional - Test helpers

    // optional - Paging 3 Integration

The above developer documents give, but when adding dependencies, one dependency is:


So the problem lies here. There is a dependency of Kapt, but there is no plugin of Kapt

The final solution:

Modify the configuration of app gradle.build to add the plugin kotlin-kapt, as follows:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'

Then confirm the three dependency dependencies related to room:


[Solved] Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of

Problem Description: my project was fine the day before yesterday. Suddenly, the following error was reported after opening it the next day

Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16.

I didn’t use kotlin either. Finally, I recompiled the project when compiling


Kotlin: How to Solve kapt import error

The first problem encountered was that the BR file could not be found

Log: unresolved reference: BR

Reason: the plug-in developed by kotlin does not support cross module, so the reference of databinding when using APT Technology br file does not determine the directory, so the error (unresolved reference: be) is caused, so it needs to be completed by kapt


apply plugin: 'kotlin-kapt'
kapt {
    generateStubs = true

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //The version should be the same as the gradle version
    kapt  "com.android.databinding:compiler:3.5.0"

New problem: Class not found Custom generated class can not be generated.

Reason: If you already have kapt, you need to replace it with kapt

Solution: In Kotlin, you need to add the kotlin-kapt plugin to activate kapt and replace the annotationProcessor with kapt.

Execution failed for task ‘:app:kaptDebugKotlin‘ [How to Solve]

Error compiling project with kotlin:

Execution failed for task ‘:app:kaptDebugKotlin’.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
various kotlin annotation errors will be reported

The problem is that the version of kotlin plug-in is inconsistent with that in build

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Check the version of the org.jetbrains.kotlin:kotlin-gradle-plugin is consistent with the version of the kotlin that the module depends on or not.

How to Solve Android jetpack Room Schema export Error

1. When using the Android Room database, the following error occurs:

Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide room.schemaLocation annotation processor argument OR set exportSchema to false.

2. There are two kinds of solutions.
1). Set the exportSchema annotation to false for RoomDatabase. default is true

@Database(entities = [TableItem::class], version = 1,exportSchema = false)
abstract class AppDataBase : RoomDatabase() {
    abstract fun tableItemDao(): TableItemDao

2) Add in the build.gradle of the app (recommended)
There are different configuration syntaxes for java environment and kotlin environment. Depending on the personal environment configuration, only one way of writing can exist for both. My environment is a kotlin environment, so use the kotlin environment writing method. At the beginning, I used the java environment writing method, and the result kept reporting errors, and only after changing to kotlin did it work.

    defaultConfig {
        applicationId "XXX"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        //Specify the path to the file generated by room.schemaLocation, java environment (choose one of the two, depending on the project environment)
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]

        //Specify the path to the file generated by room.schemaLocation, kotlin environment (choose one of the two, depending on the project environment)
        kapt {
            arguments {
                arg("room.schemaLocation", "$projectDir/schemas")

3. After configuration and compilation, JSON structure files of data will be generated in the following directory:

Kotlin develop Error: java.lang.VerifyError [How to Solve]

When using kotlin+ coroutine, compiling APK will throw Java lang.VerifyError: Verifier rejected class …

Cause: a supend method marked by a coroutine uses @JvmStatic annotation, resulting in a verify error when compiling and parsing code.

Solution: remove the annotation of the supend method.

Reference: https://stackoverflow.com/questions/59113152/java-lang-verifyerror-verifier-rejected-class-code-working-fine-in-debug-mode

[Solved] Android Kotlin Package release Error: Lint found fatal errors while assembling a release target.


Recently, I wrote in kotlin that I was playing
and reported an exception in the packaged version of release

Lint found fatal errors while assembling a release target.
unable to read PNG signature: file does not start with PNG signature.


 release {
            lintOptions {
                checkReleaseBuilds false
                abortOnError false


[Solved] AAPT: error: resource android:attr/lStar not found

Recently, I want to try the KTX expansion Library of Android core in the project:

implementation "androidx.core:core-ktx:1.7.0"

After adding dependency, we happily start to use various concise syntax sugars provided by KTX to fly happily~

Once running, wow, I reported an error:

Android resource linking failed /Users/xxx/.gradle/caches/transforms-2/files-
 AAPT: error: resource android:attr/lStar not found.


Solution 1:

If the dependency method is
AndroidX.Core: core-ktx:+
you need to replace it with a specific version

Solution 2:

If the version is  1.7.0, the compilesdkversion of the project is 31, because my project is 30, an error will be reported and changed to 1.6.0 version is good

Kotlin gets the ID automatically error [How to Solve]

Use Android studio to automatically create a kotlin project. To automatically obtain the ID in the layout in the project, you need to follow the steps below

1. In the project build Add ‘kotlin Android extensions’ to gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'

2. To modify the configuration of sourcecompatibility, the default studio is automatically created using kotlin_version

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8

3. Find gradle.properties file in the root directory of the project, Add android.enableJetifier=true:


All right! Then you can use it.
when using it, you need to import the layout file.
normally, press and hold act + enter to select import for automatic import, or you can add it manually. For example, the name of my layout file is activity_main.XML that is import kotlinx android.synthetic.main.activity_main.*

 import kotlinx.android.synthetic.main.activity_main.*

How to Solve Kotlin unresolved reference error

A crazy problem is that after the project is transferred to kotlin, it always reports: unresolved reference: XXXXXXX
the pre compilation of the project can report no error, but the problem is reported as soon as the mark is marked. The location of the problem is related to the interface defined by kotlin in in the project,
so it begins to solve:
check whether there are bugs in the definition code of the interface. The conclusion is no problem. Check whether there are bugs in the implementation of the interface. The conclusion is that the implementation class has not been executed to the environment, whether there are problems, and the version of gradle and other related tools has not been upgraded. Therefore, create a new kotlin module to import the error interface class, Results it works normally

when defining the interface of kotlin in the module of Java environment, an error will be reported during compilation.