package com.jongla.soundmash.robolectric
import org.robolectric.shadows.ShadowApplicationPackageManager
import org.robolectric.annotation.Implements
import android.app.ApplicationPackageManager
@Implements(value = ApplicationPackageManager.class, inheritImplementationMethods = true)
class MyCustomPackageManager extends ShadowApplicationPackageManager {
}
AndroidStudio正在给我Unresolved reference: ApplicationPackageManager
。有谁知道我需要做什么才能让这个例子编译?我是否需要在gradle中添加一些额外的testCompile
包?
答案 0 :(得分:0)
在浏览Roboloectric源代码时,我发现了属性className
来指定类名。它就像魔术一样。
@Implements(className = "android.app.ApplicationPackageManager", inheritImplementationMethods = true)
public class MyCustomPackageManager extends ShadowApplicationPackageManager {
}
当建议将值用作ApplicationPackageManager
类是私有的并且对于用户代码不可见时,迁移文档显然是不正确的。