Dalvik instruction Analysis (ii) from Java files to Dex

Source: Internet
Author: User


This series of articles is thought for a long time but has not been put into action, taking advantage of the two-day holiday is not over,

Hurriedly pen, afraid to work there is no time to calm down to write these articles, so a little rush, performance in the series of articles

Content arrangement on is not very reasonable, some content also need to enrich, but better than nothing bar, first write down again revise, if

Some feedback can also be modified according to feedback. OK, start the second article.

This article can be a DX HelloWorld, in this article I will describe if you compile a Java file

into a dex file. Ok,go!

Step1: Prepare Java file, file name Helloworld.java, content as follows

public class HelloWorld {public    void SayHello () {        System.out.println ("Hello world!");}    }
What a familiar HelloWorld:)


Step2: Write a script that reads as follows:

mkdir classesjavac-d Classes src/*.javadx-jxmx500m--debug--dex--no-optimize--positions=none--no-locals     -- Dump-to=classes.lst--output=classes.dex classeszip Test.jar classes.dex
Here are some explanations to be made using Javac to compile Java source files, generate class files, and then use DX to

class file into the Dalvik directive, and package the build Classes.dex, and finally package Dex into a jar package. Although just

Just a few words, but the internal logic of the DX process is actually very complex, and I'll write a separate article about DX's

Process. Briefly summarize the above compilation process:

. java------------->. class---------->. dex
Javac DX


The corresponding reverse process is as follows:

. java <-------------. class <------------. Dex

Jd-gui Dex2jar


step3: Executing the above script will generate the Classes.dex file

This article mainly introduces the process of Java to Dex through scripts, and subsequent articles will detail the DX process, as well as the Dex

The structure of the file.

Dalvik instruction Analysis (ii) from Java file to Dex

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.