Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Including resources from third-party jars
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Bolin  
View profile  
 More options Jul 31 2012, 3:58 pm
From: Michael Bolin <bolinf...@gmail.com>
Date: Tue, 31 Jul 2012 12:58:21 -0700 (PDT)
Local: Tues, Jul 31 2012 3:58 pm
Subject: Including resources from third-party jars

Assuming I have a jar such as libphonenumber
(http://code.google.com/p/libphonenumber/) that contains both compiled
class files and resources files (such
as com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US) that are
loaded via .class.getResourceAsStream(), what is the best way to ensure
that the resources end up in the right spot in the APK?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joebowbeer  
View profile  
 More options Aug 1 2012, 2:54 am
From: joebowbeer <joe.bowb...@gmail.com>
Date: Tue, 31 Jul 2012 23:54:53 -0700 (PDT)
Local: Wed, Aug 1 2012 2:54 am
Subject: Re: Including resources from third-party jars

You may receive more help if you post to the Android Developers list, or
even stackoverflow, because I think most readers of this list are building
Android images, not apks.

That being said, the JDOM folks investigated this issue when they were in
the process of validating JDOM on Android.  In their case it was the test
data that was being loaded:

https://github.com/hunterhacker/jdom/wiki/JDOM2-and-Android
https://github.com/hunterhacker/jdom/wiki/JDOM2---Android-Issue---get...

Their conclusion:

The methods this.getClass().getResource(...)

> andthis.getClass().getClassLoader().getResource(...) work as expected, and
> seemingly identically, on both regular Java and Android. The first one
> works if you use an absolute path to the resource, or a relative path to
> the package the this class is in. The second one also works on Android and
> again you should be careful with your 'path' to the resource, it only
> effectively works with a relative path, relative to the 'top' of the
> classpath.

Other approaches are to move the jar's resources into the assets folder and
load them from there, or to copy the assets to the file system when the app
is first started and then read these resources from the file system at
runtime. The file system URLs are of the form
/data/data/<package-id>/files/

See:
http://developer.android.com/reference/android/content/Context.html#g...()

--Joe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Bolin  
View profile  
 More options Aug 1 2012, 9:08 pm
From: Michael Bolin <bolinf...@gmail.com>
Date: Wed, 1 Aug 2012 18:08:40 -0700 (PDT)
Local: Wed, Aug 1 2012 9:08 pm
Subject: Re: Including resources from third-party jars

Hi Joe, thanks for the pointers. Yep, I agree that putting them in there
directly works well -- I'm just curious if there's a special tool that does
this for you. Without one, it seems like you would have to do something
like:

RESOURCES=`mktemp -d`
foreach JAR in lib_jars:
  DIR=`mktemp -d`
  jar -xf $JAR -C $DIR .
  find $DIR -name '*.class' | xargs rm
  cp -r $DIR $RESOURCES
  rm -rf $DIR

and then pass $RESOURCES to aapt package. I'm curious if apkbuilder or does
this already.

I did finally start posting to Android Developers, but it appears I'm still
moderated after posting my question over 24 hours ago.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic