gpt4 book ai didi

android - 如何修复 Android Studio 中的 INSTALL_FAILED_INVALID_APK 错误?

转载 作者:行者123 更新时间:2023-12-02 02:39:17 28 4
gpt4 key购买 nike

我最近将我的 Android Studio 更新到 3.6.1,因此也将 gradle 插件更新到 3.6.1,并将 gradle 包装器更新到 5.6.4

运行调试版本时,我不断收到此错误

Install failed: The application could not be installed: 
INSTALL_FAILED_INVALID_APK
The APKs are invalid.
  • 我检查了我的包和 applicationId,它是相同的
  • 我尝试使用 android:extractNativeLibs="true"在 list 上 <application>标签,它仍然不起作用
  • 继续清理和重建仍然不起作用
  • 无效的缓存,删除了 .gradle,idea 和 build 文件,它仍然无法工作
  • 我也在 gradle.properties 文件 org.gradle.caching=false 上使用了它但仍然无法正常工作
    我检查了idea.log 文件,它是这样说的:
  • 2020-03-22 00:49:04,191 [4654427]   INFO - ild.invoker.GradleBuildInvoker - Gradle build finished in 1 m 37 s 411 ms 
    2020-03-22 00:49:04,213 [4654449] INFO - ools.idea.run.tasks.DeployTask - Installing application: PACKAGE_NAME
    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675813ms TRC_BEG [12861][12861] : installer
    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675814ms TRC_BEG [12861][12861] : Command Dump
    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675814ms TRC_BEG [12861][12861] : get process ids
    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675872ms LOG_ERR [12861][12861] : Could not get package user id: /system/bin/run-as: unknown package: PACKAGE_NAME

    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_END [12861][12861] :
    2020-03-22 00:49:04,451 [4654687] INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_BEG [12861][12861] : retrieve_apk_path
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675874ms TRC_BEG [12861][12861] : apk_path_via_cmd_package_dump
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675923ms LOG_ERR [12861][12861] : Could not find apks for package: PACKAGE_NAME
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - 20675923ms TRC_END [12861][12861] :
    2020-03-22 00:49:04,452 [4654688] INFO - a.run.tasks.AbstractDeployTask - DUMP_UNKNOWN_PACKAGE
    2020-03-22 00:49:04,967 [4655203] INFO - #com.android.ddmlib - Created install session 969164047 with options -r -t -S 14667707
    2020-03-22 00:49:04,967 [4655203] INFO - #com.android.ddmlib - Uploading APK C:\Projects\PROJECT_FOLDER\source\PROJECT_NAME\app\build\outputs\apk\debug\app-debug.apk to session 969164047
    2020-03-22 00:49:08,055 [4658291] INFO - WindowsPerformanceHintsChecker - Windows Defender status: NONE_EXCLUDED; projectDirExcluded? false
    2020-03-22 00:49:17,686 [4667922] WARN - #com.android.ddmlib - Failed to commit install session 969164047 with command cmd package install-commit 969164047. Error: INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/PACKAGE_NAME -d9UfJVvKMP9-OA81TwCVvQ==: Package /data/app/PACKAGE_NAME -d9UfJVvKMP9-OA81TwCVvQ==/base.apk code is missing
    2020-03-22 00:49:17,687 [4667923] WARN - a.run.tasks.AbstractDeployTask - Install failed: The application could not be installed: INSTALL_FAILED_INVALID_APK The APKs are invalid.
    2020-03-22 00:49:17,689 [4667925] INFO - run.AndroidLogcatOutputCapture - stopAll()
    2020-03-22 00:49:21,408 [4671644] INFO - rationStore.ComponentStoreImpl - Saving appEditorColorsManagerImpl took 12 ms

    *注意我用 PACKAGE_NAME 和项目名称替换了我的包名

    我已经没有选择了。最坏的情况是我将降级 gradle 和 gradle wraper 甚至 Android Studio,我故意讨厌它,因为它是一个倒退

    最佳答案

    另一种解决方案是删除 ../android/app/build/outputs/apk/debug/app-debug.apk 文件,然后运行“npm run android”/“yarn android”

    关于android - 如何修复 Android Studio 中的 INSTALL_FAILED_INVALID_APK 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60790653/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com