Include 3rd party code to APK


Last Updated:

  1. isup

    isup Member This Topic's Starter

    Joined:
    Jul 9, 2009
    Messages:
    20
    Likes Received:
    0
    Below is my makefile. The generated APK file does include the classes from Third_party_2.5.jar, but not property files. The application does not work after the APK is loaded. Any suggestion?

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

    Advertisement
  2. isup

    isup Member This Topic's Starter

    Joined:
    Jul 9, 2009
    Messages:
    20
    Likes Received:
    0
    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
    Hi,
    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 This Topic's Starter

    Joined:
    Jul 9, 2009
    Messages:
    20
    Likes Received:
    0
    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:
    Thread.currentThread().getContextClassLoader().get ResourceAsStream(resource);
    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?
    Thanks!
    Tauren
     
  4. isup

    isup Member This Topic's Starter

    Joined:
    Jul 9, 2009
    Messages:
    20
    Likes Received:
    0
    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 This Topic's Starter

    Joined:
    Jul 9, 2009
    Messages:
    20
    Likes Received:
    0
    Any commnet? Why can Eclipse do it but command line "make" not?
     

Share This Page

Loading...