As part of testing an existing Android app against the L preview, the app is crashing with the following exception:
07-08 10:05:39.024: E/AndroidRuntime(2126): FATAL EXCEPTION: main
07-08 10:05:39.024: E/AndroidRuntime(2126): Process: com.example, PID: 2126
07-08 10:05:39.024: E/AndroidRuntime(2126): java.lang.LinkageError: com.example.BaseActivity
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClassNative(Native Method)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.defineClass(DexFile.java:222)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
07-08 10:05:39.024: E/AndroidRuntime(2126): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
The app works fine in API levels 14-19, but crashes on start up with this cryptic error on the L preview. The compile/targetSdk version is still set to API 19.
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.
LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class. It is caused by a conflict between the original classloader from the JVM and the classloader deployed by the plugin framework.
throw new RuntimeException("This is a crash"); Make sure to remove the line after testing is done. Another way to crash an Android app is to make a DivideByZero exception. In the onCreate method of your activity, simply write an expression with a number being divided by 0.
The problem was a conflicting method in BaseActivity
. I had created a helper method called getDrawable(int drawableId)
that had the same signature as a method added to the Activity
class in Android L.
This conflict caused the LinkageError
. To fix the issue, I simply renamed my helper method so it wouldn't conflict with the new built-in method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With