byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

net.bytebuddy.pool.TypePool$Resolution$NoSuchTypeException: Cannot resolve type description for androidx.room.RoomDatabase

Open mmelkis opened this issue 5 months ago • 3 comments

We have an Android app written in Kotlin, and use androidx.room for local Database implementation.

Bytebudy version: 1.17.6 Room versions: 2.7.0, 2.7.2

When building the app, we get the following error:

Failed to transform class com.packagename.db.OurRoomDB: [net.bytebuddy.pool.TypePool$Resolution$NoSuchTypeException: Cannot resolve type description for androidx.room.RoomDatabase]

It is a standard Room Database implementation.

Attempted with Java compiler with versions 17 and 21.

mmelkis avatar Jul 30 '25 05:07 mmelkis

This means that the plugin cannot find the androidx/room/RoomDatabase.class from the class loader / environment. Is this class file available?

raphw avatar Jul 30 '25 06:07 raphw

ClassLoader result is in fact null, maybe the problem is with how RoomDatabase is compiled:

abstract class OurRoomDB : RoomDatabase() { ...

And the signature of RoomDatabase (from androidx.room package):

/**
 * Base class for all Room databases. All classes that are annotated with [Database] must extend
 * this class.
 *
 * RoomDatabase provides direct access to the underlying database implementation but you should
 * prefer using [Dao] classes.
 *
 * @constructor You cannot create an instance of a database, instead, you should acquire it via
 *   [#Room.databaseBuilder] or [#Room.inMemoryDatabaseBuilder].
 * @see Database
 */
actual abstract class RoomDatabase { ...

When going from RoomDatabase to its Source the actual class name is "RoomDatabase.android.kt"

mmelkis avatar Jul 30 '25 06:07 mmelkis

But if the class file available?

classLoader.getResourceAsStream("androidx/room/RoomDatabase.class") 

should return a value.

raphw avatar Jul 30 '25 06:07 raphw