Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

OnBot SDK is different than Android Studio SDK #715

Open
stemrobotics opened this issue Jun 24, 2019 · 13 comments
Open

OnBot SDK is different than Android Studio SDK #715

stemrobotics opened this issue Jun 24, 2019 · 13 comments

Comments

@stemrobotics
Copy link

I have example for code for students that compiles without problem in Android studio but does not compile in OnBot due to differences in the SDK libraries. For instance, the items hardware.Servo.MAX_POSITION & MIN_POSITION is not found on OnBot but resolves correctly in AS. I have found several of these cases. What is happening here and how would I correct this situation so that my code set works in both environments?

@NoahAndrews
Copy link

NoahAndrews commented Jun 24, 2019

This is a known issue that is being tracked internally. It's useful to know that someone has run into it in the real world.

@stemrobotics
Copy link
Author

stemrobotics commented Jun 25, 2019 via email

@Windwoes
Copy link

So what does tracked internally mean?

It means they have an issue open about it in their private development repository.

@gearsincorg
Copy link
Collaborator

One reason that you sometimes see differences between OBJ and AS is that some libs do not fully update when you update the App version.

This problem is corrected by completely resetting the OnBotJava environment, which clears out any old libs.

Note: Before you do this, make sure you have backed up / downloaded any opmodes that are on your phone, that you want to keep. All code will be deleted from the phone during the reset. Just select them on the file tree, do a right click, and select download.

Easy steps:
Connect your PC to the phone, and bring up the OnBotJava page.
Find the Settings (GEARS) icon at the upper left of the page. Click it.
Scroll down and expand the "Advanced Settings" section
Click on the Red RESET button (after backing up your code)
Since this step clears out all your programs, you are prompted TWICE if you really want to do this.

Once it's done, I'd close out the RC app (swipe it off) and restart it.
Now reconnect your PC, Upload you java files, and try rebuilding.

@stemrobotics
Copy link
Author

stemrobotics commented Jun 26, 2019 via email

@David10238
Copy link

I experienced this issue in January at our league championship. Trying to write a teams auto I had issues with tensorflow not working on OnBot.

@Windwoes
Copy link

Windwoes commented Jun 26, 2019

Based on the explanation that there is a pre-compiled form of the SDK as part of the controller components, clearing things out and restarting the same controller apk or downloading a new apk via AS compile (from the existing SDK), the same pre-compiled components would be downloaded.

Well, not exactly, because the precompiled part used by OnBot (onbotjava-classes.jar) is shipped as a "resource" file in the APK and then extracted to /sdcard/FIRST for use by javac later. So if the new version of the SDK sees that the JAR already exists and doesn't overwrite it, then you have a mismatched version.

It seems there needs to be a fix to the pre-compiled SDK component in order to resolve this problem.

Based on Noah's response that this is a bug tracked in the private development repository, that appears to be correct

It appears the pre-compiled components are not rebuilt when you compile in AS, but are built when the SDK is prepared for release and do not change after that.

Correct

@stemrobotics
Copy link
Author

stemrobotics commented Jun 26, 2019 via email

@cmacfarl
Copy link
Collaborator

Thank you Richard, there's a problem with the generation of the the stubjars jar wherein public static fields were getting inlined by the javac compiler. A fix, to generate code that will prevent the inlining is in progress and should appear in v5.1 which is currently targeted for late July.

In the meantime, the stubjars software is a utility located here: https://github.com/dmssargent/StubJars That software generates the jar file that is subsequently packaged with the released SDK.

Note the develop branch has the commits that in process for inclusion in the SDK.

@dmssargent
Copy link

If you need an immediate workaround, reflectively accessing the fields in question will still function just fine.

And although I will admit it really may not be obvious (and it will be gross), the StubJars library and the ftc_app contain enough information, such that you can fix the error until we release v5.1.

I might write a script to automate the regeneration and correct update of the OnBotJava SDK if the need is great.

@stemrobotics
Copy link
Author

stemrobotics commented Jun 27, 2019 via email

@stemrobotics
Copy link
Author

An related question for the developers: I am wondering how we go from current release of 4.3 to the coming 5.1? What happened to 5.0?

@cmacfarl
Copy link
Collaborator

5.0 is a prerelease for the Control Hub pilot purposes. It should be up on ftc_app in the next week or so. There are a couple new interesting features, most notably, a Java preview pane for the Blocks editor, and an offline mode for Blocks. But the big change is full support for the Control Hub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants