【问题标题】:Android Studio The application could not be installed: INSTALL_FAILED_VERIFICATION_FAILUREAndroid Studio 无法安装应用程序:INSTALL_FAILED_VERIFICATION_FAILURE
【发布时间】:2020-04-30 19:51:47
【问题描述】:

如果我尝试在 Android Studio + Andy 模拟器中运行 Android 项目,有人可以帮助我理解这个错误吗?错误提示 无法安装应用程序:INSTALL_FAILED_VERIFICATION_FAILURE。它带有一个微调器小部件的简单应用程序。 这是我的 MainActivity 文件

package camo.learn2codeproject3;


import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.ArrayList;


public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener
{

    Spinner spinner;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        spinner = findViewById(R.id.spinner1);

        ArrayList<String> spinnerItems = new ArrayList<>();  // Empty <> == <String>
        spinnerItems.add("bicykel");
        spinnerItems.add("auto");
        spinnerItems.add("lod");
        spinnerItems.add("padak");
        spinnerItems.add("vlak");

        ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerItems );

        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        spinner.setAdapter(adapter);
        spinner.getOnItemSelectedListener();
    }

    @Override
    public void onItemSelected(AdapterView<?> adapter, View view, int position, long id)
    {
        String item = adapter.getItemAtPosition(position).toString();
        Toast.makeText( this, "Vybrali ste: " + item, Toast.LENGTH_LONG ).show();
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent)
    {
        Toast.makeText( this, "Hey nič ste nevybrali!!!", Toast.LENGTH_LONG ).show();
    }
}

这里是activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</LinearLayout>

这是错误日志

2020-04-30 21:42:01.428 4266-4266/? E/studio.deploy: Could not get package user id: run-as: Package 'camo.learn2codeproject3' is unknown
2020-04-30 21:42:01.652 4266-4266/? E/studio.deploy: Could not find apks for package: camo.learn2codeproject3
2020-04-30 21:42:03.294 3373-3373/com.android.vending I/Finsky: [1] abjv.a(7): Verification requested, id = 2
2020-04-30 21:42:03.432 3373-4253/com.android.vending I/Finsky: [212] abli.a(9): Single user settings service is not running, bind it now
2020-04-30 21:42:03.458 3373-3373/com.android.vending I/Finsky: [1] ablh.onServiceConnected(1): Single user settings service is connected
2020-04-30 21:42:03.495 3373-4253/com.android.vending W/Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
2020-04-30 21:42:03.646 4262-4262/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
2020-04-30 21:42:03.656 4262-4262/? D/AndroidRuntime: CheckJNI is OFF
2020-04-30 21:42:03.810 4262-4262/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
2020-04-30 21:42:03.841 4262-4262/? W/art: Unexpected CPU variant for X86 using defaults: x86
2020-04-30 21:42:03.841 3373-4253/com.android.vending I/Finsky: [212] lew.a(9): Task 7 requested foreground
2020-04-30 21:42:03.847 3373-4253/com.android.vending I/Finsky: [212] lew.a(22): Not entering foreground
2020-04-30 21:42:03.912 4262-4262/? E/memtrack: Couldn't load memtrack module (No such file or directory)
2020-04-30 21:42:03.913 4262-4262/? E/android.os.Debug: failed to load memtrack module: -2
2020-04-30 21:42:03.914 4262-4262/? I/Radio-JNI: register_android_hardware_Radio DONE
2020-04-30 21:42:03.945 4262-4262/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
2020-04-30 21:42:03.947 4262-4262/? D/AndroidRuntime: Shutting down VM
2020-04-30 21:42:03.970 4262-4293/? W/art: Thread attaching while runtime is shutting down: Binder:4262_1
2020-04-30 21:42:03.970 4262-4293/? I/AndroidRuntime: NOTE: attach of thread 'Binder:4262_1' failed
2020-04-30 21:42:04.086 3373-4171/com.android.vending I/Finsky: [207] abrq.b(3): Verify: Verification package=camo.learn2codeproject3, id=2 response=3
2020-04-30 21:42:04.096 3373-4253/com.android.vending I/Finsky: [212] abst.c(15): Verifying id=2, result=-1
2020-04-30 21:42:04.117 3373-4253/com.android.vending I/Finsky: [212] abre.a(8): Verify: Installation silently blocked. package=camo.learn2codeproject3
2020-04-30 21:42:04.161 3373-3373/com.android.vending I/Finsky: [1] abst.hp(6): Verification complete: id=2, package_name=camo.learn2codeproject3
2020-04-30 21:42:04.201 3373-3373/com.android.vending I/Finsky: [1] abnu.hp(2): Reported verification result: REJECT
2020-04-30 21:42:04.203 3373-3373/com.android.vending I/Finsky: [1] acmh.b(3): Verification stage already finished, ignoring sub-task callback
2020-04-30 21:42:04.213 3373-3373/com.android.vending I/Finsky: [1] acmh.b(3): Verification stage already finished, ignoring sub-task callback
2020-04-30 21:42:04.273 3373-3375/com.android.vending I/art: Do partial code cache collection, code=124KB, data=104KB
2020-04-30 21:42:04.281 3373-3375/com.android.vending I/art: After code cache collection, code=122KB, data=103KB
2020-04-30 21:42:04.281 3373-3375/com.android.vending I/art: Increasing code cache capacity to 512KB
2020-04-30 21:42:04.342 1616-1616/? I/audioserver: type=1400 audit(0.0:352): avc: denied { read } for scontext=u:r:audioserver:s0 tcontext=u:object_r:unlabeled:s0 tclass=socket permissive=1
2020-04-30 21:42:04.342 1616-1616/? I/audioserver: type=1400 audit(0.0:353): avc: denied { write } for scontext=u:r:audioserver:s0 tcontext=u:object_r:unlabeled:s0 tclass=socket permissive=1
2020-04-30 21:42:04.502 1993-1993/? I/logzmq: type=1400 audit(0.0:354): avc: denied { write } for scontext=u:r:goldfish_setup:s0 tcontext=u:object_r:unlabeled:s0 tclass=socket permissive=1
2020-04-30 21:42:05.251 3373-3470/com.android.vending I/Finsky: [148] ruz.d(9): Invalidating cached PackageState for web.php5.sk
2020-04-30 21:42:05.263 3373-3470/com.android.vending I/Finsky: [148] ruz.d(9): Invalidating cached PackageState for web.php5.learn2codeproject2
2020-04-30 21:42:26.865 2196-2860/system_process I/Sensors: setActive() with handle = 0, enabled = 1
2020-04-30 21:42:26.865 2196-2860/system_process I/Sensors: setDelay() with handle = 0, delay = 20000 us
2020-04-30 21:42:27.101 2196-2253/system_process W/WifiMode: AndroidWifi, Invalid SupportedRates!!!
2020-04-30 21:42:27.102 2196-2251/system_process W/WifiMode: AndroidWifi, Invalid SupportedRates!!!
2020-04-30 21:42:27.102 2196-2251/system_process W/WifiMode: AndroidWifi, Invalid SupportedRates!!!
2020-04-30 21:42:28.371 2196-2208/system_process I/Sensors: setActive() with handle = 0, enabled = 0

正如我所见,应用程序不仅仅在 Andy 模拟器中工作。在我的手机中,它运行良好。 我有点迷失其中。谢谢。

【问题讨论】:

  • 我没有使用过 Andy 模拟器,但查看错误消息看起来像是与 apk 签名有关的内容。您是否尝试安装签名的 apk(如果可能在 Andy 模拟器上)?
  • 看起来签名验证失败。您可以转到 Andy 模拟器并关闭签名验证(在设置中,可以是“验证通过 UDB 安装的应用程序”)或在 Android Studio 中对应用程序进行签名,然后再安装到 Andy 上。
  • 您介意发布您的(应用程序模块)build.gradle

标签: android android-studio


【解决方案1】:

从开发者设置中禁用Verify Apps over USB 对我有用:

Settings > Developer Options > Then Turn off Verify Apps over USB

您可能需要开启未知来源的安装:

Settings > Security > Then Turn on Unknown sources

注意,如果该选项不可用,您也可以运行adb 命令:

adb shell settings put global package_verifier_enable 0

【讨论】:

  • 我不明白。今天它没有任何变化。但是你的回答有一些有趣的暗示,所以我接受了。
【解决方案2】:

您可以尝试以下几项检查:

  1. 确保您的模拟器上有足够的空间(从其他项目中删除您已安装的所有应用)
  2. 确保您没有安装具有不同签名证书的应用程序版本(例如,安装了应用程序的调试版本并且您尝试在其上安装应用程序的发布变体,反之亦然)
  3. 在 Android Studio 终端中,输入:adb shell > 输入:settings put global verifier_verify_adb_installs 0(禁用 Google Play Services 验证应用选项)

在 andorid 模拟器中测试我的应用程序时,大多数时候我都会遇到问题 no#1 或 no#2

【讨论】:

    【解决方案3】:

    这对我有用。我在 Manifest 中有一个带有 android:exported="false" 的 Launcher 活动,然后我将其更改为 android:exported="true"

    【讨论】:

      猜你喜欢
      • 2017-07-31
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 1970-01-01
      • 2017-06-25
      • 2016-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多