私は、Android プロジェクトをライブラリ プロジェクト + いくつかの依存プロジェクトに分割する過程にあり、この問題に遭遇しました。
Service
ライブラリ プロジェクトには、次のように定義された Android があります。
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
コンパイルするには何を変更する必要がありますか?