check android auto app log messages while connected to car - android

I have a question on checking logs/debugging of android auto app when the mobile device is connected to the main Head Unit (car).
During apk installation on the Mobile device from the development machine
using Android Studio, the logs can to checked using adb (Android Debug Bridge).
Since it is a development machine, the calls does not go into functions like onCarConnectionCallbacks.
So tried using DHU (Desktop Head Unit), but DHU is connected using adb forward socket connection, How to check for app log messages simultaneously?
And also how to check log messages or debug the app, when it is connected to the main Head Unit (Car), Should the adb be installed? (Here the mobile is not on development mode).
I am not able to find convincing answers online.
Please give your view on this.
Thanks

Having the port forwarded for the DHU connection won’t affect the ADB streaming the logcat in another terminal. You can checkout the ADB documentation on how to Connect to a device over Wi-Fi, and use a laptop to connect with since the usb connection will be used on the phone to connect to the car or DHU.
For the onConnectionCallbacks, those are still functional even when connecting to the DHU. Sounds like it might be a coding issue with registering the connection callback.

Related

How to simulate offline mode in expo app during development

I am developing an expo app and I was working with some caching features. To test them I have to test my app in offline mode, but if I turn off my wifi (system or device) my app simply is unable to connect to the metro server. Even turning the network settings to offline in debugger didn't work, the app was again completely not loading. How can I simulate offline mode in my device while still being able to connect to the metro bundler?
I struggled with this for a while before I came across an answer. Connect via USB! I have tested this with iPhone only so far, but should work for Android too.
I should caveat that I'm using EAS Build, but this should also work with basic Expo.
With the basic development method (expo start --dev-client), the client app and server connect via your local router. The server automatically listens on an ip address available in the local LAN (that's what the QR code is). This is not helpful for developing offline-first features, because as soon as you disconnect your phone from WiFi, the connection will be lost and the dev app will close. In order to develop offline you can do the following:
Run the following command: ifconfig -a. Take note of highest number network interface on list like en7 for example
Connect phone with usb cable
Rerun ifconfig, two new network interfaces should show up with highest numbers. Take the second highest. E.g. en8. Note down it’s inet ip address
Run export EXPO_DEVTOOLS_LISTEN_ADDRESS=<ip address here> in the shell where you will run the development server
Run export REACT_NATIVE_PACKAGER_HOSTNAME=<ip address here>
expo start --dev-client as normal
The IP address advertised through the QR code will now be the IP for the usb connection that you put in above, so mobile client app will go through the usb cable to reach the dev server on your computer.
Switch on airplane mode on the phone as much as you want. Metro, hot reloading, debugging, all keep functioning, and in fact are usually much faster than via router. Enjoy!
I faced the same issue and didn't find an easy solution online. Luckily I've tried the following and it worked:
Connect a physical device. I've tried it on emulator for a while but failed.
Start Expo on localhost instead of LAN as it does by default: expo start --localhost.
Disable WiFi/cellular connection on the device.
See that the connection to Metro bundler is still working.
Work as you are used to.
If you are testing on an android device, the following steps have worked for me:
Connect your physical device via a USB cable. Make sure you have developer mode turned on.
Start expo in localhost using expo start --localhost.
Using adb, set up a connection so your device can listen to the port where the development server is running. This can be done using the command adb reverse tcp:[port] tcp:[port]. Say for example your server is running on 127.0.0.1:19000, run the command
adb reverse tcp:19000 tcp:19000
Now you should able to run the app in expo without an active internet connection.

Android Studio - how to use my wifi in order to connect to internet

I searched on how to get an Internet connection from my emulator in Android Studio and it was suggested I start up the emulator from the command line as follows: emulator -avd Pixel_3a_XL_API_29 -dns-server 8.8.8.8. This indeed has provided an Internet connection when I do from the command line, after adb shell, then run-as com.example.myapplication, then ping abcnews.go.com. this returns packets from the server "...r.cloudfront.net". Looking up this server, it appears to be for Amazon AWS, and is "free", up to some data limit I haven't looked up yet. This is OK short-term, but I would prefer to use my home wifi rather than go thru a different server. What's the best way to have my Android Studio emulator be able to connect to the Internet via my home wifi? (do I need a plugin?) TIA, Steve
First of all, emulator below API 25 doesn't support wifi.
Second, you can't connect the emulator directly to your WiFi.
The WiFi in the emulator provides a virtual hotspot to which the emulator automatically connects.
So, best practice would be that you connect your PC to your home WiFi and then run the emulator on your PC.

Connection refused: ADB connection from Iphone to windows

I am trying to build a watch face for Android wear. The Android wear is an emulator and the device that I have is an iPhone connected via USB to my windows laptop
I have followed the instructions from the below link
https://developer.android.com/studio/command-line/adb.html ,
verified device compatibility as per
https://www.android.com/wear/check/
and have also followed responses as per the answers # adb connection over tcp not working now, however I am receiving the following error
unable to connect to :5555: cannot connect :5555: No conn
ection could be made because the target machine actively refused it. (10061)
Actively refused it means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. You may also want to check these SO posts: Trouble debugging android wear over bluetooth - Unable to connect to localhost and No connection could be made because the target machine actively refused it? which also stated that the machine exists but that it has no services listening on the specified port, or there is a firewall stopping you. You may check it out.
Thanks. I was able to figure out with some research that getting to have iPhone with a wearable emulator may not be possible and decided to have both my device and wearable as emulators. Though it was difficult, I was able to get both my emulators talk to each other with the below link Pairing Android and Wear emulators and https://kennethmascarenhas.wordpress.com/2014/08/19/developing-for-android-wear-with-emulators/?utm_source=Android%20Weekly&utm_campaign=a97f04efe2-Android_Weekly_116&utm_medium=email&utm_term=0_4eb677ad19-a97f04efe2-337259209 with a minor change to authentication, which I have included as comment in the stackoverflow post

Bluetooth debugging on android wear failing

I've been attempting to debug my android wear app via bluetooth and have been running into a few problems. The main problem is that I'll successfully be running the app and debugging via bluetooth when the connection fails. After the pipe is broken nothing I do seems to get the connection back outside of switching phones. This is obviously not a workable solution, so I was wondering if anyone else had run into any similar problems.
After trying all the steps in #Alex Sulivan's answer, I also tried another suggestion from here which was suggested for devs who have previously connected to an emulator.
open Android wear companion app
Go to Settings Click on Emulator
Click 'FORGET WATCH'
This didn't work either!
Finally, changing the last adb command to
adb connect 127.0.0.1:4444
did the job.
Having done all of the steps, I don't know how many were required.
I've reached some degree of success by re-setting everything and following the developer guide again to setting up bluetooth.
Turn bluetooth debugging off on wear device
Turn ADB debugging off on wear device
Revoke debugging authorization on wear device (not sure if necessary)
Turn bluetooth debugging off on wear app on handheld
kill the adb server (adb kill-server)
Restart adb server (adb server restart)
Turn ADB debugging on on wear device
Turn bluetooth debugging on on wear device
Turn bluetooth debugging on on wear app on handheld
enter adb forwarding commands:
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444
Pray
These steps have mostly worked for me.
Debugging over Bluetooth was always Off for me. Apparently I had to choose a debugging wearable device here:
Android Wear -> Settings (gear icon) -> Debugging over Bluetooth -> Device to Debug
Then all other comments are helpful too.

I need to debug my Android app while not plugged into my computer

So, let me start off by saying that I am 'relatively' familiar and comfortable with making Android apps and using both LogCat and DDMS to debug.
That being said, I'm encountering more of a logistical issue than anything else right now - I am making a locative app, where the GPS is fuelling and controlling other methods in my Activity, and after a while, it is crashing.
Now, because it is locative, I am walking around to test it, in order to receive different GPS locations. Because of this, I am not connected to my computer at the time that it crashes, so have no way (that I know of) to read the stack trace, etc.
In my particular instance, I am navigating through a series of activities, and finally reach the penultimate screen in my app, and while I am running the application in my studio, it runs indefinitely without issue. It is only when I take the device outside that it crashes...
I am wondering if anyone has any tips or tricks with this issue - I'm sure give the prevalence of locative apps, it must have come up, but I cant seem to find the right search terms. It could be as simple as saving the LogCat to file, and/or the stackTrace, but I'm not sure that's the answer...
Thanks in advance.
If I got you right, this is what you are looking for:
https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=de
Edit: Also there are many more apps like this. You can just browse around in Google Play Store
You can debug the app without rooting your android, unlike the other responses. start off by plugging the android into your computer, then run adb devices to make sure the device is there. Then, run tcpip 5555 to change the android to tcp mode, which will allow debugging over wifi. Disconnect the android from the computer, and connect to it by typing adb 192.168.x.xxx, replacing the x's with your android's IP address. It should connect with no issues, as long as port 5555 is open, and both the android and your computer is on the same wifi.
Simple: Wireless ADB
One of the reason that I choose to run CyanogenMod on my testing devices is that it is a stripped down version of Android that has some additional developer tools, one of those being the ability to access the wireless portion of the ADB system.
As you are probably unaware, you are able to establish an ADB connection to your device over WiFi, however, if running a stock ROM, this requires root access, as it can be potentially harmful to your device, as Wireless ADB will work even over your cellular network, meaning that you could potentially receive apps from other insert carrier here's devices.
If you wish to run WirelessADB, here is a Play Store app that will help you to enable the feature on your device. Requires ROOT
It is as simple as connecting your device to your local WiFi network, (same one the development computer is connected to), enable Wireless ADB, and then running the following command on your computer:
adb connect 192.168.1.101
Replacing 192.168.1.101 with the IP address of your android device.
By establishing this connection, you can run everything just as you would if the device was plugged in via USB Cable.
I recommend ACRA (Application Crash Reports for Android ). It allows you to send crash reports to a number of different destinations. See https://github.com/ACRA/acra/wiki/BasicSetup

Categories

Resources