Trying to run teleop from android studio to driver hub

Hi, We are a rookie team. I have the same problem trying to sync my sample code to the driverhub in teleop mode. I am using Android Studio to sync from the teamcode. But my java class is not detected on the driver station. Any thoughts? I am using windows operating system.
It seems straight forward but it throws weird errors:

Execution failed for task ‘:FtcRobotController:compileDebugLibraryResources’.
A failure occurred while executing com.android.build.gradle.tasks.CompileLibraryResourcesTask$CompileLibraryResourcesAction
Could not isolate value com.android.build.gradle.tasks.CompileLibraryResourcesTask$CompileLibraryResourcesParams_Decorated@45ad95bd of type CompileLibraryResourcesTask.CompileLibraryResourcesParams
Could not resolve all files for configuration ‘:FtcRobotController:detachedConfiguration1’.
Could not resolve com.android.tools.build:aapt2:7.2.0-7984345.
Required by:
project :FtcRobotController
No cached version of com.android.tools.build:aapt2:7.2.0-7984345 available for offline mode.
No cached version of com.android.tools.build:aapt2:7.2.0-7984345 available for offline mode.
No cached version of com.android.tools.build:aapt2:7.2.0-7984345 available for offline mode.
No cached version of com.android.tools.build:aapt2:7.2.0-7984345 available for offline mode.

Possible solution:

Disable offline mode and rerun the build

Greetings!

Let’s first make sure we’re talking about the same thing. From your statement, it appears that you’re trying to deploy your Android Studio code directly to your Driver Hub - as in, you’ve got a USB connected to the Driver Hub, and are actively attempting to deploy to it. Is this the case?

Remember, THIS is a Driver Hub:

Your Driver Hub is just a “wireless dummy head” for your robot - the Driver Hub does not contain anything but the FTC Driver Station App. The Driver Hub connects wirelessly to the Control Hub, reads the software on the Control Hub, and presents a set of options based on what it sees on the Control Hub. When you make a selection and then initialize the program, all of the work is actually being done on the Control Hub and NOT the Driver Hub. Put another way, you can replace the Driver Hub with another Driver Hub or one of the specific Android Smartphones without any changes to your robot code. That’s because all of your Team Code lives on the Control Hub.

Remember, THIS is a Control Hub:

Now that you know this, know that you should be connecting your Control Hub (via USB or wirelessly) to your programming computer. Android Studio should be deploying your software to the Control Hub. In your Android Studio toolbar, your device selection should look like this:

image

Anything else, and it’s not going to work properly. BUT, you might have meant Control Hub, rookies often get the nomenclature wrong - it happens when everything is called a “Hub.” Haha.

Okay, now understand that it’s absolutely possible (but not useful) to deploy code to your Driver Hub (not that it will get you anywhere, since it will never be executed), and that’s not necessarily going to throw the error you’re seeing. And since you’re a new user, you don’t have the ability to attach images to this post to help you debug.

If all of this looks correct, and you’re still in this situation, it looks like something within Android Studio is confused terribly. In order to “fix” this problem, let’s follow some common “repair” steps:

  1. Clean your Build - Under the “Build” menu Item, towards the bottom of the menu, you’ll find the “Clean Project” command. Do this, and it will clean up your build (it’s possible something got built wrong and it’s gumming up the works. Starting clean and fresh may help). It may take a couple minutes to clean the build.

  2. Clear your Cache - Under the “File” menu Item, 3/4 the way down, you’ll find “Invalidate Caches…” option. Check both boxes, and click the “Invalidate and Restart” button. This will restart your Android Studio once the cache has been invalidated. If something updates at the wrong time you can end up with a confused system, and so this just resets the cache and forces Android Studio to “start with a clean slate” when it comes to compiling your project.

  3. Try again - Once you’ve cleaned your build, and cleared the cache and restarted, and reopened the project fresh, and you’ve got the correct project selected, and you’ve got the REV Robotics Control Hub connected, press the green arrow (or press SHIFT-F10) to build and deploy to your Control Hub.

If this doesn’t help, please contact me at:

ftctech@firstinspires.org

And I can try to help you directly. I need you to give me the steps that you took to get where you are.

(0) What version of Android Studio are you using? (Use “Help → About” to tell you)
(1) How did you download/sync the project to your computer?
(2) When you opened the project in Android Studio, did you upgrade any plugins like it asks you to (you should not do this).
(3) What is the path to the project you loaded?
(4) Are you trying to load any additional custom libraries?
(5) Take a full screenshot of your Android Studio screen with the error shown.
(6) Provide me with a full copy of the OpMode you’re trying to compile.

-Danny

Hi Danny,

Thanks for your response. I resolved the problem. I will referring to not being able to select the TeleOp program from the Driver Hub after connecting to the Control Hub Bluetooth. I uninstalled Android Studio and re-installed and everythign was taken care of. Appreciate your time in volunteering to respond to my question.
Best
Shifa

Fantastic!

I will assume you meant Control Hub Wi-Fi, since turning on the Control Hub Bluetooth is actually difficult (though some teams do manage to do it accidentally) and is not legal in competition. But no worries, glad you got it resolved.

-Danny

I am getting this same error. All our software is current. It was working fine one day and then the next started complaining about Gradle and would not build. It would say in the android studio app as a toast message, Gradle build failed some debugging features may not work, check for updates.

So we did, we already had the latest versions showing in Rev Hardware Client so all that was left to check was Android Studio itself. It was out of date and so was Gradle. We reinstalled and then started getting the error in the build output that is shown in this topic.

We cleaned our build, cleared our cache and tried again, to just receive the same error about aapt2 files being missing from the cache. I’ve now uninstalled and reinstalled android studio at least a dozen times. it reinstalls gradle and looks like it should be fixing everything up, but still the same errors are displayed in the build output.

What version of Android Studio are you running? If you’re using the latest version - LadyBug - there’s a big problem using that version of Android Studio. They completely changed how Android Studio works, and it requires a bit of work to be compatible with the FTC SDK. Check out this post here:

https://ftc-community.firstinspires.org/t/unable-to-connect-to-control-hub-in-android-studio-ladybug/1132

-Danny

Yes, its ladybug. Thanks for the link to the article. Its interesting though because I only upgraded afternot being able to build in koala due to different Gradle errors that suggested upgrading my software.

I emailed all our details to ftctech@firstinspires.org if you want to see more background. I will go through the article you provided. Thank you.