Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio highlights all Java classes with JNI functions

Since the update to Android Studio 4.1.0 stable, all of my classes with JNI implemented functions are colored as red with code highlight.

Red example

Below you can see my project structure. There are several library projects and the main ck-learn project. All the classes with the native code are placed in jni-wrappers project, while CMakeLists.txt is in a top library project peshka which uses jni-wrappers (see screenshot).

The syntax was colored as usual in Android Studio 4.0.2. All the classes were visible in the peshka project. But now they are highlighted with red, as they were not found. But the projects compiles as usual. It is only a visual problem.

If I open someof the files colored in red, there is a warning:

This .java file is outside of Java source roots and won't be added to the classpath.

The source roots are standard (src\main\java) and it all was fine in AS 4.0.2.

Can someone help with this problem?

Project structure

like image 277
Artem Mostyaev Avatar asked Apr 10 '26 03:04

Artem Mostyaev


1 Answers

As confirmed by the OP from the comment, this is caused by a bug in Android Studio 4.1.0, which gets partially fixed in Android Studio 4.1.1. The full fix is still in progress. More details on the symptoms and workaround can be found from this bug.

like image 120
tgeng Avatar answered Apr 12 '26 16:04

tgeng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!