始终违规:requireNativeComponent:在UIManager中找不到“ RNGADBannerView”

时间:2018-07-12 15:53:57

标签: react-native admob google-admob

我最近为react-native安装了admob。但是在UIManager中找不到错误“ RNGADBannerView”。我不知道这是什么意思?

public void Configuration(IAppBuilder appBuilder) { HttpConfiguration configuration = new HttpConfiguration(); WebApiConfig.Register(configuration); appBuilder.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); appBuilder.UseWebApi(configuration); } public void ConfigureOAuth(IAppBuilder appBuilder) { OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), Provider = new SimpleAuthorizationServerProvider() }; appBuilder.UseOAuthAuthorizationServer(OAuthServerOptions); appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); }

_can anyone help?_

依赖项:

import {AdMobBanner} from 'react-native-admob';

  export default class Home extends Component{
   render(){
    return <View>
        <Text>helo</Text>
        <AdMobBanner
            adSize="fullBanner"
            adUnitID="my_id"
            onAdFailedToLoad={error => console.error(error)}
        />
    </View>
}

2 个答案:

答案 0 :(得分:1)

似乎您没有将库链接到您的项目。
在项目的根目录中使用react-native link应该可以解决问题。

答案 1 :(得分:0)

我正面临类似的问题Invariant Violation: requireNativeComponent:xxx not found in UIManager

问题似乎是依赖关系,因此未与您的项目链接,因此针对此问题提供了两种解决方案(取决于您的“依赖关系”)

  1. 在终端/ cmd中的项目路径上运行react-native link
  2. 手动将依赖项添加到MainApplication.java中,如下所示:
@Override
    protected List<ReactPackage> getPackages() {      

      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for 
      packages.add(new RNFirebaseAnalyticsPackage());
      packages.add(new xxxPackage());
    }