Repository: opencv
Issue: OpenCV Java SDK not building in React Native app as Native Module: android packages and symbols not existing
Labels: bug,category: build/install,platform: android

### System Information

OpenCV version: 4.8.0
OS: Windows 11
Java SDK: 11.0.20
Gradle version: 6.9.4

### Detailed description

I have a React Native app where I want to add the OpenCV Java SDK as a Native Module. I have tried various tutorials to make this work, and now I have done all the steps described [in this StackOverflow answer](https://stackoverflow.com/a/64500728/14567247) . However, when I try to run the project, I get a `> Task :opencv:compileDebugJavaWithJavac FAILED` with the logs below showing that basic packages as andorid.content and android.util do not exist.

I could build just fine prior to adding openCV, and these errors only show up for this openCV task. How do I fix this?

<details>
<summary>Android Studio Build Output log</summary>

```
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:9: error: package android.content does not exist
import android.content.ComponentName;
                      ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:10: error: package android.content does not exist
import android.content.Context;
                      ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:11: error: package android.content does not exist
import android.content.Intent;
                      ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:12: error: package android.content does not exist
import android.content.ServiceConnection;
                      ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:13: error: package android.net does not exist
import android.net.Uri;
                  ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:14: error: package android.os does not exist
import android.os.IBinder;
                 ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:15: error: package android.os does not exist
import android.os.RemoteException;
                 ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:16: error: package android.util does not exist
import android.util.Log;
                   ^
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:20: error: cannot find symbol
    public static boolean initOpenCV(String Version, final Context AppContext,
                                                           ^
  symbol:   class Context
  location: class AsyncServiceHelper
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:38: error: cannot find symbol
    protected AsyncServiceHelper(String Version, Context AppContext, LoaderCallbackInterface Callback)
                                                 ^
  symbol:   class Context
  location: class AsyncServiceHelper
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:50: error: cannot find symbol
    protected Context mAppContext;
              ^
  symbol:   class Context
  location: class AsyncServiceHelper
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:54: error: cannot find symbol
    protected static boolean InstallServiceQuiet(Context context)
                                                 ^
  symbol:   class Context
  location: class AsyncServiceHelper
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:71: error: cannot find symbol
    protected static void InstallService(final Context AppContext, final LoaderCallbackInterface Callback)
                                               ^
  symbol:   class Context
  location: class AsyncServiceHelper
C:\PATH_TO_MY_APP\android\opencv\java\src\org\opencv\android\AsyncServiceHelper.java:156: error: cannot find symbol
    protected ServiceConnection mServiceConnection = new ServiceConnection()
              ^
  symbol:   class ServiceConnection
  location: class AsyncServiceHelper
```

</details>

### Steps to reproduce

Follow the steps [in this StackOverflow answer](https://stackoverflow.com/a/64500728/14567247) and try to run in debug mode in Android Studio

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)