[Android] 안드로이드 스튜디오 Iguana 베타 설치 & Gemini API로 생성형 AI앱 빌드하기
Android용 Google AI 클라이언트 SDK를 사용하여 Android 앱에서 직접 Gemini API에 액세스하는 방법
Jan 18, 2024
- 현재 버전이 Hedgehog이라면 Android Studio Preview에 들어가서 이구아나 설치를 눌러줍니다! 혹시나 맥 쓰는데 이 화면이 안보인다면 사이트 언어를 영어로 바꾸고 다시 링크 들어가보세요!
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252Fc1976948-bd41-4aef-94f3-4c6b58986a9d%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.04.57.png%3Ftable%3Dblock%26id%3D183c9671-583e-4f3f-9499-9e69b8eb8b6d%26cache%3Dv2&w=3840&q=75)
- 원하는 경로에 저장해놓고 압축을 풀어줍니다!
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252Fc3e9ea0c-3fef-42af-9e65-7ace97de1fbc%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.10.55.png%3Ftable%3Dblock%26id%3D35b72849-79b1-4005-bc74-0f29d9d9341b%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F08823c8b-e44c-4450-a53d-fb59650a0e12%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.11.59.png%3Ftable%3Dblock%26id%3Dc097404b-845d-4e5b-a1ce-6676bf2d5274%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F201d7129-30af-4f69-8dbd-8ff63d1fd230%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.12.52.png%3Ftable%3Dblock%26id%3Dd36ca952-c49f-4547-beb9-d504bdaf011a%26cache%3Dv2&w=3840&q=75)
그러면 기존 안드로이드 스튜디오 앱 옆에 안드로이드 스튜디오 프리뷰 앱이 보입니다!
Import android studio settings? 라고 알림이 뜰텐데, 기존 안드로이드 스튜디오 앱을 선택해서 셋팅을 가져옵니다.
- Android 스튜디오에서 첫 번째 생성형 AI 앱 빌드하기 에 들어가서 순서대로 따라합니다.
- 근데 위 화면이 보여야 하는데 아래 화면이 나온다면?
- 구글링해봅시다… Why I have no Gemini API starter template in my Android Studio?
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F8f4ce49f-5943-4a1a-ad52-560b8ebd67db%252FUntitled.png%3Ftable%3Dblock%26id%3D058bb096-20cf-46ad-a04e-aff223b5814d%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F427922a7-a3f7-4a3a-bb78-9080035c1724%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.36.01.png%3Ftable%3Dblock%26id%3D638e09b5-5731-4b1e-96f8-714821b4fb1a%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F48e6f891-c627-4a4a-b903-cf5618ad2f99%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_6.38.35.png%3Ftable%3Dblock%26id%3Dbc281a6c-8d9b-44ff-8f15-a8c39486c772%26cache%3Dv2&w=3840&q=75)
이구아나 베타 버전이고, 대한민국은 지원되는 지역인데,,, 안뜬다…
- 왜 안뜨는지 모르겠다. 샘플앱을 가져와본다. File > New > Import Sample을 통해 Generative AI 코드 샘플을 Android Studio로 가져오고 Generative AI Sample을 검색해서 가져온다.
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F7113034c-cc52-496e-96bd-1d724733e702%252FUntitled.png%3Ftable%3Dblock%26id%3D9e9862b3-f762-4f66-9ed9-be3f603f468d%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F8c066434-1402-4ca7-a5f3-299901412c14%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_7.13.44.png%3Ftable%3Dblock%26id%3D8507716e-f6bc-429d-9143-5fe2123ecb6f%26cache%3Dv2&w=3840&q=75)
언제나 리드미를 잘 읽자. 특히 이런 공식 문서는 설명이 잘 되어있다!
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252Fe2c26a45-ae34-4c8b-aeb4-d4b2d4702182%252F%2525E1%252584%252589%2525E1%252585%2525B3%2525E1%252584%25258F%2525E1%252585%2525B3%2525E1%252584%252585%2525E1%252585%2525B5%2525E1%252586%2525AB%2525E1%252584%252589%2525E1%252585%2525A3%2525E1%252586%2525BA_2024-01-16_%2525E1%252584%25258B%2525E1%252585%2525A9%2525E1%252584%252592%2525E1%252585%2525AE_7.13.31.png%3Ftable%3Dblock%26id%3Dee693d83-12a8-4e2a-a889-b779aa10e441%26cache%3Dv2&w=3840&q=75)
여기서
Create API in new project
를 눌러서 API key를 발급받는다. 이 키는 절대 공유하면 안된다. 메모장에 잘 메모해두고, 프로젝트 local.properties
에 apikey=YOUR_API_KEY
를 입력한다. 그리고 gitignore
에 local.properties
를 추가해준다.그리고 앱을 빌드해주면 다음의 스크린샷처럼 텍스트요약, 채팅, 멀티모달 기능을 이용해 볼 수 있다.
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F0fbd2247-367b-4101-b650-9214061c097c%252FScreenshot_20240117_024132.png%3Ftable%3Dblock%26id%3Dc187b453-a094-444c-b6a7-40bacd8be0f6%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F2566c3ce-4ff6-4227-b3db-8fe267682d43%252FScreenshot_20240117_024203.png%3Ftable%3Dblock%26id%3Df11f1c37-093d-4032-bee5-540ea1dd9bf5%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F12839317-7eda-474d-b04a-24b07ee53676%252FScreenshot_20240117_024219.png%3Ftable%3Dblock%26id%3D4a1d38b3-e259-492c-94a4-8e088f0bf8d6%26cache%3Dv2&w=3840&q=75)
![notion image](https://inblog.ai/_next/image?url=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%253A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F260bbe25-da4d-46d5-b9ab-6c28413babb7%252F9d7c83de-8ac7-4dfc-a574-ea1fe1c6de33%252FScreenshot_20240117_024231.png%3Ftable%3Dblock%26id%3D1fdfb3b5-9882-4773-8807-9dedfd44d372%26cache%3Dv2&w=3840&q=75)
Share article