Extract property files from pre-built jar file

Discussion in 'Application Development' started by isup, Jul 13, 2009.

  1. isup

    isup Member

    Jul 9, 2009
    There are several preoperty files, such as localstrings.properties, in a pre-built jar which is from a 3rd party. When my application is built be Eclipse, these files will be extracted and added to the generated apk file. However, when the application is built by Andriod make in a Linux system, they are not, though the linked classes are added to classes.dex. This causes the application not be able to run. Does anyone know how to resolve it?

    Here is the Andriod.mk

    LOCAL_PATH:= $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE_TAGS := eng development
    LOCAL_SRC_FILES := $(call all-subdir-java-files)
    include $(BUILD_PACKAGE)
    include $(CLEAR_VARS)
    LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libabc:lib/Third_party_2.5.jar
    # Use the folloing include to make our test apk.
    include $(call all-makefiles-under,$(LOCAL_PATH))


  2. isup

    isup Member

    Jul 9, 2009
    Found some similar post by google but no answer

    Subject: 3rdPartyJar Files and property files Actions...
    From: sasperilla (char...@gmail.com)
    Date: Dec 29, 2007 8:29:37 am
    List: com.googlegroups.android-developers
    I'm trying to add some 3rdparty apps to my android program, and the
    jar files are added. However, inside this 3rdpartyjar file there is
    a properties file seems to be missing when I run my app in the
    emulator, and the 3rdparty code dies. I can run my program in a
    Junit test as a normal java application and it works. How do I fix
    this in the emulator?

    Thanks in advance.
  3. isup

    isup Member

    Jul 9, 2009
    Another similar post.

    Subject: Accessing resources in 3rdpartyjar file Actions...
    From: tauren (yowz...@gmail.com)
    Date: Mar 29, 2008 12:50:24 pm
    List: com.googlegroups.android-developers
    It appears that it is not possible to access resources stored on the
    classpath within a 3rdpartyjar file from Android. Many 3rdpartyjars store data and configuration files within the jar itself. I'm
    surprised this doesn't work as it will prevent many 3rdparty
    libraries from working without major overhauls. For instance, code
    like the following doesn't work:
    URL data = this.getClass().getResource(name);
    I've read from other posts that the following doesn't work too:
    I understand that jars get converted into dex files? When this
    happens, are only class files retained? What happens to the
    resources? Is there a way to access those resources?
    Luckily, I have source for the jar file I need to use. Unfortunately,
    it uses data resources all over the place, and probably 50% of the
    classes will need to be modified. I'd much rather figure out a way to
    access those resources without modifying all the code.
    If this can't be solved, then any 3rdpartyjars that don't provide
    source code could not be used in Android until the developer provides
    an Android version of the jar. Is this just the way things work with
    Android, or is there a workaround others have found?
  4. isup

    isup Member

    Jul 9, 2009
    This post says it is impossible.

    Subject: [android-developers] Re: Embeded APK? Actions...
    From: Mark Murphy (mmur...@commonsware.com)
    Date: Dec 22, 2008 6:05:58 am
    List: com.googlegroups.android-developers

    Louis wrote:
    Our product need provide some SDK to 3rdparty, and we want to provide
    some services or activity in Android platform, spec for services. But
    seems we can't provide it through the Jar files (Please let me know if
    I am wrong :) ),

    Sure you can!
    Take your compiled Java classes and package them into a JAR, along with
    instructions for what entries in AndroidManifest.xml your customers will
    need to add to use your services and activities.

    The only thing that does not work well this way is resources -- your JAR
    cannot package resources
    , nor can you reliably ensure that resources
    will get the same resource IDs between your code and the actual Android
    application. You can accept resource IDs as parameters, but you cannot
    "bake in" your own resources. Or, rather, I have not figured out a trick
    for doing this as yet.

    I have a chapter in the upcoming _The Busy Coder's Guide to *Advanced*
    Android Development_ that covers this. Fortunately, that is one of the
    chapters already (partially) available, so current subscribers to the
    Warescription can get access to this already.

    And in these cases, is there any way to make our APK
    as Embeded APK which 3rdparty can install it with their APK without
    user more actions?

    I do not believe this is possible.
    Mark Murphy (a Commons Guy)
    CommonsWare: Helping the Commons, One Bit at a Time
    _The Busy Coder's Guide to Android Development_ Version 1.9 Available!
  5. isup

    isup Member

    Jul 9, 2009
    Any comment?
  6. Nas

    Nas New Member

    Nov 21, 2009
    I have the same problem, I need to build a jar to give out as an sdk that contains resources..

    My first thought was how did android build their jar to contain resources that they reference?

Share This Page