We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5343 - cpufeatures module broken on current Android Studio?
Summary: cpufeatures module broken on current Android Studio?
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.13
Hardware: x86_64 Android (All)
: P2 blocker
Assignee: Sylvain
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-08 16:52 UTC by superfury
Modified: 2020-11-11 08:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description superfury 2020-11-08 16:52:50 UTC
When I try to compile my project using SDL2 on Android(tested both 2.0.12 and 2.0.13), the indexing tries to index the entire C:\ drive on Windows.

Somehow, the cpufeatures module included from SDL2's Android.mk seems to make it include C:\ into the project path for the cpufeatures module(it should actually use the cpufeatures folder instead). This makes Android Studio pretty much infinitely try to index the entire C:\ drive recursively(perhaps even causing conflicts due to included path overlaps recursing again)?

Can this module be disabled for Android?
Comment 1 superfury 2020-11-08 16:53:35 UTC
I'm on the latest NDK and Android Studio. Reverting to older NDKs has no effect.
Comment 2 superfury 2020-11-08 22:13:08 UTC
Managed to get it compiling somewhat.

I've simply commented the following line out in Android.mk from the cpufeatures module:
```
LOCAL_SRC_FILES := cpu-features.c
```

Then, build it(so that Android Studio doesn't index it), uncomment said line to allow compilation to pass, then build again.

Afaik this now needs to be repeated every time you load a SDL2 project which uses the cpufeatures module (pretty much any modern SDL2 library using app it seems).
Comment 3 Sam Lantinga 2020-11-09 07:29:55 UTC
Sylvain, I've experienced this as well. Can you look at what's happening here?
Comment 4 Sylvain 2020-11-09 09:48:32 UTC
I don't use Android Studio. Only tried a couple of times to update packages, and java code checks. I haven't been able to build anything.

Superfury: can you tell me which folder you open from SDL, and how you build ?
On linux, it seems to index correctly.

Just googling: maybe using "import project" instead of "open project".
Comment 5 superfury 2020-11-09 20:10:20 UTC
"import project" is creating a completely new project based on an existing one? That would pretty much defeat the entire purpose of using an existing project (which is committed in git)?

As a little side note: Android Studio after the initial LOCAL_SRC_FILES removal, open it, run make, uncomment the LOCAL_SRC_FILES line and build again, then quit while saving the project steps causes it to apparently no longer search the C:\ drive for the project. It will still compile the cpufeatures module, so there's no problem there atm. One thing that can be noticed, however, is that the Project tab on the left side of Android studio no longer lists neither the C:\ drive nor the cpufeatures module(only hidapi, main, SDL2 and SDL2_net(SDL2_net only when installed in the module directory) in my case).

So it's working, but I don't know if the problem might resurface when Android Studio receives another update(it looks like the NDK isn't part of the problem. Downgrading the NDK(using the side-by-side NDK feature) to older versions has no effect on the cpufeatures issue). It looks like the issue has mainly something to do with the new Android Studio 4.1's way of handling things (had no issue until I actually installed the update for 4.1). Perhaps it's a strange little bug inside of Android Studio itself (seeing as the NDK version (using side-by-side loading) doesn't affect things)? The development environment (updating from 4.0(as far as I can remember) to 4.1) seems to be the main culprit somehow.
Comment 6 superfury 2020-11-09 20:20:30 UTC
Also, my build steps I follow (other than the special steps mentioned above to bypass the indexing issue) can be found in the README on my app's repository: https://bitbucket.org/superfury/unipcemu.git
Comment 7 superfury 2020-11-09 20:25:48 UTC
Although if you're on Linux creating the symbolic directory and file links would need to be done manually(look inside the generatelinks.bat file for how the directories and file are linked for compatiblity with Android Studio).

It's basically redirecting the Android Studio java/jni/res folders and AndroidManifest.xml file (in android-studio\app\src\main) to the folders/files in the android-project folder. That's my simple way of keeping compatibility with the old building system (that was used before transitioning to Android Studio).
Comment 8 Sylvain 2020-11-10 06:16:39 UTC
it really sounds to be a bug in the latest Android Studio, maybe it's better to report the bug there so that it can be fixed for the next release.

that was the link: not sure if this is really relevant:
https://medium.com/@u.adb/android-studio-constantly-indexing-the-project-problem-solution-8d3150d244a3

maybe you can just disable the indexing in the IDE ?
Comment 9 superfury 2020-11-10 14:45:47 UTC
I tried running the import step you've mentioned. But it simply ends up hanging the app(gets to 0% CPU usage) when starting the IDE with the import step?

Then I did something different: I tried running the app, closed the project, chose from the main screen(where you can choose recently opened projects and setup the Android Studio's basic settings), then chose to update. It found some update for the Kotlin plugin and installed it.
Then I tried said option again, after which it actually continued loading using said import option, finding the project and loading as it should.

Now just need to fix the NDK, since it can't properly clean the project(ndk-build.cmd fails) or compile SDL(somehow the installed NDK seems to be corrupted now).
Comment 10 superfury 2020-11-10 15:05:02 UTC
As for reinstallation of the corrupted NDK, I'm just following the first 8 steps from this tutorial:
https://lazyfoo.net/tutorials/SDL/52_hello_mobile/android_windows/index.php

Everything after that is specific for my project, which is described in the project's README.
Comment 11 superfury 2020-11-10 21:06:59 UTC
Btw I'm on SDL2 commit 14055. The current SDL2 commit has come compilation issues/warnings.
Comment 12 superfury 2020-11-10 21:30:08 UTC
An update to Android Studio just came out... Guess what's in it?

https://androidstudio.googleblog.com/2020/11/android-studio-411-available.html

```
C++
Issue #171280381: #$(call import-module,android/cpufeatures) in Android.mk will import all files in disk root
```

So a bugfix just came out! :D
Comment 13 superfury 2020-11-10 22:19:41 UTC
The Android Studio 4.1.1 update fixes the issue.
Comment 14 Sylvain 2020-11-11 08:10:57 UTC
Great, thanks for the investigation !