Where to Place Code in Ftc Androdi Studio to Upload
Using Android Studio¶
Android Studio is an integrated development environment (IDE) for Android app development based on IntelliJ. Information technology compiles your code to an apk which is then installed onto the Robot Controller: either the Control Hub or a legal Android phone.
Downloading Android Studio¶
If you've already downloaded Android Studio, you can move on to the next step, which is setting up the SDK.
The steps to download and setup Android Studio are:
-
Check to make sure your organization meets the necessary requirements
-
Install the latest version of Android Studio from https://programmer.android.com/studio/alphabetize.html
-
Run the executable, follow the setup sorcerer, and use whatever and all recommended development kits
Setting up the SDK¶
At present that you accept Android Studio installed, you're going to desire to use the electric current flavor'southward SDK (software development kit) where you will create your team'due south code.
Downloading the SDK¶
The SDK is publicly released to a GitHub repository every season. The current season's SDK tin can be plant in the FtcRobotController repository.
Downloading the Zippo¶
-
When you lot're at the repository, click the dark-green "code" button. Then, select "Download ZIP."
-
Then, save it to the desired location in your computer.
-
Later it is saved, excerpt the contents of the ZIP and identify them into whatever desired location. You should see the contents of the SDK within of the folder location.
From the Control Line¶
-
Install git
-
Open the last (probably bash) in the desired resource location.
-
Use
$ git clone https://github.com/FIRST-Tech-Challenge/FtcRobotController.git
Opening the SDK on Android Studio¶
-
Open up Android Studio. If you have some other projection open up, close it.
-
Check for updates. Click on the "configure" dropdown and select "cheque for updates." If y'all practise not accept the latest version, download the updates.
-
Select "Import Project." Navigate to where you take the SDK saved on your estimator. Cull the directory that has the Android logo.
-
Modify to project view. In the meridian left corner should exist a dropdown that allows you to alter the mode you are looking at your projection.
-
Expect for Gradle to complete the build. This indicator should be located at the bottom of the window by default.
Layout¶
Android Studio can look intimidating at first glance, but there are only a few features needed to employ it properly.
Creating Classes¶
The get-go matter to note in the project view is the dropdown with the name of the project. If y'all drop that down, you will see all of the Gradle files and directories. Navigate to the TeamCode binder. In the teamcode folder you will see an org.firstinspires.ftc.teamcode package.
This is where you lot volition create your lawmaking for the robot. To create a new Java class, right click on the package, select New, then choose "Java Form."
Alternatively, you tin select the "Package" selection if you desire to create a subfolder for organization purposes. Then, y'all can create classes in those packages.
Concluding and Logcat¶
Nigh the bottom left of the application, you volition find tabs for the local terminal and logcat. These are useful tools for working with your programme.
Some useful data on using the logcat can be found hither.
Note
You can build your program through the commandline via the local terminal. Click on the terminal tab and so input gradlew :TeamCode:clean :TeamCode:build . This volition delete the previously compiled files and build your TeamCode module.
Installing Your Program¶
To install your program onto the Robot Controller, you will use the play push located most the top right of the application window.
Next to it you volition come across a dropdown for devices. When you lot connect your Robot Controller to your computer (using the correct cablevision), the device should appear in the dropdown after some time. Then, click the play button and your program will install onto the device.
If you run into any problems with this process, refer to the official REV documentation. Some useful pages from the REV site are:
-
Troubleshooting the Control Organization
-
Deploying Lawmaking Wirelessly
If you're however stuck yous can ask for help in the FTC Discord.
Gradle¶
Gradle is a build tool for software evolution. In the telescopic of FTC, it is used to build and manage dependencies for your projection.
When you update any of your Gradle files y'all will demand to perform a Gradle sync, which syncs your project to the changes and rebuilds it. In your build.common.gradle , you will notice information for how your robot controller application is built.
Rebuilding¶
You can rebuild your project easily with the build dropdown.
To rebuild from a clean project, printing the make clean project option. This removes quondam compiled files from your projection and then y'all can completely rebuild your projection. It clears any production files, generated files, etc. This is useful for making sure old artifacts don't break annihilation when y'all build your lawmaking. When y'all next build your projection, information technology will do and then from scratch with no old compiled files to which information technology can refer. To rebuild your project, printing the rebuild selection.
Invalidate and Restart¶
Sometimes you lot can get errors after moving things effectually, refactoring, etc. The first step is to try cleaning the project and doing a rebuild. If this doesn't piece of work, you lot might have confused Android Studio because information technology caches information about your projection structure.
The well-nigh common way to prepare these errors is to practise an invalidate and restart. In the file dropdown, there will exist an option for this and and then you will choose Invalidate and Restart. This clears the enshroud and restarts your Android Studio, which then should perform a Gradle rebuild.
Calculation Dependencies¶
If you lot want to add dependencies to your project, you can do so in the build.gradle file in the TeamCode directory.
There should be a dependencies block at the lesser of the file.
// Include common definitions from above. apply from: '../build.mutual.gradle' employ from: '../build.dependencies.gradle' dependencies { implementation project ( ':FtcRobotController' ) annotationProcessor files ( 'lib/OpModeAnnotationProcessor.jar' ) } Some dependencies require changes to your other Gradle files. Brand sure to read the installation instructions for whatever dependency you desire to add.
Next, you add a line in the dependencies block to implement the dependency. This is mostly washed with implementation 'com.package.name' .
dependencies { implementation project ( ':FtcRobotController' ) annotationProcessor files ( 'lib/OpModeAnnotationProcessor.jar' ) implementation 'com.package.name:name:version' } Refer to the instructions of whatever library you are using for the right package proper noun and version.
Finally, perform a Gradle sync.
Upgrading to Java eight¶
By default, the SDK's version of Java is set to 7. Coffee 8 is also supported. You might want to upgrade your version of Java from 7 to 8 if y'all want to use features such as lambdas or generics. Some libraries may too require you to change your Coffee version.
To upgrade to Java 8, navigate to your build.mutual.gradle file. Whorl downwardly until yous find this cake:
compileOptions { sourceCompatibility JavaVersion . VERSION_1_7 targetCompatibility JavaVersion . VERSION_1_7 } Change the 7 to 8 , like so:
compileOptions { sourceCompatibility JavaVersion . VERSION_1_8 targetCompatibility JavaVersion . VERSION_1_8 } Then, perform a Gradle sync.
Android Debug Bridge¶
Note
On macOS, Linux, or using PowerShell yous volition have to change any commands that start with adb to start with ./adb if you are in the platform-tools directory.
Logcat¶
Logcat is extremely useful for debugging issues with your lawmaking at runtime or figuring out what went incorrect. For example, if your app activity crashes and you pull upwards the log seeing 5000 lines of something similar this:
then, you know that there is infinite recursion somewhere in your programme.
To employ logcat, plug in your device (or connect via ADB). Then, select the app you desire to view the logs for. Your window should await similar this.
If you have an consequence you don't understand, yous can impress a PDF (pick 5) of the log and ask a question in the FTC discord.
Wireless Communication¶
Android Debug Span (ADB) is a command-line tool that allows for wireless communication betwixt the robot controller (phone or Control Hub).
ADB should come with the platform tools in Android Studio. Navigate to your local.properties file in the root of your project and you should run across a path to the Android SDK on your computer, such as C:\Users\Woodie\AppData\Local\Android\Sdk . Then navigate to platform-tools and an application called adb should exist in that location. To use information technology, open up CLI (like PowerShell or control prompt) and run either adb devices or ./adb devices .
For more data on ADB, you can look at the developers page.
Setting Up ADB¶
-
Ensure USB debugging is enabled on your device and it is in programmer mode.
-
Make certain yous have ADB installed. If you do not, follow the instructions at this link
Note
You can apply logcat via ADB with the adb logcat command. This is extremely useful for debugging equally information technology allows you to look at the logs wirelessly which saves time. Think, logcat is the all-time way to debug your software.
Add together ADB To PATH¶
Adding variables to PATH:
-
Windows
-
Linux/Unix (bash)
-
macOS (zsh)
If you want to employ ADB from any directory, add it to PATH. Follow an online tutorial for adding to PATH and set the PATH to the platform-tools directory. Once you do that, you tin can run ADB commands from anywhere on your system.
Connecting to a Telephone Wirelessly¶
-
Plug the robot controller phone into your figurer.
-
Run the command
adb devicesin theplatform-toolsdirectory and run across if the phone shows up. -
Run
adb usband and soadb tcpip 5555. You can then unplug the phone. -
Connect to the same WiFi network the device is either hosting or on. The WiFi direct network created by the phone should be called "TEAMNUMBER-RC" or some small derivation of that. Information technology may include extra letters if you accept multiple devices per team. Refer to RS01 in Game Manual Part i for farther details on the network naming scheme.
-
Connect to the phone using
adb connect 192.168.49.i:5555. If this doesn't work, recheck the IP address of the phone and try over again with that IP accost if it is different.
Connecting to a Control Hub Wirelessly¶
-
Connect to the WiFi hotspot hosted by the Command Hub. The hotspot should be chosen "TEAMNUMBER-RC" or some minor derivation of that. It may include extra letters if you lot take multiple devices per team. Refer to RS01 in Game Manual Part 1 for farther details on the network naming scheme.
-
In one case you lot're connected to a Control Hub'southward network, you just need to connect to it using
adb connect 192.168.43.1:5555.
Once a connection is established, it should appear in the device dropdown in Android Studio.
Wireless Configuration¶
You tin can gear up a configuration on the Driver Station or Robot Controller similar usual. However, you can too create a valid configuration XML file in TeamCode/src/principal/res/xml . Y'all can find your configuration files in the /sdcard/Start binder equally an XML file with the same proper noun as the configuration.
To get these XML files wirelessly, you tin use adb pull /sdcard/Showtime/config.xml /fully/qualified/path/res/xml .
If a valid configuration XML file is in res/xml it volition show upward as a configuration you tin can use for the robot when you lot push information technology to the Robot Controller or a Control Hub.
SDK Managing director¶
You can discover the SDK manager in the top right corner of your Android Studio.
Accepting Licenses¶
If you get a warning complaining about licenses non being accepted, follow these steps:
-
Become to the SDK director and under SDK Platforms.
-
Select the version with the API level specified by the warning.
-
Click "Apply" and wait for the components to install.
-
Once this finishes, press "Terminate," so "Ok." Expect for Android Studio to index if it is.
-
Restart Android Studio.
Source: https://gm0.org/en/latest/docs/software/using-android-studio.html
0 Response to "Where to Place Code in Ftc Androdi Studio to Upload"
Post a Comment