[英]Android Studio Wear Os application can't be installed INSTALL_PARSE_FAILED_NO_CERTIFICATES
我是 Android Studio 魔法世界的新手。 我正在嘗試開發一個簡單的 Wear Os 應用程序來掃描附近的藍牙設備。
MainActivity.java
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));
}
}
};
}
AndroidManifest.xml
<?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>
當我嘗試在我的 Fossil SmartWatch 中調試將 APK 上傳到設備的應用程序時,我收到以下錯誤:
Launching 'app' on Physical Device.
Timed out waiting for process (com.firstapp.testble) to appear on fossil-garrett_hr-127.0.0.1:4444.
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_NO_CERTIFICATES
List of apks:
[0] 'C:\Users\marac\AndroidStudioProjects\TestBLE\app\build\outputs\apk\debug\app-debug.apk'
APK signature verification failed.
對於其他簡單的應用程序,我沒有這種問題。 這是我已經嘗試過的:
我不明白為什么我有這個問題,為什么我只在這個項目中遇到這個問題。 你能幫我解決嗎?
謝謝,瑪拉
如果您已經簽署了您的 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
文件夾下找到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.