简体   繁体   English

Android SDK版本错误-如何缩小尺寸?

[英]Android SDK version error- how to downsize(?)

I had two API version(21,27) in my SDK platform and my Virtual Device was also targeting API 21. The problem was MediaPlayer in my MainActivity was not working. 我的SDK平台中有两个API版本(21,27),我的虚拟设备也以API 21为目标。问题是MainActivity中的MediaPlayer无法正常工作。 I checked volume , it was obviously turned on but could here no sound. 我检查了音量,显然它已打开,但这里没有声音。 So i thought the higher API version(In my case, API 27) might be causing the problem so i uninstalled it. 因此,我认为较高的API版本(以我的情况为API 27)可能是导致此问题的原因,因此我将其卸载了。 and now every singe code has turned into red-which means error occured)as u can see. 现在每一个单一的代码都变成了红色-如您所见,这意味着发生了错误。 enter image description here 在此处输入图片说明

would you give insight of what is the cause and how to fix it? 您能否提供引起原因的原因以及如何解决的见解? Thanks you so much in advance. 提前非常感谢您。

download every api version and try 下载每个api版本并尝试

start with api 27 and keep coming down but you don't have to delete the sdk version 从api 27开始,继续下降,但是您不必删除sdk版本

You just need to click the "Sync Project with gradle file", available in AndroidStudio 您只需要单击AndroidStudio中提供的“与gradle文件同步项目” 在此处输入图片说明

This will also download necessary SDK version in case missing. 如果丢失,这还将下载必要的SDK版本。

Latest android studio version should use latest build tools and better to target with current popular version just like: 最新的android studio版本应使用最新的构建工具,并更好地针对当前流行的版本进行定位,例如:

your project build.gradle should set like that: 您的项目build.gradle应该设置为:

    compileSdkVersion 26
    buildToolsVersion "27.0.3"
 defaultConfig {
        minSdkVersion 21
        targetSdkVersion 27

set your min support sdk if the app support from SDK 21 to 27. Should install back the latest sdk 27 如果应用程序支持从SDK 21设置为27,则将您的最低支持SDK设置为27。应安装最新的SDK 27

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM