Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Incompatible minimal SDK version set by default #4955

Closed
AJenbo opened this issue Nov 14, 2021 · 18 comments
Closed

[Android] Incompatible minimal SDK version set by default #4955

AJenbo opened this issue Nov 14, 2021 · 18 comments
Assignees
Milestone

Comments

@AJenbo
Copy link
Contributor

AJenbo commented Nov 14, 2021

Since HIDAPI was required in SDL 2.0.9 (d2042e1) it has not been possible to run on Android older then 4.3 (SDK 18), but the minimum SDK still indicates 16 (Android 4.1).

Because of this discrepancy installations on Android 4.1-4.2 are allowed by launching the app will result in the following error being presented to the user:
image

I'm not sure how possible it is to make all the HIDAPI code conditional on the system SDK version. But considering how old Android 4.2 is at this point (2012). Support for the OS having ended about 5 years ago, and play services having been discontinued for it (and 4.3). And the user base being less then 1% of Android installation. I suggest simply bumping the minimal required SDK to 18 (Android 4.3) to resolve the issue.

minSdkVersion 16

@slouken slouken self-assigned this Nov 14, 2021
@slouken
Copy link
Collaborator

slouken commented Nov 14, 2021

We just removed the dependency on libhidapi.so, can you check and see if this is resolved in the latest snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip

AJenbo added a commit to AJenbo/SDL that referenced this issue Nov 14, 2021
@slouken slouken added this to the 2.0.18 milestone Nov 14, 2021
@slouken slouken added the waiting Waiting on user response label Nov 14, 2021
@AJenbo
Copy link
Contributor Author

AJenbo commented Nov 15, 2021

We just removed the dependency on libhidapi.so, can you check and see if this is resolved in the latest snapshot? http://www.libsdl.org/tmp/SDL-2.0.zip

I upgraded our project to the linked version, did did progress further but then failed to locate libbzip2 which we depend on. A bit odd since it should have been part of Android since 1.6.

Considering that even 4.3 only makes up 1 out of 9600 users. It's hard to justify the effort in getting things working for an even older version :)

The android-project in SDL doesn't build out of the box, so haven't tested a bare bones app. I can maybe look in to that later.

@AntTheAlchemist
Copy link
Contributor

My builds that include HIDAPI have been running on 4.1 no problem for a while now. I'd rather we didn't raise the minimum to 18. It doesn't need to be.

@slouken
Copy link
Collaborator

slouken commented Nov 16, 2021

I just updated the SDL android project so it builds out of the box in 7ad6435.

I ran the following and verified that the simple test program works on Android 12:
cd build-scripts
./androidbuild.sh org.libsdl.testwm2 ../test/testwm2.c

@slouken
Copy link
Collaborator

slouken commented Nov 16, 2021

I'm going to close this issue since hidapi is no longer used. Please open new issues for any problems with older or newer SDKs and devices.

Thanks!

@slouken slouken closed this as completed Nov 16, 2021
@slouken slouken removed the waiting Waiting on user response label Nov 16, 2021
@AJenbo
Copy link
Contributor Author

AJenbo commented Nov 16, 2021

I just updated the SDL android project so it builds out of the box in 7ad6435.

Cool will upstream all our other fixes then :)

@AntTheAlchemist
Copy link
Contributor

@AJenbo how are you getting on now with the latest source with android versions under 4.3? I'm testing on a physical 4.2.2 device and apps run ok but I'm getting a big mess when it comes to game controllers. Would this be because HIDAPI requires 4.3+?

Controllers often not being recognised when plugged in. When they're eventually picked up they're having a duplicate joystick-only version "Sony Computer Entertainment Wireless Controller" for PS4 controllers and "Microsoft X-Box 360 pad" for Xbox. Unplugging doesn't produce remove events. Rumble doesn't stop. Bluetooth connected controllers don't produce any events.

Other Android versions work as expected, sort of.

@AntTheAlchemist
Copy link
Contributor

I guess disabling HIDAPI with a hint if SDK is < 18 is a workable solution? Sorry, I'm still learning and understanding about this.

@slouken
Copy link
Collaborator

slouken commented Nov 22, 2021

I guess disabling HIDAPI with a hint if SDK is < 18 is a workable solution? Sorry, I'm still learning and understanding about this.

Yes, this seems like a good solution. Are you guys able to test this?

@slouken slouken reopened this Nov 22, 2021
@AntTheAlchemist
Copy link
Contributor

Yes, this seems like a good solution. Are you guys able to test this?

Already did and it seemed to have the desired effect. Obviously losing all the features HIDAPI offers, along with the bugs and crashes that happen on SDK < 18.

@AntTheAlchemist
Copy link
Contributor

AntTheAlchemist commented Nov 22, 2021

Is it possible to set this hint in the manifest file using similar version-conditional syntax recently added to WRITE_EXTERNAL_STORAGE?

@slouken
Copy link
Collaborator

slouken commented Nov 23, 2021

Yes, this seems like a good solution. Are you guys able to test this?

Already did and it seemed to have the desired effect. Obviously losing all the features HIDAPI offers, along with the bugs and crashes that happen on SDK < 18.

Can you submit a pull request for this? I don't have a way to test it, and I'd like to make sure we're putting tested changes in for 2.0.18.

thanks!

@slouken slouken added the waiting Waiting on user response label Nov 23, 2021
@AntTheAlchemist
Copy link
Contributor

I've no idea how to do a pull request, really sorry. I'm not sure what one even is embarrassed. I am a complete Github virgin.

All I can say is that I put this code into main() and it works a lot better on my 4.2.2 device which HIDAPI doesn't behave on.

#ifdef ANDROID
	if (SDL_GetAndroidSDKVersion() < 18)
		SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "0");
#endif

@slouken
Copy link
Collaborator

slouken commented Nov 23, 2021

Ah, gotcha, thanks for clarifying. This isn't something you can put in the manifest conditionally based on API version, as far as I know.

@AJenbo
Copy link
Contributor Author

AJenbo commented Nov 23, 2021

I've no idea how to do a pull request, really sorry. I'm not sure what one even is embarrassed. I am a complete Github virgin.

It's a change proposal. It is done by first forking the repository to you own account. Making your changes do it. Then go to the repositories Pull Request (PR) tab and press create new.
(tip make a new branch for each change set, so that you can still do other changes with our affecting your previous PR).

I believe on GitHub it's also possible to do all of this via the browser simply by editing the file.

@AntTheAlchemist
Copy link
Contributor

Thanks @AJenbo . But I'm lost at the forking and account bit. My account isn't linked to SDL. I download a .zip of the source code, compile the DLL with Visual Studio 2019 and copy the src to where my Android Studio project can pick it up. I started programming in the early 1980s and still do everything the old school way.

If it's possible to edit the code from the browser, then I can do it that way. The other problem is that I'm not confident I would be following the strict formatting rules. And that I might break something else. In this instance I would try to put the above bit of code in the place where SDL checks the SDL_HINT_JOYSTICK_HIDAPI hint and override it if SDK < 18 with an ANDROID #ifdef. Would this be the right approach? I'd have to do some digging to work out where that is. I'm not confident I know what I'm doing with that, so I try to stick to pinpointing problems and pass the fix to someone who's better equipped, if that makes sense? This old dog is willing to learn new tricks though :-D

@AJenbo
Copy link
Contributor Author

AJenbo commented Nov 23, 2021

My account isn't linked to SDL.

That isn't relevant. When you fork you make your own copy where you are free to do what ever you want. A PR is a suggestion to the SDL project that they should apply some of the changes you have made in your copy.

You create a fork (copy) by clicking Fork in the upper right corner on the SDL GitHub page. You can use GitHub Desktop to easily sync between your GitHub copy and your computer.

The other problem is that I'm not confident I would be following the strict formatting rules. And that I might break something else.

Don't worry. There are 14 test suites run automatically on incoming PRs and a human has to also approve it.

To edit a file in the browser simply navigate to it and press the pencil in the upper right corner of the file. This works best if you only need to suggest changes to a single file.

@slouken slouken removed the waiting Waiting on user response label Nov 26, 2021
@AJenbo
Copy link
Contributor Author

AJenbo commented Dec 8, 2021

Confirmed

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

Successfully merging a pull request may close this issue.

3 participants