Easy way to get around the introduction of the third-party SDK's jar package in DelphiXE5

Source: Internet
Author: User

Easy way to get around the introduction of the third-party SDK's jar package in DelphiXE5 (2014-02-21 17:30:17) reproduced
Tags: android Delphi xe5 jar SDK Category: Programming Miscellaneous sets

Toss a few days finally success, hereby share to the new contact classmate, hope can a little help.

Introduction to ————— Environment ————————

Delphi XE5 Update2

Windows7 64bit

A, with "China Meteorological (www.weather.com.cn)" Weather forecast Android SDK For example, it provides only one jar file: Smartweatherapi_android_3.0.2.jar (for the description convenient, I changed the file name to Weather.jar)

(If the Android SDK has both a jar and so files, no problem, the jar continues to do the following method, and so file in the Delphi project is published to the Library\lib\armeabi\ directory to run the program.) Note: I understand that so files are like DLLs for Java to invoke in virtual machines, and third parties are inconvenient to expose you to the details. )

B, suppose we create a directory in the D disk as D:\WorkSpace, our operations are done here.

——————————————————

The first step: Copy the Delphi Classes.dex to D:\WorkSpace, renamed Delphi-classes.dex. This file is typically found in this directory:

C:\Program Files (x86) \embarcadero\rad Studio\12.0\lib\android\debug

(Note: This example uses the debug version to experiment, to use the release version also the same)

The second step: the SDK jar file is also copied to D:\WorkSpace, renamed to Weather.jar.

Step three: Use the following batch dxandmerge.bat to implement the "third-party jar package as Dex file, and then merge two dex files" for the purpose. (For the Windows environment variable configuration to be used for Android development, do not repeat, many articles on the web to see.) )

————————————

@echo off

Setlocal

Set dx_lib= "%android_home%\build-tools\android-4.3\lib"

Echo.

Echo Convert third-party jar to DEX format

Echo.

Call DX--dex--verbose--output=d:\workspace\weather.dex--positions=lines D:\WorkSpace\weather.jar

Echo.

Echo Merge Dex file

Echo.

JAVA-CP%dx_lib%\dx.jar com.android.dx.merge.DexMerger D:\WorkSpace\classes.dex D:\WorkSpace\weather.dex d:\ Workspace\delphi-classes.dex

————————————

This new classes.dex inside has the content of the SDK.

We can use the Dex2jar tool (download separately) to convert this new Classes.dex file into a jar file, and then open the jar file with the Jd-gui tool (download separately) to see, in addition to Embarcadero original package content, the new weather forecast content is included, as shown in:


At this point, the "jar into Dex" This thing is so easy to fix.

The following are the main things to do:

1) Replace the Delphi default with the new Classes.dex in the release settings of the project;

2) According to the instructions of others ' SDK, carefully revise the AndroidManifest.template.xml;

3) In accordance with the Java code compiled by the jar of the SDK, carefully translated into classes and interface descriptions such as Jobject, Jobjectclass, and the type of Delphi that can be used. (Note: I have experimented with invoking individual classes and interfaces successfully, stating that the new Dex file does work for the SDK, but has not actually completed a complete set of SDK translations, take it slow.) )

The introduction is here.

Easy way to get around the introduction of the third-party SDK's jar package in DelphiXE5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.