SlimeKT 开源项目教程

随笔2个月前发布
36 0 0

SlimeKT 开源项目教程

SlimeKTAn article sharing platform where you can personalize, subscribe to your favorite topics, get daily-read reminders, etc. App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.项目地址:https://gitcode.com/gh_mirrors/sl/SlimeKT

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

SlimeKT 项目的目录结构如下:




/


├── api/


├── app/


├── features/


├── modules/


├── README.md


└── ...

目录介绍

api/: 包含后端代码,使用 Ktor 框架构建。app/: 包含 Android 应用程序代码。features/: 包含应用程序的各种功能模块。modules/: 包含项目使用的各种模块。README.md: 项目的主文档文件。

2. 项目的启动文件介绍

app/ 目录下,主要的启动文件是 MainActivity.kt,它是 Android 应用程序的入口点。




package com.example.slimekt


 


import android.os.Bundle


import androidx.activity.ComponentActivity


import androidx.activity.compose.setContent


import androidx.compose.runtime.Composable


import androidx.compose.ui.tooling.preview.Preview


import com.example.slimekt.ui.theme.SlimeKTTheme


 


class MainActivity : ComponentActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {


        super.onCreate(savedInstanceState)


        setContent {


            SlimeKTTheme {


                // 主界面内容


            }


        }


    }


}

3. 项目的配置文件介绍

app/ 目录下,主要的配置文件是 build.gradleAndroidManifest.xml

build.gradle




plugins {


    id 'com.android.application'


    id 'kotlin-android'


    id 'kotlin-kapt'


    id 'dagger.hilt.android.plugin'


}


 


android {


    compileSdk 30


 


    defaultConfig {


        applicationId "com.example.slimekt"


        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


    }


    kotlinOptions {


        jvmTarget = '1.8'


    }


    buildFeatures {


        compose true


    }


    composeOptions {


        kotlinCompilerExtensionVersion compose_version


    }


}


 


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.compose.ui:ui:$compose_version"


    implementation "androidx.compose.material:material:$compose_version"


    implementation "androidx.compose.ui:ui-tooling:$compose_version"


    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'


    implementation 'androidx.activity:activity-compose:1.3.0-alpha06'


    implementation "com.google.dagger:hilt-android:$hilt_version"


    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"


}

AndroidManifest.xml




<manifest xmlns:android="http://schemas.android.com/apk/res/android"


    package="com.example.slimekt">


 


    <application


        android:allowBackup="true"


        android:icon="@mipmap/ic_launcher"


        android:label="@string/app_name"


        android:roundIcon="@mipmap/ic_launcher_round"


        android:supportsRtl="true"


        android:theme="@style/Theme.SlimeKT">


        <activity android:name=".MainActivity">


            <intent-filter>


                <action android:name="android.intent.action.MAIN" />


 


                <category android:name="android.intent.category.LA



SlimeKTAn article sharing platform where you can personalize, subscribe to your favorite topics, get daily-read reminders, etc. App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.项目地址:https://gitcode.com/gh_mirrors/sl/SlimeKT

© 版权声明

相关文章

暂无评论

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