'A failure occurred while executing org.jetbrains.kotlin.gradle.internal

Building of my android app failed with a new strange set of errors:

theapp/app/build/generated/data_binding_base_class_source_out/debug/out/com/comTest/theapp/databinding/TabPinBinding.java:48: error: illegal '.' public final com.comTest.theapp..utilsviews.MyTextView pin8;

The class MyTextView is defined in theapp/utils/views/MyTextView.kt it looks like the generator of java code makes a mistake.

As this code is right in generated java, I don't know how to correct the error or where to begin with to fix the problem.

The application compiled fine then I did the following:

  • created a scratch.kt file where I needed to import some file defined in the utils folder
  • updated some stuff (gradle pluggin, targetSDK value, remove redundant dependencies) following suggestion of android-studio. It was the usual stuff when updating android-studio internals.

the errors appear in the file TabPinBinding.java which start with: "// Generated by view binder compiler. Do not edit!"



Solution 1:[1]

I find the error. It comes from a layout not used anymore in the project.

<?xml version="1.0" encoding="utf-8"?>
<com.comTest.theapp..utilsviews.PinTab
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pin_lock_holder"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <com.comTest.theapp..utilsviews.MyTextView
            android:id="@+id/pin_lock_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/small_margin"
            android:paddingLeft="@dimen/activity_margin"
            android:paddingRight="@dimen/activity_margin"
            android:paddingTop="@dimen/activity_margin"
            android:text="@string/enter_pin"/>
    <!-- other fields -->
</com.comTest.theapp..utilsviews.PinTab>

I do not know why the layout uses a wrong path to access the Layout class defined in the project but I suspect a bug of the IDE when propagating changes related to renaming or moving of the Layout class file. This change was made a long time ago, and gradle and android studio seemed to have ignored the problem so far. Why it pops up now ? I have updated the kotlin version to Java 8 (sourceCompatibility "1.83) and other changes. It looks that many problems are poping up...

To find the problem I made a search on the entire project with the string com.comTest.theapp..utilsviews

To remove the problem, I corrected the paths in the layout to : com.comTest.theapp.utils.views wherever the error occured.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1