Android错误:软件包android.os不存在 [英] Android error: package android.os does not exist
问题描述
我已使用Gradle将项目导入Android Studio.导入过程成功,但是在尝试导入android.os.*
时出现错误.
这是一个libGDX项目.
I have imported a project to Android Studio using Gradle. Import process was successful, but it gives an error for android.os.*
, when I try to import it.
It is a libGDX project.
推荐答案
最近,我在Android Studio 3.2.1 Ubuntu/Linux版本中遇到了类似情况.
Recently, I met a similar case in Android Studio 3.2.1 Ubuntu/Linux version.
我非常确定该问题与Android SDK的安装有关,因为我在Windows 10笔记本电脑的Android Studio中构建了相同的项目.
I am quite sure about the issue shall be related to the Android SDK installation,because I build the same project in Android Studio of my Windows 10 laptop.
问题: Android Studio中的Java编译器错误
Issue: Java compiler error at Android studio
error: package android.os does not exist
error: package android.media does not exist
error: package android.content does not exist
error: package android.util does not exist
error: cannot find symbol variable Log
error: cannot find symbol class Context
error: cannot find symbol class AudioRecord
解决方案: 在build.gradle文件中提到的android.jar未安装在/sdk/platforms/目录中.请参阅下面我的build.gradle文件中的android.jar依赖项(这引起了问题),
Solution: The android.jar which was mentioned at the build.gradle file was not installed at the /sdk/platforms/ directory. See the android.jar dependency at my build.gradle file below(which caused the issue),
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files(sdkDir+'/platforms/android-24/android.jar')
}
安装正确的android平台(如果有build.gradle文件,请参阅正确的API级别)并重建项目.
Install the correct android platform(correct API level as mentioned in the build.gradle file,if any) and rebuild the project.
这篇关于Android错误:软件包android.os不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!