我在我的项目中使用了react-native-orientation包,并使用npx pod-install链接它。这在iOS上有效,现在我的应用程序在app上完全发布了。然后,当我试图创建一个Android构建时,我一直从Android获得以下错误:
A problem occurred evaluating project ':app'.
> Could not find method compile() for arguments [project ':react-native-orientation'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.然后,我遵循了将react-native-orientation链接到Android目录的手动说明,但是它什么也没做。我知道pod-install只适用于iOS,但是现在react-native link已经被废弃了,不是吗?我甚至不能运行它,因为它只是告诉我link是一个无法识别的命令。那么,如果手动连接不能工作,而自动链接显然不存在,我有什么行动方针?
发布于 2022-11-19 02:00:51
尝试使用贴片包装
问题是,在第7级上,“compile”关键字被废弃,而倾向于“实现”。
正确的方法不是在/node_modules/文件夹内进行更改,而是创建一个修补程序。在我的例子中,我不得不手动修改由修补程序包生成的自动修补程序。
这个问题帮了我:https://github.com/yamill/react-native-orientation/issues/407
修补程序如下所示(不要复制前2行,让修补程序包创建这些代码):
diff --git a/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java b/node_modules/react-native-orientation/android/src/main/java/com/github/yamill/orientation/OrientationModule.java
index 85331ae..787f60f 100644
--- a/node_modules/react-native-orientation/android/build.gradle
+++ b/node_modules/react-native-orientation/android/build.gradle
@@ -16,5 +16,5 @@ android {
}
dependencies {
- compile "com.facebook.react:react-native:+"
+ implementation "com.facebook.react:react-native:+"
}发布于 2022-09-30 18:24:45
这一问题的答案只是温和的激怒。结果是,在运行安装时导入的其中一个文件是不推荐的。多亏了Android,我才能看到代码被破坏的文件--我无法在VSCode中访问这个文件,或者如果是的话,我无法自己找到它。错误发生的文件看起来如下..。
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
dependencies {
compile "com.facebook.react:react-native:+"
}当代码中的最后一个块看起来像这样的时候.
dependencies {
implementation "com.facebook.react:react-native:+"
}https://stackoverflow.com/questions/73887302
复制相似问题