该问题通常是由于智能手机设备列表中缺少您的设备造成的,解决方法如下:
查看您的设备是否在设备列表中 打开Android Studio,单击“File”菜单,然后点击“Project Structure”。然后在“SDK Platforms”选项卡下,查看“Android API”列表,并确保您的设备所需的API已被安装。如果您的设备所需的API未被安装,选择它并单击“Apply”按钮。
添加您的设备到设备列表 在SDK Manager中,单击“SDK Tools”选项卡,然后找到“Android SDK Build-Tools”并选择最新版本。该版本应该包含您的设备信息。然后,重新加载Android Studio,然后检查设备列表,以确保您的设备是包含在内的。
修改build.gradle文件 打开build.gradle文件,并添加以下代码:
android {
compileSdkVersion
defaultConfig {
......
minSdkVersion
targetSdkVersion
// Add the following code, replacing "yourDeviceName" with
// the name of your device.
flavorDimensions "yourDeviceName"
productFlavors {
yourDeviceName {
dimension "yourDeviceName"
// Add your device here. Replace "manufacturer" and
// "model" with appropriate values.
// Be sure to use a valid ID.
// Check the Android Developers website for more information.
// https://developer.android.com/reference/android/R.xml#config_hardware_profiles
resValue "string", "build_device_manufacturer", "manufacturer"
resValue "string", "build_device_model", "model"
resValue "integer", "build_device_type",
}
}
}
}
再次构建您的程序 针对更改后的build.gradle文件