๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’š ๊ฐœ๋ฐœ/์•ˆ๋“œ๋กœ์ด๋“œ

[์•ˆ๋“œ๋กœ์ด๋“œ] AAR(Android Archive) ํ…Œ์ŠคํŠธ ... 2

by devshin.kr 2021. 8. 12.
728x90

2021.08.12 - [๊ฐœ๋ฐœ/์•ˆ๋“œ๋กœ์ด๋“œ] - [์•ˆ๋“œ๋กœ์ด๋“œ] AAR(Android Archive) ๋งŒ๋“ค๊ธฐ ... 1

 

[์•ˆ๋“œ๋กœ์ด๋“œ] AAR(Android Archive) ๋งŒ๋“ค๊ธฐ ... 1

JAR (Java Archive) JAR๋Š” ํ•ด๋‹น ํ”Œ๋žซํผ์—์„œ JAVA ์‘์šฉํ”„๋กœ๊ทธ๋žจ์„ ๋ฐฐํฌํ•˜๊ธฐ ์œ„ํ•ด ๊ณ ์•ˆ๋œ ํŒจํ‚ค์ง€ ํŒŒ์ผ ํ˜•์‹์ด๋‹ค. ์ปดํŒŒ์ผ๋œ Javaํด๋ž˜์Šค ํŒŒ์ผ๊ณผ, MANIFEST ๊ฐ™์€ ํŒŒ์ผ๋“ค์ด ํฌํ•จ๋œ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ZIP ์•„์นด์ด๋ธŒ ํ˜•

devshin93.tistory.com

์ด์ „ ์žฅ์—์„œ ์ด์–ด์„œ ๊ณ„์†...

 

1. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ƒˆ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑ

 

2. setting.gradle์— ์ด์ „ ์žฅ์—์„œ ์ƒ์„ฑํ•œ ๋ชจ๋“ˆ์„ ์ถ”๊ฐ€

๊ธฐ์กด setting.gradle (AARTest)

rootProject.name = "AARTest"
include ':app'

 

์ˆ˜์ • ํ›„ setting.gradle (AARTest)

rootProject.name = "AARTest"
include ':app', ':aarlib'
project(':aarlib').projectDir = new File("D:/AARLib")

 

 

 

3. build.gradle (:app) ์˜ dependencies ์— implementation project(":aarlib") ์ถ”๊ฐ€

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.devshin93.aartest"
        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.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

	// ์—ฌ๊ธฐ!
    implementation project(":aarlib")
}

 

 

 

4. Sync Now ํด๋ฆญ!

์ด๋ ‡๊ฒŒ aarlib ๋ชจ๋“ˆ์ด ์ถ”๊ฐ€ ๋œ๋‹ค. →

 

 

 

5. ํ…Œ์ŠคํŠธ

MainActivity.java ์—์„œ ๋ชจ๋“ˆ์— ์žˆ๋˜ Calculate ํด๋ž˜์Šค์˜ add ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœ

package com.devshin93.aartest;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.devshin93.aarlib.Calculate;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Calculate calculate = new Calculate();
        System.out.println( calculate.add(1, 2) );
    }
}

 

๋Œ“๊ธ€