我正在玩AOSP,并尝试应用OTA包
1).我为 Google Pixel 构建了 AOSP 并安装了它
2).我创建了简单的应用程序,它下载 OTA 包,并尝试应用它 (基于这篇文章:http://jhshi.me/2013/12/13/how-to-apply-downloaded-ota-package/index.html)
我正在打电话
RecoverySystem.installPackage(getContext(), file);
,它让我满意
java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.os.IRecoverySystem.setupBcb(java.lang.String)' on a null object reference
at android.os.RecoverySystem.setupBcb(RecoverySystem.java:895)
at android.os.RecoverySystem.installPackage(RecoverySystem.java:496)
at android.os.RecoverySystem.installPackage(RecoverySystem.java:421)
谁能告诉我如何解决这个问题吗?
最佳答案
据我所知,您的错误来自这段代码:
在 RecoverySystem.java 中:
RecoverySystem rs = (RecoverySystem) context.getSystemService(
Context.RECOVERY_SERVICE);
if (!rs.setupBcb(command)) {
throw new IOException("Setup BCB failed");
}
...
/**
* Talks to RecoverySystemService via Binder to set up the BCB.
*/
private boolean setupBcb(String command) {
try {
return mService.setupBcb(command);
} catch (RemoteException unused) {
}
return false;
}
在第一段代码中,if 评估,您的错误是 rs
的 mService
成员为 null
。这是在 ''setupBcb` 方法中使用的。
因此,您正在使用的上下文似乎无法以某种方式访问 Context.RECOVERY_SERVICE。
您是否使用 Activity 上下文?我会尝试一下 git Application Context。
关于android - RecoverySystem.installPackage java.lang.NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45212737/