开源项目 CleanArchitectureForAndroid 使用教程

随笔20小时前发布 泗四坊方
5 0 0

开源项目 CleanArchitectureForAndroid 使用教程

CleanArchitectureForAndroidClean Architecture for Android – a sample project项目地址:https://gitcode.com/gh_mirrors/cl/CleanArchitectureForAndroid

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




CleanArchitectureForAndroid/


├── app/


│   ├── build.gradle


│   ├── proguard-rules.pro


│   └── src/


│       ├── main/


│       │   ├── java/


│       │   │   └── com.eran.cleanarchitectureforandroid/


│       │   │       ├── data/


│       │   │       ├── domain/


│       │   │       ├── presentation/


│       │   │       └── App.kt


│       │   └── res/


│       │       ├── drawable/


│       │       ├── layout/


│       │       ├── mipmap/


│       │       └── values/


│       └── test/


│           └── java/


│               └── com.eran.cleanarchitectureforandroid/


├── build.gradle


├── gradle.properties


├── settings.gradle


└── README.md

目录结构介绍

app/: 主应用程序模块,包含所有源代码和资源文件。
build.gradle: 应用程序模块的构建脚本。proguard-rules.pro: ProGuard 规则文件。src/: 源代码目录。
main/: 主源代码目录。
java/: Java 或 Kotlin 源代码目录。
com.eran.cleanarchitectureforandroid/: 主包目录。
data/: 数据层,负责数据获取和存储。domain/: 领域层,包含业务逻辑和用例。presentation/: 表示层,负责 UI 和用户交互。App.kt: 应用程序的入口点。 res/: 资源目录。
drawable/: 图片资源。layout/: 布局文件。mipmap/: 应用图标。values/: 字符串、颜色等资源。 test/: 测试代码目录。
java/: 测试代码。

2. 项目的启动文件介绍

App.kt




package com.eran.cleanarchitectureforandroid


 


import android.app.Application


 


class App : Application() {


    override fun onCreate() {


        super.onCreate()


        // 初始化操作


    }


}

App.kt: 这是应用程序的入口点,继承自 Application 类,在 onCreate 方法中进行应用程序的初始化操作。

3. 项目的配置文件介绍

build.gradle (项目级)




// 项目级 build.gradle 文件


buildscript {


    ext.kotlin_version = '1.5.21'


    repositories {


        google()


        mavenCentral()


    }


    dependencies {


        classpath 'com.android.tools.build:gradle:7.0.0'


        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


    }


}


 


allprojects {


    repositories {


        google()


        mavenCentral()


    }


}


 


task clean(type: Delete) {


    delete rootProject.buildDir


}

build.gradle: 项目级的构建脚本,定义了项目的构建工具版本、依赖仓库和插件。

build.gradle (模块级)




// 模块级 build.gradle 文件


plugins {


    id 'com.android.application'


    id 'kotlin-android'


}


 


android {


    compileSdk 30


    defaultConfig {


        applicationId "com.eran.cleanarchitectureforandroid"


        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'


        }


    }


    compileOptions {


        sourceCompatibility JavaVersion.VERSION_1_8


        targetCompatibility JavaVersion.VERSION_1_8


    }


    k

CleanArchitectureForAndroidClean Architecture for Android – a sample project项目地址:https://gitcode.com/gh_mirrors/cl/CleanArchitectureForAndroid

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...