所以我使用this包尝试将MapBox集成到我正在处理的React-Native项目中,并且在运行时我不断收到此错误。我已经按照他们页面上的说明进行操作了,我仍然得到了这个,所以我想我一直忘记安装包或其他东西。任何人都知道如何解决这个问题?
a:17: error: cannot find symbol
protected List getPackages() {
^
symbol: class List
location: class MainActivity
/Github/ReactApp/android/app/src/main/java/com/reactapp/MainActivity.java:17: error: cannot find symbol
protected List getPackages() {
^
symbol: class ReactPackage
location: class MainActivity
/Github/ReactApp/android/app/src/main/java/com/reactapp/MainActivity.java:16: error: method does not override or implement a method from a supertype
@Override
^
/Github/ReactApp/android/app/src/main/java/com/reactapp/MainActivity.java:19: error: cannot find symbol
new MainReactPackage(),
^
symbol: class MainReactPackage
location: class MainActivity
/Github/ReactApp/android/app/src/main/java/com/reactapp/MainActivity.java:18: error: cannot find symbol
return Arrays.asList(
^
symbol: class ReactPackage
location: class MainActivity
/Github/ReactApp/android/app/src/main/java/com/reactapp/MainActivity.java:18: error: cannot find symbol
return Arrays.asList(
^
symbol: variable Arrays
location: class MainActivity
6 errors
编辑:这是MainActivity的源代码:
package com.reactapp;
import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "ReactApp";
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeMapboxGLPackage()); // <-- Register package here
}
}
答案 0 :(得分:7)
您缺少一些导入:
import java.util.List;
import java.util.Arrays;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.react.ReactPackage;
您的@Overrides
之一也是一个方法(getPackages),它不会覆盖超类中的任何内容。删除它。
答案 1 :(得分:0)
U缺少进口&gt; 如果你使用Android工作室去: 文件&gt;设置&gt;编辑器&gt;常规&gt;自动导入和检查 - 显示导入弹出窗口 - 即时优化导入 - 即时添加明确的导入