安装失败,原因是:'null' - Android Studio 3.5

新手上路,请多包涵

自从遇到 APK 安装问题以来,我已将 Android Studio 更新到 3.5。这是它显示的唯一日志:

 Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Installation failed due to: 'null'
Retry

尝试在真实设备上安装 APK 时会发生这种情况。如果我从设备上卸载应用程序然后重新运行构建,它只会安装一次,然后在下一次安装时不断抛出此错误。它在模拟器上运行良好,但我不能对所有东西都使用模拟器。

我试过的:

  • 删除了 Android Studio 配置文件。
  • 从项目中删除 Gradle 文件。
  • 无效并重置缓存。
  • 清理/重建项目。
  • 寻找类似的问题 Stackoverflow(没有符合我的问题)
  • 干净安装(删除了包括 SDK 在内的所有文件)Android Studio 3.5

更新

我在我的机器上安装了 Linux Mint 并在那里测试了 AS 3.5,出于某种原因,即使对于 Android 7 及更低版本的设备,一切都运行良好。

以前的操作系统:Windows 10 1903

当前操作系统:Linux Mint 19.2

我认为这个问题可能来自 Windows 机器。

原文由 Taseer 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.3k
2 个回答

打开 运行/调试配置 对话框(Windows: 运行 > 编辑配置

编辑 您的应用程序 > 常规 > 安装选项 > 安装标志

添加安装标志 -r -t

这个标志意味着 adb install -r -t apkpath

屏幕图片

原文由 Stackoverflow 发布,翻译遵循 CC BY-SA 4.0 许可协议

如果您的应用面向 Android 12 或更高版本,则必须在应用的清单文件中声明这些归因标签。如果应用组件包含 LAUNCHER 类别,请将 android:exported 设置为 true。

  <activity
    android:name="com.test.activity.SplashActivity"
    android:clearTaskOnLaunch="true"
    android:label="@string/app_name"
    android:launchMode="singleTop"
    android:noHistory="true"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar"
    android:exported="true">

还要检查 Androidmanifest 中的接收器或服务,如果您根据要求使用任何接收器或服务集 android:exported=“true” 或 false。

 <receiver
    android:name="com.test.receiver.ShareReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.test.fcm.android.action.broadcast" />
    </intent-filter>
</receiver>

 <service
    android:name="com.google.android.gms.tagmanager.InstallReferrerService"
    android:exported="true" />

还要更新你所有的 gradle 依赖。我已根据要求更新了以下依赖项。

 testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.razorpay:checkout:1.6.15'

希望它也能帮助你。

原文由 Kishan Thakkar 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题