Android error: package android.os does not exist

こ雲淡風輕ζ 提交于 2019-12-12 11:17:21

问题


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.


回答1:


Recently, I met a similar case in Android Studio 3.2.1 Ubuntu/Linux version.

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.

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

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')
}

Install the correct android platform(correct API level as mentioned in the build.gradle file,if any) and rebuild the project.



来源:https://stackoverflow.com/questions/28307414/android-error-package-android-os-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!