android - VerifyPerSourceInstallationConsentInstallTask.f(2):包名 null 不是已安装的包
问题描述
在 android 6.0 中,我想有意安装 apk。在 logcat中说PackageInstaller
gotto be installed app
和.
但我有一个错误,。
我要求阅读许可,仍然没有警告。package name
callerPackageName
VerifyPerSourceInstallationConsentInstallTask.f(2): Package name null is not an installed package
这是我的代码:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.button);
textView = findViewById(R.id.txt);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
installApp(this);
}
public static void installApp(Activity context) {
String filePath = Environment.getExternalStorageDirectory() + "/app.apk";
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);//add read and write permissions
}
intent.setDataAndType(GetPathUri(context, filePath), "application/vnd.android.package-archive");
context.startActivity(intent);
}
public static android.net.Uri GetPathUri(Context context, String filePath) {
android.net.Uri uri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
String packageName = context.getPackageName();
uri = FileProvider.getUriForFile(context, packageName + ".fileProvider", new File(filePath));
} else {
uri = android.net.Uri.fromFile(new File(filePath));
}
return uri;
}
}
这是logcat:
06-11 17:14:56.063 3461-4204/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10446 on display 0
06-11 17:14:56.128 2820-2820/? I/PackageInstaller: GraPermsActivity:callingPackageName:com.example.myapplication,mRequestedPermissions:android.permission.READ_EXTERNAL_STORAGEandroid.permission.REQUEST_INSTALL_PACKAGES
06-11 17:14:56.274 3461-3484/? I/ActivityManager: Displayed com.android.packageinstaller/.permission.ui.GrantPermissionsActivity: +195ms
06-11 17:15:04.803 2820-2820/? I/PackageInstaller: GraPermsActivity:sendbroadcast pkg:com.example.myapplication,groupname:android.permission-group.STORAGE,granted:true,doNotAskAgain:false
06-11 17:15:04.881 3461-4247/? I/ActivityManager: START u0 {act=android.intent.action.VIEW dat=file:///storage/emulated/0/app.apk typ=application/vnd.android.package-archive flg=0x10008000 cmp=com.android.packageinstaller/.PackageInstallerActivity (has extras)} from uid 10446 on display 0
06-11 17:15:04.987 2820-2820/? I/PackageInstaller: HandleAdbInstallFlow:confirmAdbInstall installflags:64
06-11 17:15:05.041 2820-2820/? I/PackageInstaller: PackageInstaller:The to be installed apk's packageName = com.example.myapplication
06-11 17:15:05.066 2820-2820/? I/PackageInstaller: PackageInstaller:callerPackageName = com.example.myapplication
06-11 17:15:05.099 3461-3784/? V/HwPhoneWindowManager: updateSystemUiColorLw window=Window{65d2e01 u0 com.android.packageinstaller/com.android.packageinstaller.PackageInstallerActivity},EmuiStyle=1,StatusBarColor=0xff28c0c6,NavigationBarColor=0x0
06-11 17:15:05.100 2820-2820/? V/ActivityThread: Resuming ActivityRecord{810d7b8 token=android.os.BinderProxy@c318115 {com.android.packageinstaller/com.android.packageinstaller.PackageInstallerActivity}} with isForward=true,forwardBitChanged=false
06-11 17:15:05.163 3461-3484/? I/ActivityManager: Displayed com.android.packageinstaller/.PackageInstallerActivity: +195ms
06-11 17:15:05.275 2820-4149/? I/PackageInstaller: AppRiskLocalCheck:checkLocalBlackList
06-11 17:15:05.376 2820-4148/? I/PackageInstaller: HTTPUtil:responseCode =200
06-11 17:15:05.379 2820-2820/? I/PackageInstaller: CheckAppRiskTask:risk check result:11,tipText:Inconsistent signatures. This app may have been tampered with.
06-11 17:15:05.379 2820-2820/? I/PackageInstaller: CheckAppRiskTask:syncBlackList localVersion:20150326105712
06-11 17:15:05.474 2820-4147/? I/PackageInstaller: CheckAppRiskTask:online check result
06-11 17:15:05.512 2820-2885/? I/PackageInstaller: HTTPUtil:responseCode =200
06-11 17:15:14.007 3461-3472/? I/ActivityManager: START u0 {dat=file:///storage/emulated/0/app.apk cmp=com.android.packageinstaller/.InstallAppProgress (has extras)} from uid 10066 on display 0
06-11 17:15:14.022 3461-4204/? W/ActivityManager: Duplicate finish request for ActivityRecord{c5c41f6 u0 com.android.packageinstaller/.PackageInstallerActivity t1367 f}
06-11 17:15:14.069 3461-4259/? W/ActivityManager: getRunningAppProcesses: caller 10066 does not hold REAL_GET_TASKS; limiting output
06-11 17:15:14.110 3461-3490/? I/ActivityManager: Start proc 4169:com.android.defcontainer/u0a2 for service com.android.defcontainer/.DefaultContainerService
06-11 17:15:14.115 3861-3861/? W/HwSystemManager: HandleInstalledPackageInfoService:this is PackageInstaller branch, so return directly
06-11 17:15:14.178 3461-4259/? D/ActivityManager: ActivityManagerService,attachApplication,callingPid = 4169
06-11 17:15:14.179 3461-4259/? V/ActivityManager: New app record ProcessRecord{68d88a 4169:com.android.defcontainer/u0a2} thread=android.os.BinderProxy@35a6efb pid=4169
06-11 17:15:14.211 3461-3484/? I/ActivityManager: Displayed com.android.packageinstaller/.InstallAppProgress: +186ms
06-11 17:15:14.256 31580-31580/? E/Finsky: [1] VerifyPerSourceInstallationConsentInstallTask.f(2): Package name null is not an installed package
06-11 17:15:14.258 31580-31580/? W/Finsky: [1] VerifyInstallTask.l(37): The installer's package name is missing
06-11 17:15:14.262 31580-2923/? I/Finsky: [27138] VerifyAppsInstallTask.gu(2): Skipping verification because disabled
06-11 17:15:14.262 31580-2923/? I/Finsky: [27138] VerifyAppsInstallTask.gu(23): Verify: Skipping anti malware verification due to pre-check failure. package=com.example.myapplication
06-11 17:15:14.264 31580-2923/? I/Finsky: [27138] VerifyInstallTask.i(4): Cannot read file for file:///storage/emulated/0/app.apk in request id=82
06-11 17:15:14.264 31580-2923/? I/Finsky: [27138] VerifyMissingSplitsInstallTask.gu(7): Could not tell if Splits is installed due to null packageInfo for id=82. Assuming not.
06-11 17:15:14.264 31580-2923/? I/Finsky: [27138] VerifyMissingSplitsInstallTask.d(1): Assuming split not required due to null packageInfo for id=82
06-11 17:15:14.266 31580-2923/? I/Finsky: [27138] VerifyPerSourceInstallationConsentInstallTask.gu(2): PSIC verification started with installer uid: 10066 package name: com.android.packageinstaller, originating uid: 10446
06-11 17:15:14.271 31580-2923/? I/Finsky: [27138] VerifyPerSourceInstallationConsentInstallTask.gu(8): Skipping logging for attempted installation. Pre-O device.
06-11 17:15:14.276 31580-2923/? I/Finsky: [27138] VerifyPerSourceInstallationConsentInstallTask.gu(24): Package source uid 10446 requires user's source trust
06-11 17:15:14.303 3461-3806/? I/ActivityManager: START u0 {flg=0x58000000 cmp=com.android.vending/abkp (has extras)} from uid 10058 on display 0
06-11 17:15:14.306 31580-2923/? E/Finsky: [27138] VerifyInstallTask.gu(5): Unexpected exception on background thread
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.vending/abkp}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.ContextImpl.startActivity(ContextImpl.java:762)
at android.app.ContextImpl.startActivity(ContextImpl.java:737)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
at abkp.m(PG:1)
at com.google.android.finsky.verifier.impl.VerifyPerSourceInstallationConsentInstallTask.gu(PG:29)
at com.google.android.finsky.verifier.impl.VerifyInstallTask.gu(PG:4)
at acmr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at aavp.run(Unknown Source)
at java.lang.Thread.run(Thread.java:833)
06-11 17:15:14.307 31580-31580/? I/Finsky: [1] VerifyInstallTask.g(3): Verifying id=82, result=-1
06-11 17:15:14.310 31580-31580/? I/Finsky: [1] VerifyInstallTask.gs(6): Verification complete: id=82, package_name=com.example.myapplication
06-11 17:15:14.511 2820-2843/? I/PackageInstaller: InstallAppProgress:installobserver:null,-22
解决方案
推荐阅读
- pytest - pytest.approx 的 rel 参数背后的基本原理是什么?
- crud - 为什么按下提交按钮后所有数据都丢失了?
- git - 手动编辑 git add --patch 导致错误(补丁失败)
- python - 如何修剪列值而不将它们变成字符串?
- oracle - ORA-24247: 访问控制列表 (ACL) 拒绝网络访问 - 错误
- javascript - div 点击不像鼠标点击
- java - Android Studio Java:无法将图像从网络下载到应用程序中
- javascript - 如何将动态 url 链接到 jquery 中的标签?
- azure-cosmosdb - CosmoDB:由于目标机器主动拒绝,无法建立连接。[::1]:10255
- python - 空闲运行的任何python代码都可以访问所有已安装的ram吗?