我试图安装expo-av
到一个非博览会反应原生项目中。安装react-native-unimodules
和调整android/app/build.gradle
文件后,我无法再构建 android 应用程序。
这是我得到的主要错误:
终端如下所示:Java 或 Kotlin 文件MainApplication.java
不包含包声明。
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
我在该文件上进行了搜索package
,发现了 26 次。
这个实例上有这个packages
变量。ReactNativeHost
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
}
};
有人知道这个错误吗?