1

When using UsageStatsManager or UsageStats in Android Studio, it says

Cannot resolve symbol 'UsageStatsManager' / 'UsageStats'

I have downloaded SDK Platform, Intel x86 Atom_64 System Image, Google APIs and Sources for Android SDK under Android 5.0.1 (API 21) from Android SDK.

Abhishek
  • 2,959
  • 2
  • 17
  • 24

1 Answers1

0

Set your buildSdkVersion to 21 or higher in your build.gradle file. UsageStatsManager was added in API Level 21; you need to be compiling against API Level 21 to reference that class.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Actually I have imported my project to Android Studio from Eclipse and forgot to change it to a Gradle project. So, it doesn't have a `build.gradle` file. However setting `targetSdkVersion` in `AndroidManifest.xml` to 21 doesn't help. What can be done on this? – Abhishek Dec 21 '14 at 16:39
  • @CommonsWare Is there any method to get app statistics in previous apis? – Sreekanth Karumanaghat Oct 05 '16 at 18:53