proguard 反编译
In this article, we will examine the Android Studio project structure and key concepts in detail followed by compilers.
在本文中,我们将详细研究Android Studio项目结构和关键概念,然后详细介绍编译器。
When we start a new Android project in Android Studio, it will automatically creates a lot of files and folders for us. Let’s look at their functions and meaning. A New Project automatically opens in the Android Project View.
当我们在Android Studio中启动新的Android项目时,它将自动为我们创建许多文件和文件夹。 让我们看看它们的功能和含义。 新项目会自动在Android项目视图中打开。
Android专案检视 (Android Project View)
The Android project view shows all the build files at the top level of the project hierarchy under Gradle Scripts. Each project module appears as a folder at the top level of the project hierarchy and contains these three elements at the top level:
Android项目视图在Gradle脚本下的项目层次结构的顶层显示所有构建文件。 每个项目模块在项目层次结构的顶层显示为一个文件夹,并在顶层包含以下三个元素:
- java/ : Source files for the module. java / :模块的源文件。
- manifests/ : Manifest files for the module manifests / :模块的清单文件
- res/ : Resource files for the module res / :模块的资源文件
Here is the brief description of important files/folders in the Android project structure:
这是Android项目结构中重要文件/文件夹的简短描述:
Android清单文件 (Android Manifest File)
AndroidManifest.xml
is one of the most important file in the Android project structure.It contains information of the package, including components of the application such as activities, services, broadcast receivers, content providers etc.
It performs the following tasks:
AndroidManifest.xml
是Android项目结构中最重要的文件之一,它包含软件包的信息,包括应用程序的组件,例如活动,服务,广播接收者,内容提供者等。
它执行以下任务:
- It is responsible to protect the application to access any protected parts by providing the permissions 它负责通过提供权限来保护应用程序访问任何受保护的部分
- It also declares the android api that the application is going to use 它还声明了应用程序将要使用的android api
- It lists the instrumentation classes. The instrumentation classes provides profiling and other informations. These information are removed just before the application is published etc. 它列出了检测类。 检测类提供概要分析和其他信息。 这些信息将在应用程序发布之前被删除等。
Java (java)
The java folder contains the Java source code files of the application organized into packages. We can have more than one package in the Android application. Its always a good practice to break the source code of the application into different packages based on its core functionality. All the source files of the Activities, Services etc. go into this folder.
java文件夹包含组织成软件包的应用程序的Java源代码文件。 我们在Android应用程序中可以有多个软件包。 将应用程序的源代码根据其核心功能分为不同的软件包始终是一个好习惯。 活动,服务等的所有源文件都进入此文件夹。
资源 (res)
Res folder is where all the external resources for the application such as images, layout XML files, strings, animations, audio files etc. are stored.
Res文件夹是用于存储应用程序所有外部资源的位置,例如图像,布局XML文件,字符串,动画,音频文件等。
Sub folders:
子文件夹:
- Drawable: This folder contains the bitmap file to be used in the program. There are different folders to store drawables. They are drawable-ldpi, drawable-mdpi, drawable-hdpi,drawable-xdpi etc. The folders are to provide alternative image resources to specific screen configurations. Ldpi, mdpi & hdpi stands for low density, medium density & high density screens respectively. The resources for each screen resolutions are stored in respective folders and the android system will choose it according to the pixel density of the device Drawable :此文件夹包含要在程序中使用的位图文件。 有不同的文件夹来存储绘图。 它们是drawable-ldpi,drawable-mdpi,drawable-hdpi,drawable-xdpi等。文件夹用于为特定屏幕配置提供替代图像资源。 Ldpi,mdpi和hdpi分别代表低密度,中密度和高密度屏幕。 每种屏幕分辨率的资源都存储在相应的文件夹中,Android系统将根据设备的像素密度进行选择
- Layout: It contains XML files that define the User Interface of the application 布局 :它包含XML文件,这些文件定义了应用程序的用户界面
- Menu: XML files that define menus for the application goes into this folder 菜单 :定义应用程序菜单的XML文件进入此文件夹
- Mipmap: The mipmap folders is used for placing the app icons only. Any other drawable assets should be placed in the relevant drawable folders as before. Mipmap :mipmap文件夹仅用于放置应用程序图标。 任何其他可绘制资产应像以前一样放置在相关的可绘制文件夹中。
- Values : XML files that define simple values such as strings, arrays, integers, dimensions, colors, styles etc. are placed in this folder 值 :将定义简单值(例如字符串,数组,整数,尺寸,颜色,样式等)的XML文件放置在此文件夹中
Gradle脚本 (Gradle Scripts)
Gradle scripts are used to automate tasks.For the most part, Android Studio performs application builds in the background without any intervention from the developer. This build process is handled using the Gradle system, an automated build toolkit designed to allow the ways in which projects are built to be configured and managed through a set of build configuration files.It uses a language called groovy.
Gradle脚本用于自动执行任务。大多数情况下,Android Studio在后台执行应用程序构建,而无需开发人员的任何干预。 该构建过程使用Gradle系统处理,该系统是一个自动化构建工具包,旨在通过一组构建配置文件来配置和管理构建项目的方式,它使用一种名为groovy的语言。
项目视图 (The Project View)
。理念 (.idea)
Eclipse uses project.properties file for project specific metadata. Here in Android Studio, this .idea does the same thing. This means the project specific metadata is stored by Android Studio.
Eclipse将project.properties文件用于项目特定的元数据。 在Android Studio中,此.idea的作用相同。 这意味着特定于项目的元数据由Android Studio存储。
项目模块(应用程序) (Project Module(app))
This is the actual project folder where the application code resides. The application folder has following sub directories
这是应用程序代码所在的实际项目文件夹。 应用程序文件夹具有以下子目录
- build : This has all the complete output of the make process i.e. classes.dex, compiled classes and resources, etc.In the Android Studio GUI, only a few folders are shown. The important part is that the R.java is found here under build/generated/source/r/…/R.java build :具有make过程的所有完整输出,即classes.dex,已编译的类和资源等。在Android Studio GUI中,仅显示了几个文件夹。 重要的是R.java可以在build / Generated / source / r /…/ R.java下找到
- libs : This is a commonly seen folder in eclipse and android studio, which optionally can hold the libraries or .jar files libs :这是eclipse和android studio中的常见文件夹,可以选择保存库或.jar文件
- src : The src folder can have both application code and android unit test script. You will find two folders named “androidTest” and “main” correspond to src folder. The main folder contains two subfolders java and res. The java folder contains all the java codes and res contains drawables, layouts etc. src :src文件夹可以同时包含应用程序代码和android单元测试脚本。 您会发现两个名为“ androidTest”和“ main”的文件夹对应于src文件夹。 主文件夹包含两个子文件夹java和res。 java文件夹包含所有Java代码,res包含可绘制对象,布局等。
摇动 (gradle)
This is where the gradle build systems jar wrapper is found. This jar is how Android Studio communicates with gradle installed in Windows/MAC.
这是找到gradle构建系统jar包装器的地方。 这个jar是Android Studio与Windows / MAC中安装的gradle通信的方式。
外部图书馆 (External Libraries)
This is not actually a folder but a place where Referenced Libraries and information on targeted platform SDK are shown.
这实际上不是文件夹,而是显示参考库和目标平台SDK上的信息的位置。
什么是R.java? (What is R.java?)
Android R.java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory.
On creating any component in the activity_main.xml file, id for the corresponding component is automatically created in this file. This id can be used in the activity source file to perform any action on the component.
Android R.java是aapt (Android资产打包工具)自动生成的文件,其中包含res /目录的所有资源的资源ID。
在activity_main.xml文件中创建任何组件时,将在该文件中自动创建相应组件的ID。 可以在活动源文件中使用此ID对组件执行任何操作。
Android编译器 (Android Compilers)
The compilers converts compiled .class files to executable .dex files in the Dalvik format for further execution in the Android environment. Following are the two important tools used:
编译器将Dalvik格式的已编译.class文件转换为可执行.dex文件,以在Android环境中进一步执行。 以下是使用的两个重要工具:
敏捷 (DEX)
Dalvik Virtual Machine is an Android Virtual Machine optimized for mobile devices. It optimizes the virtual machine for memory, battery life and performance. The Dex compiler converts the class files into the .dex file that run on the Dalvik Virtual Machine. The Multiple class files are converted into one dex file. Following flow depicts compiling and packaging process from the source file:
Dalvik虚拟机是为移动设备优化的Android虚拟机。 它优化了虚拟机的内存,电池寿命和性能。 Dex编译器将类文件转换为在Dalvik虚拟机上运行的.dex文件。 将多个类文件转换为一个dex文件。 以下流程描述了源文件的编译和打包过程:
- The javac tool compiles the java source file into the class file. javac工具将Java源文件编译为类文件。
- The dx tool takes all the class files of the application and generates a single .dex file. It is a platform-specific tool. dx工具获取应用程序的所有类文件,并生成一个.dex文件。 它是特定于平台的工具。
- The Android Assets Packaging Tool (aapt) handles the packaging process. Android资产打包工具( aapt )处理打包过程。
Android ProGuard (Android ProGuard)
The ProGuard tool shrinks, optimizes, and obfuscates the code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.
ProGuard工具通过删除未使用的代码并使用语义上模糊的名称重命名类,字段和方法,从而对代码进行压缩,优化和混淆。 结果是一个较小的.apk文件,很难进行反向工程。
翻译自: https://www.journaldev.com/9319/android-studio-project-structure-compiler-proguard
proguard 反编译