nishitpatel
nishitpatel

Reputation: 652

How to create Jar file from android library project with resources?

I want to create a Jar file of my android library project. My project contains resources like layouts, Strings and Drawbles. i created Jar file and its working but when i tried to open custom dialog from my jar file it will give error.

02-19 15:40:13.467: E/AndroidRuntime(27766): FATAL EXCEPTION: main
02-19 15:40:13.467: E/AndroidRuntime(27766): android.content.res.Resources$NotFoundException: Resource ID #0x0
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.content.res.Resources.getValue(Resources.java:1033)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2179)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.content.res.Resources.getLayout(Resources.java:872)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.app.Dialog.setContentView(Dialog.java:471)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.example.inappcarrierbilling.customDailog.DirectBillingDialog.onCreate(DirectBillingDialog.java:46)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.app.Dialog.dispatchOnCreate(Dialog.java:355)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.app.Dialog.show(Dialog.java:260)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.example.inappcarrierbilling.objects.BillingParams$2.onPostExecute(BillingParams.java:318)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.example.inappcarrierbilling.objects.BillingParams$2.onPostExecute(BillingParams.java:1)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.os.AsyncTask.finish(AsyncTask.java:631)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.os.Looper.loop(Looper.java:153)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at android.app.ActivityThread.main(ActivityThread.java:5297)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at java.lang.reflect.Method.invokeNative(Native Method)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at java.lang.reflect.Method.invoke(Method.java:511)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-19 15:40:13.467: E/AndroidRuntime(27766):    at dalvik.system.NativeStart.main(Native Method)

I dont want to put may library resources in my code project.

Upvotes: 0

Views: 1072

Answers (2)

Abx
Abx

Reputation: 2882

One way to do this is

Build your project then copy the jar from bin (for this your project should be a library project)

Upvotes: 2

FD_
FD_

Reputation: 12919

Jar files cannot include resources like layouts, drawables and strings. You have to link the library as a library project to your non-library project.

First make sure your library project is marked as library, then import the library using the steps from here.

Upvotes: 1

Related Questions