Android Activity ClassNotFoundException - tried everything

前端 未结 15 2275
有刺的猬
有刺的猬 2020-11-22 12:02

I\'ve just refactored an app into a framework library and an application, but now when I try and start the app in the emulator I get the following error stack trace:

15条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 12:48

    I've just refactored an app into a framework library and an application.

    I'm not entirely sure what you are trying to say here, but the fact that you used the word "refactored" here leads me to believe that you are misunderstanding the concept of a library project.


    What library projects are:

    A library project is a development project that contains shared source code and resources. Other Android projects can reference the library project and include its compiled sources in their .apk files at compile time.

    What library projects are not:

    A library project differs from a standard Android project in that you cannot compile it directly to a single .apk file and run it on an Android device. You can't use an Android projects as a library project, and then have another Android project extend the library project. It doesn't work that way.


    That said, I would investigate the structure of your library project and insure that you've set it up correctly. It's OK to use your library to store shared code/resources, but if your library is attempting to behave as if it were a separate .apk within the library project itself, then you've probably done something wrong. I believe a ClassNotFoundException would be thrown if this were the case. To fix the problem, I'd just build the library project from scratch, rather than attempting to convert the Android project to a library project. That'll prevent you from running into tiny, annoying bugs.

    Feel free to post more code if you are still having trouble. You should also elaborate a bit more on the structure (and purpose) of your library project... why you decided to use one, how you created it, etc.

提交回复
热议问题