与react-native-ble-plx链接后,反应本地运行android失败了
Task :react-native-ble-plx:compileDebugJavaWithJavac FAILED
这是一个带有React-NIT的新创建的应用程序,除了Min SDK以外,没有任何更改。已经尝试清洁项目,将Min SDK设置为18,并尝试使用Android Studio构建以获取更具体的错误,但仍然无法理解问题来自哪里。
我遇到的错误:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
12 actionable tasks: 2 executed, 10 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/converter/RxBleScanResultConverter.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
/Users/oriamd/Documents/MyDev/DudeWheresMyCar/node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/wrapper/Characteristic.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
在此处进行完整日志:https://pastebin.com/njamjujm
可以在需要时提供更多信息。谢谢
这个问题与此问题相似。
如@kreator答案所述,它与某些未转换为Androidx的软件包有关。
要解决此问题,您可以使用喷射器。
我在问题中提到了相同的问题,这些步骤解决了并再次运行。
- 首先,使用Android Studio的重构工具转换您的应用程序:Android开发人员文档
-
npm install --save-dev jetifier
-
npx jetify
-
npx react-native run-android
(您的应用程序应正确编译并工作( - 呼叫
npx jetify
在您的软件包的后安装目标中运行。
问题是我正在使用Android Studio Preview,并且使用Androidx和更多不支持的软件包。
我也有同样的问题。
"任务:react-native-ble-plx:compiledebugjavawithjavac失败失败:构建失败,有例外。
出了什么问题:执行失败任务':react-native-ble-plx:compiledebugjavawithjavac'。汇编失败;有关详细信息,请参见编译器错误输出。
尝试:使用-stacktrace选项运行以获取堆栈跟踪。使用-Info或 - debug选项运行,以获取更多日志输出。运行 - 扫描以获得完整的见解。
在https://help.gradle.org上获得更多帮助
构建在54S中失败
错误无法安装应用程序。确保您有Android建立了开发环境:https://reaectnative.dev/docs/environment-setup。
解决方案
这是我的build.gradle项目:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
kotlin_version = "1.6.0" // Update this to your version
}
repositories {
google()
mavenCentral()
}
...
}
我将某些版本更改为如下:
compileSdkVersion = 29
targetSdkVersion = 29
现在构建成功了!