<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Luiz Fernando</title>
    <description>The latest articles on DEV Community by Luiz Fernando (@thelittleluiz).</description>
    <link>https://dev.to/thelittleluiz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1777475%2F6327b9f5-ce67-408f-b230-b427f39a045b.jpg</url>
      <title>DEV Community: Luiz Fernando</title>
      <link>https://dev.to/thelittleluiz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thelittleluiz"/>
    <language>en</language>
    <item>
      <title>Tips to Debug React Native under Android</title>
      <dc:creator>Luiz Fernando</dc:creator>
      <pubDate>Thu, 01 Aug 2024 23:33:30 +0000</pubDate>
      <link>https://dev.to/thelittleluiz/tips-to-debug-under-android-3kfh</link>
      <guid>https://dev.to/thelittleluiz/tips-to-debug-under-android-3kfh</guid>
      <description>&lt;p&gt;Hello, I'm Luiz, a 26-year-old Software Engineer from São Paulo, Brazil. Today, I want to share some essential tips for debugging Android apps using React Native and ADB (Android Debug Bridge). Whether you're an experienced developer or just starting out, these tips will help make your debugging process more efficient. Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  ADB
&lt;/h2&gt;

&lt;p&gt;What is ADB? ADB, or Android Debug Bridge, is a versatile command-line tool that allows developers to communicate with and control Android devices. It facilitates a variety of device actions, such as installing and debugging apps, and provides access to a Unix shell that you can use to run various commands on a device.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect your device over WiFi to install or debug
&lt;/h2&gt;

&lt;p&gt;ADB, has a feature that will allow us to connect our android device over wi-fi so this way we can debug without the need of a cable connected to the device.&lt;/p&gt;

&lt;p&gt;To make this happen make sure that you follow the steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make sure that your device and your computer are under the same wi-fi network, ADB Debugging and Wireless Debugging are enabled in the Android Device's Developer options&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the IP Address of the Device, Searching for IP address on the device settings or by connecting via USB and running this command &lt;code&gt;adb shell "ip addr show wlan0 | grep -e wlan0$ | cut -d\" \" -f 6 | cut -d/ -f 1"&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now if you have any cables connected remove from the device and run &lt;code&gt;adb connect &amp;lt;ip_address&amp;gt;:5555&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Redirecting ports
&lt;/h2&gt;

&lt;p&gt;Sometimes, Android and React Native encounter issues fetching &lt;code&gt;localhost&lt;/code&gt; URLs. What does this mean? It indicates that Android is unable to find the ports on your machine. To resolve this, you can use some commands to proxy the ports to your computer to the Android Device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb reverse tcp:PORT tcp:PORT
adb &lt;span class="nt"&gt;-d&lt;/span&gt; reverse tcp:PORT tcp:PORT
adb &lt;span class="nt"&gt;-e&lt;/span&gt; reverse tcp:PORT tcp:PORT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Typically, this issue arises with the React Native bundler. To fix it, you just need to replace &lt;code&gt;PORT&lt;/code&gt; with &lt;code&gt;8081&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb reverse tcp:8081 tcp:8081
adb &lt;span class="nt"&gt;-d&lt;/span&gt; reverse tcp:8081 tcp:8081
adb &lt;span class="nt"&gt;-e&lt;/span&gt; reverse tcp:8081 tcp:8081
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Control your device with your computer
&lt;/h2&gt;

&lt;p&gt;There is a Tool that you can install and control devices that are connected over ADB on your computer, called &lt;a href="https://github.com/Genymobile/scrcpy" rel="noopener noreferrer"&gt;&lt;code&gt;scrcpy&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Genymobile/scrcpy/blob/master/doc/macos.md" rel="noopener noreferrer"&gt;Install on Mac&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md" rel="noopener noreferrer"&gt;Install on Linux&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Genymobile/scrcpy/blob/master/doc/windows.md" rel="noopener noreferrer"&gt;Install on Windows&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To start the application just run type on your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scrcpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Thats all Folks
&lt;/h2&gt;

&lt;p&gt;Debugging Android apps with React Native and ADB can make your life a lot easier. Using features like wireless debugging, port redirection, and tools like scrcpy helps you stay connected and fix issues without hassle. Keep experimenting and stay updated with new tools to make your debugging process smooth and efficient. Happy coding!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>adb</category>
    </item>
  </channel>
</rss>
