Study/Android

[Android Studio] Firebase와 연동해서 Chat App 만들기 part 1

AC 2021. 6. 3. 11:18

기본 셋팅

build.gradle(Project)

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.1"
        classpath 'com.google.gms:google-services:4.3.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

build.gradle(Module)

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "kr.tutorial.mychatapp2"
        minSdkVersion 21
        targetSdkVersion 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
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

    //firebase
    implementation platform('com.google.firebase:firebase-bom:28.0.1')

    implementation group: 'com.google.firebase', name: 'firebase-analytics', version: '19.0.0'
    implementation group: 'com.google.firebase', name: 'firebase-auth', version: '21.0.1'
    implementation group: 'com.google.firebase', name: 'firebase-database', version: '20.0.0'
    implementation group: 'com.google.firebase', name: 'firebase-storage', version: '20.0.0'
    implementation group: 'com.firebaseui', name: 'firebase-ui-auth', version: '7.1.1'
    implementation group: 'de.hdodenhof', name: 'circleimageview', version: '3.1.0'
    implementation group: 'com.rengwuxian.materialedittext', name: 'library', version: '2.1.4'
    implementation group: 'com.github.bumptech.glide', name: 'glide', version: '4.12.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    runtimeOnly group: 'com.github.bumptech.glide', name: 'compiler', version: '4.12.0'
    implementation group: 'com.karumi', name: 'dexter', version: '6.2.2'
    implementation group: 'com.squareup.retrofit2', name: 'retrofit', version: '2.9.0'
    implementation group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.9.0'
    implementation group: 'com.google.firebase', name: 'firebase-messaging', version: '22.0.0'
    implementation group: 'androidx.multidex', name: 'multidex', version: '2.0.1'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

 

gradle.properties

org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true

drawable

drawable.zip
0.06MB

파일압축 풀어서 drawable에 넣습니다. 24에 붙여넣는게 아닙니다~

layout

layout.zip
0.01MB

Menu

menu.zip
0.00MB

values

values.zip
0.00MB

 

5개의 액티비티를 생성

 

 

manifests

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="kr.tutorial.mychatapp2">

    <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/AppTheme">
        <activity android:name=".RegisterActivity" />
        <activity android:name=".LoginActivity" />
        <activity android:name=".MessageActivity" />
        <activity android:name=".MainActivity" />
        <activity android:name=".StartActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

LIST