NoClassDefFoundError occurs at runtime when I use mutliple Java packages in one Android project

I have done the following:

  • Create an Android working project (not a library or test project) in Eclipse. It has one package called X with XA activity
  • Create a new Java Y package as part of the above project with at least one YC class
  • Call YC from XA (i.e., call something in a new package from the original package that previously worked).
  • Create and run an Android project.

It builds fine, but throws a NoClassDefFoundError on the first line using YC, saying that it cannot find YC When I Refactor -> Move YC to package X (so now XC), the exception is not thrown at runtime anymore. What's wrong?

A vague hint: I read that similar problems can occur when the assembly and runtime paths stop synchronizing, but I have not yet found how to fix or fix the problem.

+3
source share
1 answer

In his AndroidManifest.xmlin determining your actions you need to install the fully qualified class name for the action, located in subpackages, or even in a different package.

The full class name will look like com.example.my.cool.app.Activity. Alternatively, when you work only with subpackages, you can install it like this: android:name=".app1.AnotherActivity"when your base package looks like com.example.my.cool.

+2
source

Source: https://habr.com/ru/post/1777132/


All Articles