NoClassDefFoundError for code in an Java library on Android

前端 未结 24 2016
梦如初夏
梦如初夏 2020-11-22 15:19

I am experiencing an error quite often among my users. The app crashes during startup. When the MainActivity is supposed to be loaded the VM apparently cannot find the class

24条回答
  •  梦谈多话
    2020-11-22 15:53

    In my case, I was trying to add a normal java class (from a normal java project) compiled with jre 1.7 to an android app project compiled with jre 1.7.

    The solution was to recompile that normal java class with jre 1.6 and add references to the android app project (compiled with jre 1.6 also) as usual (in tab order and export be sure to check the class, project, etc).

    The same process, when using an android library to reference external normal java classes.

    Don't know what's wrong with jre 1.7, when compiling normal java classes from a normal java project and try to reference them in android app or android library projects.

    If you don't use normal java classes (from a normal java project) you don't need to downgrade to jre 1.6.

提交回复
热议问题