How to Run Android Apps Against a localhost API (Tutorial)



In this video we’re showing you how to run an Android app against a localhost API. We demonstrate a real device and an emulator approach.

Tip: turn on subtitles to deal with my accent. A full transcript is available below.

More information in the tutorial:

Watch 20+ Retrofit videos in our playlist here:

—————————————-

Future Studio is helping 5,000+ users daily to solve Android and Node.js problems with 320+ written tutorials and videos. We’re on a mission to provide new in-depth content every week.

Checkout 320+ technical in-depth tutorials:

Subscribe for two new videos every week:

—————————————-

Follow us on social media to get updates on new content:


—————————————-

Full transcript:

Hey, what is up everyone, Norman from futurestud.io University here.

In this video I’m going to show you how to run an Android app against a localhost API. In your Android project you probably have some kind of base URL, which will resolve to your URL. Obviously, if you’re running an API on your local machine, this would not work. Depending on your setup, you most likely have some kind of localhost and port address. In our case, it’s localhost:3000, which we’ll run our server with all the API endpoints.

Obviously, you cannot use localhost in your Android app since that will resolve to nothing on the phone. The trick is to use the IP address of your computer and then the port. So in my case this is this, in your case that’s most likely something else. Use the network utility to figure that out. Copy the entire address over and make that your API base URL. If your phone and your computer are on the same network, this will run everything in the app against the localhost API.

Unfortunately, this doesn’t work for emulators. An emulator cannot resolve the IP address or the localhost to your machine. Instead, you’ve use a special kind of IP address, which is 10.0.2.2. If you add the port, it’ll demonstrate exactly what’s on your localhost of the hosting machine. If you want to test your app on an emulator against the localhost API you’ve to change the IP address one more time and build the apk, run it and you can test the local API on your emulator.

If you’ve any questions, let us know in the comments. I’ve linked a blog post with all the information and the IP address in the description below. If you like this video, feel free to subscribe to us on YouTube. Happy coding.

Nguồn:https://hdwallpaperslovely.com/

Related Posts

Flash Firmware Asus Zenfone Go X014D via adb

May 26, 2020

May 26, 2020 4

Bahan Flashing Asus X014D Via ADB Fastboot :  Firmware Asus Zenfone Go Asus Intel USB Driver ADB Fastboot Cara Flash...

How to Temporarily Disable Bitdefender Internet Security 2019

March 18, 2020

March 18, 2020 16

Bitdefender Internet Security 2019 – In today’s lesson, we will teach you how to temporarily disable Bitdefender Internet Security 2019....

Solucionar el error AdbWinApi.dll Windows 7/8/10

March 21, 2020

March 21, 2020 32

Solucionar el error donde el SIMBOLO DE SISTEMA no nos deja ejecutar “Adb” Fix the error where the CMD does...

TUTORIAL BACKUP FILE DUMP VIA ADB WITH UFI BOX

March 27, 2020

March 27, 2020 13

CARA BACKUP FILE DUMP SAMSUNG VIA ADB WITH UFI BOX, Tanpa harus angkat ic,tanpa harus bongkar Cukup dgn root,langsung bisa...

Cara Download Dan Instal ADOBE AUDITION CC 2015 | BAHASA INDONESIA

April 12, 2020

April 12, 2020 36

Halo apa kabar semuanya… Di video kali saya akan mengarjakan bagaimana mendownload dan menginstal Adobe audition CC 2015. jika teman-teman...

SAMSUNG G531f FRP REMOVE WITH ADB MODE

February 28, 2020

February 28, 2020 6

SAMSUNG G531f FRP REMOVE WITH ADB MODE Link : Link : ADB FILE FREE VISIT: Nguồn:https://hdwallpaperslovely.com/

RedMi 4x прошивка с любой на любую. MiFlash

February 20, 2020

February 20, 2020 29

Перепрошивка телефона RedMi 4x через ПК программой MiFlash с заблокированным загрузчиком. Канал по ремонту ArtBelChannel – Кабель с кнопкой для...

J2,j5,j7,s7 set default storage as sd card Solv 100% Working Try it

May 26, 2020

May 26, 2020 42

Part 2 video for j5 prime, j7, j7 prime Splender Modified How to Install Fog LED On Splender Either any...

Đánh giá iOS 13.1.2: lại là sửa lỗi!

February 7, 2020

February 7, 2020 29

iOS 13.1.2 chính thức ra mắt ngay sau khi iOS 13.1 và iOS 13.1.1. iOS 13.1.2 hỗ trợ iPhone SE...

[Tự học Adobe Audition CC] – Giới thiệu phần mềm Audition

May 17, 2020

May 17, 2020 10

Video được thực hiện nhằm giúp các bạn muốn sử dụng phần mềm Adobe Audition để tự thu âm và...

Vietnam 2010 – How will Asia Lead

March 18, 2020

March 18, 2020 4

06.06.2010 Opening Plenary session: How Will Asia Lead? Domestic and intra-regional trade are the new mantra for Asia suggesting greater...

Nhanh tay mua hàng 9.000đ trên LAZADA trong hôm nay

February 28, 2020

February 28, 2020 42

– Link mua hàng 9k, nhóm và mã giảm giá: (vào link xong xuống dưới có link 9k nhé) ——————...

DESCARGAR ADOBE ACROBAT PRO 11

March 22, 2020

March 22, 2020

Estimados Youtubers!! Les comparto el activador del software Adobe Acrobat XI, ya que hubo un inconveniente con el número de...

2019✅ Actualizar Firmware de SSD Kingston para mejor rendimiento y alargar la vida del SSD.

February 4, 2020

February 4, 2020 21

Suscríbete y conoce todas las novedades en tecnología: 🤩 Aquí encuentras tú problema solucionada. ✅ 😓¿No sabes como? 😤 😴¡Estas...

[Fixed] How to Fix Dead Android Logo in Zenfone 2

March 14, 2020

March 14, 2020 20

Hello, YouTube! This Video about Fixing Android Dead Logo (No Command Error) Issues! Watch Full Video to Know More.! Commend...

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *