May 7, 2014

Compile Against A Stub .JAR When Using Android Studio

Problem:

You are trying to compile against a stub .jar when using Android Studio.  When you compile and run the .apk on your device, you get a RuntimeException telling you to move the .jar to your classpath.

Cause:

You have the .jar set to compile.

Solution:

In Android Studio 0.5.7, go to File -> Project Structure.

Select your module.

Go to the "Dependencies" tab.

Find your stub .jar.

Click the down chevron next to "Compile" and change it to "Provided."

Rebuild.