Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio E/dalvikvm: Could not find class... referenced from method

Tags:

java

android

I encountered a problem that seems to have something to do with the libraries in android studio.
I am having compiling errors like:

Could not find class 'android.os.PersistableBundle referenced from method com.example.jack.test1.MainActivity.access$super', Could not find class 'android.app.SharedElementCallback referenced from method com.example.jack.test1.MainActivity.access$super', Could not find class 'android.app.ActivityManager$TaskDescription.

The app still runs normally but when it comes to running a certain button event, it stops working. My friend has the same exact code as I do but in my case it doesn't work. I have tried upgrading to a latest API level and tried different gradle plugin version but the problem persisted. Thanks

running android studio 2.0
gradle version 2.10
min sdk 4.0

like image 548
Jack Smith Avatar asked Apr 23 '16 21:04

Jack Smith


1 Answers

I got this error in Android Studio v2.0 while building an empty child of AppCompatActivity from the (v7-appcompat) Support Library. Seems like the problem occurred when the Build Tools (Gradle v2.1.0, Android plugin v2.10) were upgraded after the corresponding support library upgrade (v23.3.0).

My solution:

  • Remove the support-library dependency reference from my module-level build.gradle file(s)
  • Clean the Project
  • Restart Android Studio (possibly optional)
  • Add the support-library back via Project Structure > Dependencies

Seems to be working so far, although in future it would be nice to be able to specify an upgrade-order, or set up some kind of happens-before hierarchy for libraries/settings that are dependent on Build Tools.

like image 178
MandisaW Avatar answered Oct 17 '22 01:10

MandisaW