1
我正在将Android项目拆分为库项目+几个相关项目,并且遇到了这个问题。Android库项目:调用内部类的方法
库项目有Android Service
定义是这样的:
public class UserService extends Service {
public class LocalBinder extends Binder {
UserService getService() {
return UserService.this;
}
}
...
}
依赖项目进行调用,以一个内部类的Service
这样的方法:
public ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
LocalBinder binder = (LocalBinder) service;
mService = binder.getService();
mBound = true;
}
...
};
该作品很好,当一切都在同一个项目中。但是在我将服务移动到库项目之后,它给出了编译时错误:
The method getService() from the type UserService.LocalBinder is not visible
我需要更改哪些内容才能编译它?
感谢您的快速回答。我试过了,但它仍然给出了同样的错误。 – gcl1 2013-03-09 12:50:44
我得到了原来的代码再次工作。我有另一个与库项目转换相关的问题,如下所述:http://stackoverflow.com/questions/8476912/menu-item-ids-in-an-android-library-project。当我解决这个问题时,这个错误消失了 - 不知道为什么/他们是如何相关的,但是无论如何感谢。 – gcl1 2013-03-09 15:35:49
感谢您的回答。 :) – 2015-10-09 10:19:13