ModularizationExample 项目教程
ModularizationExampleEasy to understand real-life example of a modularized Android app项目地址:https://gitcode.com/gh_mirrors/mo/ModularizationExample
1. 项目的目录结构及介绍
ModularizationExample/
├── app/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ ├── com/
│ │ │ │ │ ├── jeroenmols/
│ │ │ │ │ │ ├── modularizationexample/
│ │ │ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ │ │ ├── ModularizationExampleApplication.java
│ │ │ ├── res/
│ │ │ │ ├── layout/
│ │ │ │ │ ├── activity_main.xml
│ │ │ │ ├── values/
│ │ │ │ │ ├── strings.xml
├── build.gradle
├── settings.gradle
├── gradle.properties
目录结构介绍
app/: 主应用模块。
src/: 源代码目录。
main/: 主源集。
java/: Java 源代码。
com/jeroenmols/modularizationexample/: 主应用包。
MainActivity.java: 主活动文件。ModularizationExampleApplication.java: 应用启动类。 res/: 资源文件。
layout/: 布局文件。
activity_main.xml: 主活动布局文件。 values/: 字符串资源。
strings.xml: 字符串配置文件。 build.gradle: 应用模块的构建脚本。settings.gradle: 项目设置文件。gradle.properties: Gradle 属性配置文件。
2. 项目的启动文件介绍
ModularizationExampleApplication.java
package com.jeroenmols.modularizationexample;
import android.app.Application;
public class ModularizationExampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// 应用启动时的初始化代码
}
}
介绍
ModularizationExampleApplication 类继承自 Application 类,是应用的启动类。onCreate 方法在应用启动时调用,用于初始化应用的全局状态。
3. 项目的配置文件介绍
build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.jeroenmols.modularizationexample"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
介绍
plugins: 应用的插件,包括 com.android.application 和 kotlin-android。android: Android 构建配置。
compileSdk: 编译 SDK 版本。defaultConfig: 默认配置,包括应用 ID、最小 SDK 版本、目标 SDK 版本、版本号和版本名。buildTypes: 构建类型,
ModularizationExampleEasy to understand real-life example of a modularized Android app项目地址:https://gitcode.com/gh_mirrors/mo/ModularizationExample
1