Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: Engine (WallpaperService)

I'm trying to extend android.service.wallpaper.WallpaperService.Engine class in Kotlin, but I get "Unresolved reference" error:

Unresolved reference: Engine

Even though it is clearly imported above.

Is there any way to fix this?

like image 629
Aleksandar Stefanović Avatar asked Sep 13 '25 11:09

Aleksandar Stefanović


1 Answers

The issue is that the WallpaperService.Engine is a class enclosed within WallpaperService class (it is obvious once you see it), and is not static, and thus must be tied to a instance of a WallpaperService class, in other words, it must be declared as an inner class of a WallpaperService class:

import android.service.wallpaper.WallpaperService

class MyWallpaperService : WallpaperService() {

    ...

    inner class MyEngine : Engine() {

    }

}
like image 121
Aleksandar Stefanović Avatar answered Sep 15 '25 01:09

Aleksandar Stefanović