Android Clean Architecture 项目教程

Android Clean Architecture 项目教程

Android-CleanArchitectureThis is a sample app that is part of a series of blog posts I have written about how to architect an android application using Uncle Bob's clean architecture approach.项目地址:https://gitcode.com/gh_mirrors/an/Android-CleanArchitecture

1. 项目的目录结构及介绍

目录结构

Android-CleanArchitecture/
├── app/
│   ├── build.gradle
│   ├── src/
│   │   ├── main/
│   │   │   ├── java/
│   │   │   │   ├── com.fernandocejas.android10.sample.data/
│   │   │   │   ├── com.fernandocejas.android10.sample.domain/
│   │   │   │   ├── com.fernandocejas.android10.sample.presentation/
│   │   │   ├── res/
│   │   │   ├── AndroidManifest.xml
├── build.gradle
├── settings.gradle

目录介绍

  • app/: 主应用程序模块。
    • build.gradle: 应用程序的构建脚本。
    • src/main/: 主源代码目录。
      • java/: Java 源代码目录。
        • com.fernandocejas.android10.sample.data/: 数据层代码。
        • com.fernandocejas.android10.sample.domain/: 领域层代码。
        • com.fernandocejas.android10.sample.presentation/: 表示层代码。
      • res/: 资源文件目录。
      • AndroidManifest.xml: 应用程序的清单文件。
  • build.gradle: 根项目的构建脚本。
  • settings.gradle: 项目的设置文件。

2. 项目的启动文件介绍

启动文件

  • app/src/main/java/com.fernandocejas.android10.sample.presentation/AndroidApplication.java

文件介绍

AndroidApplication.java 是应用程序的入口点,继承自 Application 类。它负责初始化应用程序的全局状态,例如依赖注入框架的设置。

public class AndroidApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        // 初始化依赖注入框架
        this.initializeInjector();
    }

    private void initializeInjector() {
        // 初始化 Dagger 或其他依赖注入框架
    }
}

3. 项目的配置文件介绍

配置文件

  • app/build.gradle
  • settings.gradle
  • app/src/main/AndroidManifest.xml

文件介绍

app/build.gradle

该文件包含了应用程序的构建配置,例如依赖库、插件、构建类型等。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.fernandocejas.android10.sample.app"
        minSdkVersion 15
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}
settings.gradle

该文件包含了项目的模块配置。

include ':app'
app/src/main/AndroidManifest.xml

该文件是 Android 应用程序的清单文件,包含了应用程序的基本信息和组件声明。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fernandocejas.android10.sample.app">

    <application
        android:name=".AndroidApplication"
        android:icon="@

Android-CleanArchitectureThis is a sample app that is part of a series of blog posts I have written about how to architect an android application using Uncle Bob's clean architecture approach.项目地址:https://gitcode.com/gh_mirrors/an/Android-CleanArchitecture

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杭云瑗Ward

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值