我有 Web 开发人员的背景,最近开始使用 android-studio 在 react-native 中进行应用程序开发,当我尝试运行命令时遇到这个 gradle 构建错误:
react-native run-android
它输出这个:
cannot find symbol mInstabug.setUserName(username);
- method setUserName(String)
location: variable mInstabug of type Instabug
Note: D:\my_project\node_modules\instab reactnative\android\src\main\java\com\instabug\react library\RNInstabugReactnativeModule.java uses or overrides a deprecated API.
- Note: Recompile with -Xlint:deprecation for details.
Execution failed for task ':instabug-reactnative:compileReleaseJavaWithJavac'.
我目前正在使用:
- "instabug-reactnative": "git+ https://github.com/Instabug/instabug-reactnative.git#master "
- “ native react ”:“0.42.3”
提前致谢
最佳答案
我刚遇到同样的问题。我想我发现了问题并且可以提供一个临时解决方案,直到开发人员可以更新他的模块。如果您引用下面的链接,我们可能会从开发人员那里得到更多反馈。
https://github.com/Instabug/instabug-reactnative/issues/36
临时解决方案:
在您机器上的 RNInstabugReactnativeModule 文件中:
D:\my_project\node_modules\instab reactnative\android\src\main\java\com\instabug\react library\RNInstabugReactnativeModule.java
从第 183 行开始:
@ReactMethod
public void setUserName(String username) {
try {
mInstabug.setUserName(username);
} catch (Exception e) {
e.printStackTrace();
}
}
将 try 语句的 mInstabug.setUserName 更改为 mInstabug.setUsername:
@ReactMethod
public void setUserName(String username) {
try {
mInstabug.setUsername(username);
} catch (Exception e) {
e.printStackTrace();
}
}
看起来开发人员更改了外壳以与 iOS 更加一致,但我想它还没有在 mInstabug 类上更新。
关于java - Gradle构建错误: cannot find symbol for mInstabug. setUserName(用户名),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43932286/