Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

错误: 不兼容的类型: List<AMapGeolocationModule>无法转换为List<NativeModule> return Collections.singletonList(new AMapGeolocationModule(reactContext)); #156

Open
wenjianli92 opened this issue Oct 31, 2022 · 7 comments

Comments

@wenjianli92
Copy link

/Users/wenjianli/muyuan/my-slaughter-logistics-driver/node_modules/react-native-amap-geolocation/lib/android/src/main/java/cn/qiuxiang/react/geolocation/AMapGeolocationPackage.java:22: 错误: 不兼容的类型: List无法转换为List
return Collections.singletonList(new AMapGeolocationModule(reactContext));
^
1 个错误

@wenjianli92
Copy link
Author

修改nodemodal中文件代码已解决

@tvsj
Copy link

tvsj commented Nov 2, 2022

修改nodemodal中文件代码已解决
改了哪里?

@wenjianli92
Copy link
Author

@tvsj
node_modules/react-native-amap-geolocation/lib/android/src/main/java/cn/qiuxiang/react/geolocation/AMapGeolocationPackage.java

复制下面的内容替换上面文件中内荣
package cn.qiuxiang.react.geolocation;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class AMapGeolocationPackage implements ReactPackage {
@NotNull
@OverRide
public List createViewManagers(@NotNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@NotNull
@Override
public List<NativeModule> createNativeModules(@NotNull ReactApplicationContext reactContext) {

    List<NativeModule> modules = new ArrayList<>();
    modules.add(new AMapGeolocationModule(reactContext));

    return  modules;
}

}

@bianxuerui
Copy link

@tvsj node_modules/react-native-amap-geolocation/lib/android/src/main/java/cn/qiuxiang/react/geolocation/AMapGeolocationPackage.java

复制下面的内容替换上面文件中内荣 package cn.qiuxiang.react.geolocation;

import com.facebook.react.ReactPackage; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; import org.jetbrains.annotations.NotNull;

import java.util.ArrayList; import java.util.Collections; import java.util.List;

public class AMapGeolocationPackage implements ReactPackage { @NotNull @OverRide public List createViewManagers(@NotNull ReactApplicationContext reactContext) { return Collections.emptyList(); }

@NotNull
@Override
public List<NativeModule> createNativeModules(@NotNull ReactApplicationContext reactContext) {

    List<NativeModule> modules = new ArrayList<>();
    modules.add(new AMapGeolocationModule(reactContext));

    return  modules;
}

}

@OverRide 应该是 @OverRide

@inkcrazy666
Copy link

结合两个issue,同时修改掉单词拼写错误,完成解决方案:
第一步:node_modules/react-native-amap-geolocation/lib/android/src/main/java/cn/qiuxiang/react/geolocation/AMapGeolocationPackage.java
截屏2023-07-07 14 11 23

package cn.qiuxiang.react.geolocation;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class AMapGeolocationPackage implements ReactPackage {
    @NotNull
    @Override
    public List<ViewManager> createViewManagers(@NotNull ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }

    @NotNull
    @Override
    public List<NativeModule> createNativeModules(@NotNull ReactApplicationContext reactContext) {

        List<NativeModule> modules = new ArrayList<>();
        modules.add(new AMapGeolocationModule(reactContext));
        return modules;
    }
}

第二步:
0d96b404b2a029b2514b0a3b6e43c27c

/node_modules/react-native-amap-geolocation/lib/android/build.gradle按上图加
compileOnly 'org.jetbrains:annotations:23.0.0'

@inkcrazy666
Copy link

也可以把@NotNull都删掉,文件如下

package cn.qiuxiang.react.geolocation;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class AMapGeolocationPackage implements ReactPackage {
    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        modules.add(new AMapGeolocationModule(reactContext));
        return modules;
    }
}

@zjjjjjjjjjjd
Copy link

为什么没人看这个问题呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants