I was trying to install expo-av
into a non-expo react-native project. After installing react-native-unimodules
and adjusting the android/app/build.gradle
file, I am not able to build the android app anymore.
This is the main error I get:
The terminal looks like this: Java or Kotlin file MainApplication.java
does not include package declaration.
ENVFILE=.env react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 2152 file(s) to forward-jetify. Using 16 workers...
info JS server already running.
info Installing the app...
Configuration on demand is an incubating feature.
> Configure project :app
Reading env from: .env
FAILURE: Build failed with an exception.
* Where:
Script '/Users/*REDACTED*/HF-Projects/*REDACTED*/node_modules/react-native-unimodules/gradle.groovy' line: 75
* What went wrong:
A problem occurred evaluating project ':app'.
> Java or Kotlin file /Users/*REDACTED*/HF-Projects/*REDACTED*/android/app/src/main/java/com/*REDACTED*/MainApplication.java does not include package declaration
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 14s
I searched for package
on that file and found 26 occurrences.
There is this packages
variable on this ReactNativeHost
instance.
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
// Add unimodules
List<ReactPackage> unimodules = Arrays.<ReactPackage>asList(
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
packages.addAll(unimodules);
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage(); // <- add
}
};
Does anybody know about this error?