I followed HMS developer guide for Device virtualization (DV) engine development here - https://developer.huawei.com/consumer/en/doc/development/connectivity-Guides/devicevirtualization-preparation, I integrated DV SDK into my app, compile and build all finished fine. But after deployed my DV app to my cell phone, the hardware device list won’t show up in the app GUI. What could be the reason for this?
2 Answers
Please check to see if you have already done the following:
- First of all, you need send Permission applications for the usage of DV Engine to : [email protected]
- Once your application is approved, make sure you also include all the required permissions and your app id as meta data in AndroidManifest.xml. Virtual device permission of DV Engine, which is mandatory for using the distributed virtual devices.
com.huawei.permission.DISTRIBUTED_VIRTUALDEVICE
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=xxxxxxxxx"/>
Make sure the DV SDK version in your code is same as the one in your cell phone. Below is a sample code to show how to check the DV version: CURRENT_KIT_VERSION is the HUAWEI DV Engine version that the app is compatible with. Your app needs to record the version, and check whether the DV Engine version on your mobile phone is the same as the DV Engine version that the app is compatible with.
boolean isSupport = true;
try {
// Obtain the running version of DV Kit.
String version = DvKit.getVersion();
if (version.compareTo(CURRENT_KIT_VERSION) < 0) { // The current DV Kit version does not meet the app running requirements. isSupport = false; }
} catch (NoClassDefFoundError e) {
// The current running environment does not support the DV Kit.
isSupport = false;
Log.e(TAG, "DvKit not exist", e);
}
if (isSupport) {
// The current DV Kit version meets the app running requirements. Intent intent = new Intent(MainActivity.this, DvKitDemoActivity.class); startActivity(intent);
}
1. Please check Device Compatibility:
Currently, DeviceVirtualization Engine supports only Huawei mobile phones. When an app invokes the APIs in DV Engine in an unsupported running environment, or on a Huawei phone running an unsupported EMUI version, the system throws NoClassDefFoundError. Therefore, apps should check compatibility between the running environment and DV Engine version. For details, see docs.
2. Check whether the callback method connect is called successfully:
If so, your configuration is correct;
If not, check whether you have the permission to access related APIs. For security purposes, you need to apply for permissions from Huawei to use open APIs of DeviceVirtualization Engine. As @Zinna put it, applying for API permissions requires the app ID generated after you created your app on AppGallery Connect, and that the fingerprint has been configured. For permission application, please send an email to [email protected], and specify the topic "DeviceVirtualization Engine permission application." For details, please see docs.
3. Network connection is required when you start your app for the first time.
Check whether the callback method startDiscovery is called successfully. If so, and device parameters are not empty, you can send data to the UI thread through threads. For details, please refer to the demo provided on the official website.