Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error: package android.os does not exist

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.

like image 623
plaidshirt Avatar asked Feb 03 '15 19:02

plaidshirt


2 Answers

I suggest to use AGP Upgrade assistent. I often have probs upgrading gradle. This time with artic fox and java 11 it I got all those infamous android.* not found errors.

Then I discovered that neat AGP Upgrade assistent (in tools since Studio 4.2) - and it did what it should and everything is now using gradle 7 and compiles again.

About time such a tool was introduced - and I just saw about half a year too late ;)

like image 123
FrankKrumnow Avatar answered Nov 13 '22 22:11

FrankKrumnow


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.

like image 8
Rajesh P Avatar answered Nov 13 '22 23:11

Rajesh P