سؤال

I have an Android project that depends on a non-Android JAR that contains resources (Java resources, not Android resources), which classes within the JAR need to load. When running the application, these resources are not found (i.e., ClassLoader.getResourceAsStream() fails), apparently because the resources are not being included in the APK.

I found some discussion here: http://code.google.com/p/android/issues/detail?id=10076#c7

But I need to build the APK in Eclipse. Short of doing a command-line build with a deprecated tool (ugh), or duplicating all the resources (ugh), how can I make it work?

هل كانت مفيدة؟

المحلول

Create your jar file with the classes you need and save it your computer. Then in the project explorer right click the project and go to properties -> Java Build Path -> Libraries. Now import the jar file.

You should now have full access to the classes and methods in your code and the jar file will be installed with your APK. My guess is you have utility classes and when you are calling them in your source Eclipse is importing them from another project.

The solution I have given works for sure (I do it myself).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top