0

i created android lib jar and i place lib folder in my test application i start a activity which in jar file but i getting following error

10-22 00:14:59.349: E/AndroidRuntime(670): FATAL EXCEPTION: main
10-22 00:14:59.349: E/AndroidRuntime(670): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapplication/com.example.test.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/ic_launcher.png from xml type layout resource ID #0x7f020000
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.os.Looper.loop(Looper.java:130)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-22 00:14:59.349: E/AndroidRuntime(670):  at java.lang.reflect.Method.invokeNative(Native Method)
10-22 00:14:59.349: E/AndroidRuntime(670):  at java.lang.reflect.Method.invoke(Method.java:507)
10-22 00:14:59.349: E/AndroidRuntime(670):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-22 00:14:59.349: E/AndroidRuntime(670):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-22 00:14:59.349: E/AndroidRuntime(670):  at dalvik.system.NativeStart.main(Native Method)
10-22 00:14:59.349: E/AndroidRuntime(670): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/ic_launcher.png from xml type layout resource ID #0x7f020000
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1916)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1871)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.Resources.getLayout(Resources.java:731)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-22 00:14:59.349: E/AndroidRuntime(670):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.Activity.setContentView(Activity.java:1657)
10-22 00:14:59.349: E/AndroidRuntime(670):  at com.example.test.MainActivity.onCreate(MainActivity.java:12)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-22 00:14:59.349: E/AndroidRuntime(670):  ... 11 more
10-22 00:14:59.349: E/AndroidRuntime(670): Caused by: java.io.FileNotFoundException: Corrupt XML binary file
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.AssetManager.openXmlAssetNative(Native Method)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:486)
10-22 00:14:59.349: E/AndroidRuntime(670):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1898)
10-22 00:14:59.349: E/AndroidRuntime(670):  ... 20 more

pls help me to fix this issuee sorry for my bad english

manlio
  • 18,345
  • 14
  • 76
  • 126
SelvaMariappan
  • 1,334
  • 2
  • 11
  • 20

1 Answers1

3

You cannot export a library to a jar, since you can't put your resources into a jar. This is the reason you are getting a Resources#NotFoundException. This is what the docs say:

You cannot export the library project to a self-contained JAR file, as you would do for a true library. Instead, you must compile the library indirectly, by referencing the library in the dependent application and building that application.

Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • any way convert lib project make as jar if have any example means pls mention bcoz i need to hide src – SelvaMariappan Oct 21 '13 at 19:03
  • You can export it to an aar. [See this](http://stackoverflow.com/questions/16763090/how-to-export-library-to-jar-in-android-studio). – Ahmad Oct 21 '13 at 19:08