Android Things Emulator - android-emulator

I was wondering if there is a way to set up an emulator in Android Studio using the system image that can be downloaded from the Android Things website.
I already have a Raspberry Pi 3, but I always have to plug it into the tv which is not very practical at all. That's why I'm asking.

You don't need to plug the Raspberry Pi into a TV for it to work for Android Things. The Pi will still work without a HDMI cable connected.
If you do want to create a UI you can use a normal emulator and in your AndroidManifest.xml add that the Android Things SDK is not required:
<application ... >
<uses-library android:name="com.google.android.things" android:required="false"/>
... activities etc
</application>
android:required="false" is the key
You just have to make sure, that the code that is running on the emulator is not using any of the Android Things java imports at that time.
One way of making sure the Android Things SDK code is kept separate from your core application (meaning you can run your core app on an Emulator) is to separate the code with Hexagonal Architecture, it's a little off topic for your question but it would allow you to avoid the need to have a "raspberry pi emulator" you can read more about this here: https://www.novoda.com/blog/testing-android-things/

In my opinion it is not possible right now. To early stage, too much hardware dependant (GPIOs etc). If it would be possible at this stage good guys at Google would gladly provide some solution to do that.

If you just want to view the screen you could try Vysor which is Chrome app that works via adb. If your RPI is connected via adb it should work. You can get it here: https://www.vysor.io/.

Related

can i create android and ios applications with flutter without android emulator , with just flutter sdk and vscode and browser

I learned dart and I want to access flutter, but I was surprised by android studio because my computer is weak.so,can i create android and apple applications with flutter without android emulator , with just flutter pack and vs code and browser
If you only work with simple UI widgets yes you can use the embedded development tools within the browser to get the dimensions of the device you working on like so
But, most of the cases there are libraries work differently according to the platform so it might work with the web but not with android or iphone and you can not test it without the actual device.
And yes VS code is a very good with flutter and might be better than android studio but it won`t make the difference you expected, in my opinion what make it faster is to use an actual device for testing and not using the emulator, also don't use a lot of application along side with the IDE, like if you are using spotify, listening to youtube video or following a tutorial just use your phone because browsers as bad as emulator.
You can use a text editor and the command line tools to build flutter apps and test them on a real device.
I wouldn't recommend it though.
You could give VSCode a try as it is a more lightweight environment.
Your computer should handle testing on a real device, which requires only a USB cable. Accessing the application in the browser would probably eat a lot more memory. You can read about how to use the real device with flutter here.

having trouble setting up flutter in vs code

I have trouble in setting flutter and running an app on a real device in vs code. I want to run my apps on physical device and I do not want to use emulators. Is it going to be possible?
Yes, this is very possible. In fact, many flutter developers use physical devices in order to test features like Maps,Camera, etc. I always recommend following a video tutorial to set up environments for development. But you should try the following:
First of all, I recommend the flutter docs https://flutter.dev/docs/development/tools/vs-code to set up vscode.
After this, all you need does not have anything to do with VSCode any longer. You should check https://flutter.dev/docs/get-started/install/windows to connect a physical device.
Im not sure if you have already setup flutter on your machine to start with. If you haven't use this link how to install flutter
the next part is easy just install dart and flutter extensions in vscode.
walla!

Is there a way to access or control raspberry pi GPIO pins using flutter app running on android things?

I am trying to build a project based on IoT with flutter, android things, and raspberry pi. For that, I need to access raspberry pi GPIO pins through my flutter app.
Firstly I have installed android things os onto the raspberry pi and connect a display to it. After that, I have to build a flutter app and uploaded and it's working perfectly but now I need to control GPIO so I have googled it but found nothing except the rpi_gpio dart library which can access raspberry pi GPIO pins but apparently it is not working on flutter dependencies.
So is there a way then suggest me so that I can complete my project.
I know that this posting is a bit old, but another option might be to use the pigpio library. It has a feature that pushes the entire API out to a network connection (this feature is called "pigs").
I struggled trying to use FFI to interface with the C-based pigpio library on a Pi Zero W. Then I was reminded that Dart support for the older, less powerful devices had been dropped from Dart, so I was stuck with no graceful solution until I tried out pigs. The pigs interface completely removed the headaches associated with either FFI on Dart or JNI in Java and just made it a happy Socket interface over the network. I was doing an I2C interface to a temperature/humidity sensor. Pigs should also make a browser-based Flutter app happy as long as you deal properly with the single origin requirements.
Here's a link to pigs on pigpio
I've recently seen a Dart library for the Raspi's GPIOs. As Dart is the underlying language of Flutter, shouldn't you be able to then use the pins by importing this library?
https://pub.dev/packages/rpi_gpio
As far as I know there is no plugin for Flutter to interact with Peripheral IO. Given Flutter's nature of targeting multiplatform and Android Things being very specific, I do not think something like that will exist.
Most IoT applications have quite simple logic, so it should be reasonable easy to write the UI on Android directly (given you are not planning to release in any other platform anyway.
Your other option would be to create a Flutter plugin for GPIO and port it only to Android, but IMHO it will be harder to do than just code the UI of the app directly on Android.
There is now another FFI-based gpio on RPI Dart package called gpiod.
Its use is described in this article on running Flutter on a RPI based device.

Using IOS device to develop an Android game

as the title described my issue , my question seems to be dumb a little ; But because I don't own an Android device , But I published Android Apps using Genymotion Emulators. And I tried to download Unity Remote App on my Emulator but it does not work that well.
So my question here is : Can I use my iPhone device to test and develop the game that will be published to android users?
Yes, it is possible to do that since the Input methods being touches do not differ. The only thing you have to keep in mind is the wide range of resolutions used by android devices.
You can use can use your iphone for testing but jusst for the logic. The performance and resolutions are very different for android. Also if there is any platform specefic code you have written in unity then you have to take care of that.
Besides using your iPhone you can generate an APK from unity and install it on the android emulators to test.

Custom Android Emulators

I currently have an Android app on the Android Market. One of it's main purposes involves detecting incoming calls. Unfortunately, some phone models don't seem to be detecting this correctly. The version of Android isn't the problem (other phones with 2.1 and 2.2 work fine), so I'm wondering if the phones have something unique about them.
Because the main phone I've had problems with is the Epic 4g, I was hoping to get an emulator running simulating the phone. Is it possible to do this? I don't know anyone that personally has that model of phone, so this seems like my only option to debug the issue.
Thanks!
I've found this for Motorola Phones
which has helped me.
Generally, the emulator is based on QEMU, so it can be configured deeply. But thats not very useful as it is hard to get the actual hardware specs of any specific device as long it's developing company don't like to talk and share their secrets and flaws.
This said, it would be quite easy for an phone company insider to set up an exact emulator but very hacker style to set up for ourselves, needing days of investigation on the actual phone to check out its hardware details.