我的第 3 方应用程序可以让最终用户从我们的服务器下载更新的 APK,然后该应用程序将在下载完成后调用该 APK 上的安装包管理器。同样的方法适用于所有版本的 Android 操作系统,但现在它会在 Android 10 (api 29) 上崩溃。我还没有看到任何人有类似的问题,任何帮助将不胜感激!
这是我用来从我的应用程序中调用 APK 文件的内容:
Intent intent = new Intent(Intent.ACTION_VIEW);
final File apkFile = new File(Files.getApkFileName());
Log.v("dt.update", "Start update from " + apkFile.getAbsolutePath());
intent.setDataAndType(Uri.fromFile(apkFile), application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这是每次返回的堆栈跟踪,仅在 Android 10 / API29 上:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.MyAppHere, PID: 11107
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Download/updatedapp.apk typ=application/vnd.android.package-archive flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2051)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1709)
at android.app.Activity.startActivityForResult(Activity.java:5192)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5150)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:5521)
at …Run Code Online (Sandbox Code Playgroud) I'm not sure what happened, everything used to build just fine with our pipeline in Azure Devops.
But just recently, we have every build failing at zipaligning ... the APK zipaligns and builds just fine when using the Android Studio IDE, but it fails in Azure Devops pipeline.
Here is the start of the zipalign from Azure:
Starting: AndroidSigning
==============================================================================
Task : Android signing
Description : Sign and align Android APK files
Version : 3.176.0
Author : Microsoft Corporation
Help …Run Code Online (Sandbox Code Playgroud)