无法安装Android Studio Wear Os应用程序INSTALL_PARSE_FAILED_NO_CERTIFICATES

问题描述

我在Android Studio的魔幻世界中是新手。我正在尝试开发一个简单的Wear Os应用程序,以扫描附近的蓝牙设备。

MainActivity.java

# ...
for id,group in groups:
    group.name = df.name

AndroidManifest.xml

package com.firstapp.testble;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.wearable.activity.WearableActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends WearableActivity {

    private ListView listView;
    private ArrayList<String> mDeviceList = new ArrayList<String>();
    private BluetoothAdapter mBluetoothAdapter;

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

        listView = (ListView) findViewById(R.id.listView);

        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if(mBluetoothAdapter == null){
            System.out.println(">>>>>>>>>>>>>>>>>>ERRORRE");
        }else{
            mBluetoothAdapter.startDiscovery();

            IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
            registerReceiver(mReceiver,filter);

            // Enables Always-on
            setAmbientEnabled();
        }
    }


    @Override
    protected void onDestroy() {
        unregisterReceiver(mReceiver);
        super.onDestroy();
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context,Intent intent) {
            String action = intent.getAction();
            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                BluetoothDevice device = intent
                        .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                mDeviceList.add(device.getName() + "\n" + device.getAddress());
                Log.i("BT",device.getName() + "\n" + device.getAddress());
                listView.setAdapter(new ArrayAdapter<String>(context,android.R.layout.simple_list_item_1,mDeviceList));
            }
        }
    };
}

当我尝试在Fossil SmartWatch中调试应用程序并将APK上传到设备时,出现以下错误:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.firstapp.testble">

    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature android:name="android.hardware.type.watch" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@android:style/Theme.DeviceDefault">
        <uses-library
            android:name="com.google.android.wearable"
            android:required="true" />

        <!--
               Set to true if your app is Standalone,that is,it does not require the handheld
               app to run.
        -->
        <meta-data
            android:name="com.google.android.wearable.standalone"
            android:value="true" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

在其他简单应用程序中,我没有这种问题。 这是我已经尝试过的:

  1. Build>生成单包/ APK
  2. 清理项目并重建项目
  3. 文件>使缓存无效/重新启动
  4. 断开并重新连接智能手表
  5. 重新安装Android Studio

我不明白为什么会有这个问题,为什么只有这个项目才有。你能帮我解决吗?

谢谢, 玛拉

解决方法

如果您已经对apk进行了签名,则可以考虑安装发行版本而不是要安装的调试版本。

从以下日志中,我可以看到您正在尝试安装调试版本。

[0] 'C:\Users\marac\AndroidStudioProjects\TestBLE\app\build\outputs\apk\debug\app-debug.apk'

发布apk可以在\Users\marac\AndroidStudioProjects\TestBLE\app\build\outputs\apk\release文件夹下找到。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...