• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

com.google.android not found

I'm new to Android, but old to programming. I'm using Android Studio 3.2.1. I'm trying to do some UART things as described at https://developer.android.com/things/sdk/pio/uart .

When I try to code this line:
PeripheralManager manager = PeripheralManager.getInstance();​
The word "PeripheralManager" is red, meaning it's not found. I think what I need is this line near the top of my code:
import com.google.android.things.pio.PeripheralManager;​
it highlights "android" in red. When I mouse over, I get a popup message "cannot resolved symbol 'android'".

I think this is because I need to add something to my project or environment, and THIS is what I can't figure out. I've seen other posts that get close, but they don't seem to apply correctly.

Please remember, I'm using Android Studio 3.2.1. When I click on Tools / SDK Manager, and look at the SDK Tools tab, I see some "Google..." items. I installed "Google Play services", but that didn't fix the problem. "Google Repository" is already checked. Just now I checked ALL of the "Google Play..." items, but it still didn't help.

Exactly HOW do I make this work? Detailed instructions are greatly appreciated...
 
Thanks, @LV426 . That got me further, but not all the way.

Successful portion: I already had all of the things mentioned at the link you provided, except for the build.gradle compileOnly dependency. When I added that to my existing project, it built.

Failure portion: However, when I tried to run it on my tablet, I got this error:
upload_2018-12-13_10-6-44.png


Sidetrack: Since this was with an existing project that was not an Android Things form factor, I created a brand new project that was. Having done nothing to this initial "Hello World" strictly Android Things form factor project, I got exactly the same error. So the error seems to not be about my original project. Note also that my tablet is Android 7.0. But when I made yet another Android Things project, selecting Android 7.0, I still got this same error. While the Android version might be an issue later, it seems to not be the reason I got this specific error. So I'm going back to my original project...

Moving Forward: So what do I do now? I clicked OK on multiple attempts, but that didn't fix the problem. Is it that I need to install something that's missing from my tablet? Note that I'd rather not upgrade the OS, for business and technical reasons. Is this missing library problem about it missing from the tablet or about it missing from my development computer? Over at https://github.com/androidthings/new-project-template/issues/1 I read "Apps that use the Android Things library can only be installed in Android Things device." Well, I'm using a regular Android Tablet which I assume is not a "thing".

What I'm really trying to do: I need to read/write a USB-to-Serial adapter. All I'm trying to do is open the device as a serial port. I'm currently trying to follow the advice at https://developer.android.com/things/sdk/pio/uart#usb-ttl where it uses PeripheralManager. As in the OP here, PeripheralManager has let me to the Android Things. Should I be getting PeripheralManager in a different way? Or should I be trying to access the serial port in a totally different way? I'm starting to think I'm barking up the wrong tree and need to search all over again for "Android Usb-to-Serial"...

[EDIT: I am currently starting over, trying to do this: https://github.com/mik3y/usb-serial-for-android ]
 
Last edited:
"Apps that use the Android Things library can only be installed in Android Things device."

Well there you go, that's your issue. It's a deployment problem. Looks like an Android Things app can't be run on a usual mobile device.

What I'm really trying to do: I need to read/write a USB-to-Serial adapter. All I'm trying to do is open the device as a serial port. I'm currently trying to follow the advice at https://developer.android.com/things/sdk/pio/uart#usb-ttl where it uses PeripheralManager. As in the OP here, PeripheralManager has let me to the Android Things. Should I be getting PeripheralManager in a different way? Or should I be trying to access the serial port in a totally different way? I'm starting to think I'm barking up the wrong tree and need to search all over again for "Android Usb-to-Serial"...

So are you running this on a mobile phone? I don't think you need to be building a 'Things' app for this. I'm pretty sure there are examples out there showing how to implement serial comms with such an adapter.
 
LOL ... and none of those examples work yet! I tried https://github.com/mik3y/usb-serial-for-android . I let AndroidStudio do what it wanted, installing SDKs 22 and 19. Then, eventually I ran into a hard stop with this error:
upload_2018-12-13_12-40-53.png

I don't know what or how to do this.

I noticed this github project hasn't been touched since 2015. So I started looking for newer advice. Might you, @LV426, be able to advise me on the above?

Otherwise, I also need to make sure the USB-to-Serial is indeed showing up as a serial device. (It's actually a CANable USB device. It shows up as a serial port on both my Windows 10 machine and my Ubuntu VM. So I am hoping it will also show up as a serial port on this TECLAST P80H Android Tablet.) If it does *not* show up as a serial device, then that would be because a compatible driver isn't built into my tablet's OS (Android 7.0). This *might* make all the serial port effort a waste. Although perhaps not, if the github link above takes that into account. Otherwise from that otherwise, if it *does* already show up as a serial port, then maybe I don't need the github link above but instead just some simple serial port access examples...

At the moment, I'm trying to get the tablet rooted in order to run ES File Browser, with which I have experience, to see if the /dev/ folder contents change when I plug in the CANable USB device...
 
Please note that I've gone back to trying https://github.com/mik3y/usb-serial-for-android . After going around in circles a bit, including finding https://stackoverflow.com/questions/44546849/unsupported-method-baseconfig-getapplicationidsuffix and trying a bunch of wrong gradle versions, I found that my original MyFirstApp used gradle version 3.2.1. I wrote that on top of usb-serial-for-android-master's build.gradle. Then after a bunch of other confusion, I finally got the usbSerialExamples of usb-serial-for-android to run on my tablet. So far so good... but not for long.

Using an USB OTG cable, when I plug in an actual USB-to-Serial adapter that I know has an FTDI chip in it, the usbSerialExamples app indeed sees it as Vendor 0403 Product 6001.

However, when I plug in my CANable device, it does NOT show up. The usbSerialExamples app is not seeing it. I know from prior efforts that the tablet can see it as a usb device with vendor AD50 product 60C4. But for some reason, usbSerialExamples isn't seeing it. I'm not sure why. I'm hunting through the code now to see if there's something specific that selects some usb hardware and not others. But t would sure be nice to get a better answer from this forum...

EDIT: Hmmm.... Each time I re-plug in the FTDI USB-to-Serial adapter, I get a pop up window asking me "Open Serial Example when this USB device is connected?" I suspect that this is the Android OS asking this, and *not* the usbSerialExamples program itself. This implies that the Android OS is recognizing the FTDI USB-to-Serial adapter. Contast this to when I plug in the CANable board. I do NOT get any such message. The USB does get found by my original usbmanager-based software. But the Android OS itself is *not* asking me to do anything. Does that mean that the usb hardware is being recognized, but that NO DRIVER is being loaded for it? In other words, when the FTDI USB-to-Serial adapter is plugged in, an associated driver is loaded (aka connected to the device). But when the CANable board is plugged in, it is NOT finding a driver for it. Note how this is in contrast to what I've seen happen on Windows 10 and Ubuntu (VM) for this board.

EDIT: I find in the source code for usbSerialExamples that it has 5 different drivers actually built into it. Each of these 5 drivers has a single .java file containing a getSupportedDevices function, that gets called by a probe function. The getSupportedDevices function returns a list of vendor id's and product id's that come from a file called Usbid.java. In this Usbid.java file is a complete list of all the vendors and products that usbSerialExamples can handle via its 5 built-in drivers. SOOOO.... my CANable board's vendor id and product di is NOT in the list. I don't know if the CANable board is compatible with one of the 5 drivers already existing, or not. I sure don't want to have to write my own driver in this case... Where oh where do I go now????

EDIT: A compatible driver is mentioned at https://groups.google.com/forum/#!topic/stm32_en/0J30h0BmOzY and I find the source code at https://github.com/STMicroelectronics/STMCD_Android_BasicGpioDemo and located at https://github.com/STMicroelectroni...c/main/java/com/hoho/android/usbserial/driver with files of interest STM32SerialDriver.java and updated UsbId.java . They are hard coded for vendor 0x0483, which is different from the CANable board's 0xAD50. I've modified the edit to UsbId.java to change the STM32SerialDriver.java's used vendor ID to 0xAD50, as well as adding a product ID for 0x60C4. This is in hopes that the CANable remains fully STM32 driver compatible, even though the vendor ID and product ID got changed...
 
Last edited:
SUCCESS! The info on my prior post, the last "EDIT", led me to where I am now successfully seeing live CAN bus data traffic on my Android Tablet, via the CANable (CANtact) USB board, via the STM32 driver incorporated into the example usb-serial-for-android project. This was done *not* as a "thing" and *not* using PeripheralManager as mentioned in the OP.
 
Thanks.

I don't yet know jack about Android or Java, but my 40+ years of experience allows me to plow through it!

Next. What's with "LV-426" and the Alien alien? Got it... You realize, I saw the original Alien movie when it opened! (...wait a minute... "Alien", not "Aliens". I saw *both* when they opened. I guess LV-426 didn't show up until the second movie. The first movie was far, far, far better than the second one.)
upload_2018-12-14_15-17-59.png
 
Both films are excellent for different reasons. In the first, Scott pulled off a cinematic masterpiece, given the lack of special effects and technology. And you know why that film was so scary? Because you hardly ever saw the creature. The tension was unbelievable. Over time it's lost some of it's impact, and has become a bit dated in appearance. But at the time, the chest bursting scene in particular, was utterly shocking. I find the whole xenomorph lifecycle fascinating, and terrifying. I don't know who came up with the idea for that progression of developmental states, but they deserve some kind of award. Maybe they got it. There really hadn't been anything created like this before, or anything to rival the novelty of it ever since.

The sequel movie 'Aliens' was IMO equally superb, if not better. One of the few sequels that matches, or surpasses the quality of the original. Cameron managed to honour the first movie's atmosphere, even continuing the tension. It really is relentless from the initial entrance to the facility, right through to the spectacular finale.
Unfortunately the quality was not continued with the subsequent movies, and it degenerated into a boring parade of CGI gore fests, with poor story lines.

I bet you wished you never asked now? :)
 
no, not really. Since it's been 30-40 years, it might be that #3 was the one I found so poor. That would make our assessments similar. (No, I don't think I've seen any of them again since opening. I might have seen the original half a dozen times, however. I don't recall for sure, but the thought seems familiar.)
 
Yes #3 'Alien 3' was passable, although not as good as the previous two. After that it became utter garbage, and I can no longer bother with the franchise.
Ridley Scott tried to tie things together with a link film called 'Prometheus', which attempted to explain the origins of the Xenomorph. I did have high hopes for that film, but it disappointed on many levels. The sequel film 'Covenant' was even worse.
 
Well, my departing comment is that Alien (#1) was the FIRST major film to depict the spaceship as dirty. ALL prior major films had clean spaceships. This was a huge sea change.
 
Back
Top Bottom