Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 初始化应用程序时,仅显示白色屏幕_Android_Reactjs_React Native - Fatal编程技术网

Android 初始化应用程序时,仅显示白色屏幕

Android 初始化应用程序时,仅显示白色屏幕,android,reactjs,react-native,Android,Reactjs,React Native,当我启动应用程序时,我唯一看到的是一个大的白色屏幕,没有显示UI,请任何人向我提供解决方案。我已经在React Native上编写了代码。我在互联网上做了很多工作,但没有一个单一的解决方案。。。 致意 App.js:- import React, {useEffect, useState} from 'react'; import {Button} from 'react-native'; import admob, {MaxAdContentRating} from '@react-nativ

当我启动应用程序时,我唯一看到的是一个大的白色屏幕,没有显示UI,请任何人向我提供解决方案。我已经在React Native上编写了代码。我在互联网上做了很多工作,但没有一个单一的解决方案。。。 致意

App.js:-

import React, {useEffect, useState} from 'react';
import {Button} from 'react-native';
import admob, {MaxAdContentRating} from '@react-native-firebase/admob';
import {
  BannerAd,
  BannerAdSize,
  InterstitialAd,
  AdEventType,
} from '@react-native-firebase/admob';
import firebase from 'firebase';

const BanneradUnitId = 'ca-app-pub-7184661797309439/5996869501';

const InterstetialadUnitId = ' ca-app-pub-7184661797309439/5399949611';

const interstitial = InterstitialAd.createForAdRequest(InterstetialadUnitId, {
  requestNonPersonalizedAdsOnly: true,
  keywords: ['fashion', 'clothing'],
});

const App = () => {
  // ______________________ Request Configuration ___________________
  useEffect(() => {
    admob()
      .setRequestConfiguration({
        // Update all future requests suitable for parental guidance
        maxAdContentRating: MaxAdContentRating.PG,

        // Indicates that you want your content treated as child-directed for purposes of COPPA.
        tagForChildDirectedTreatment: true,

        // Indicates that you want the ad request to be handled in a
        // manner suitable for users under the age of consent.
        tagForUnderAgeOfConsent: true,
      })
      .then(() => {
        // Request config successfully set!
      });
    firebase.initializeApp();
  });

  // ____________ Interstetial Ads setup ________________________
  const [loaded, setLoaded] = useState(false);

  useEffect(() => {
    const eventListener = interstitial.onAdEvent((type) => {
      if (type === AdEventType.LOADED) {
        setLoaded(true);
      }
    });

    // Start loading the interstitial straight away
    interstitial.load();

    // Unsubscribe from events on unmount
    return () => {
      eventListener();
    };
  }, []);

  // No advert ready to show yet
  if (!loaded) {
    return null;
  }

  return (
    <div className={styles.main}>
      <h1>Hello World</h1>
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <Button
        title="Show Interstitial"
        onPress={() => {
          interstitial.show();
        }}
      />
    </div>
  );
};

const styles = StyleSheet.create({
  main: {
    textAlign: 'center',
  },
});

export default App;
{
  "react-native": {
    "admob_android_app_id": "ca-app-pub-7184661797309439~8217684640"
  }
}
firebase.json:-

import React, {useEffect, useState} from 'react';
import {Button} from 'react-native';
import admob, {MaxAdContentRating} from '@react-native-firebase/admob';
import {
  BannerAd,
  BannerAdSize,
  InterstitialAd,
  AdEventType,
} from '@react-native-firebase/admob';
import firebase from 'firebase';

const BanneradUnitId = 'ca-app-pub-7184661797309439/5996869501';

const InterstetialadUnitId = ' ca-app-pub-7184661797309439/5399949611';

const interstitial = InterstitialAd.createForAdRequest(InterstetialadUnitId, {
  requestNonPersonalizedAdsOnly: true,
  keywords: ['fashion', 'clothing'],
});

const App = () => {
  // ______________________ Request Configuration ___________________
  useEffect(() => {
    admob()
      .setRequestConfiguration({
        // Update all future requests suitable for parental guidance
        maxAdContentRating: MaxAdContentRating.PG,

        // Indicates that you want your content treated as child-directed for purposes of COPPA.
        tagForChildDirectedTreatment: true,

        // Indicates that you want the ad request to be handled in a
        // manner suitable for users under the age of consent.
        tagForUnderAgeOfConsent: true,
      })
      .then(() => {
        // Request config successfully set!
      });
    firebase.initializeApp();
  });

  // ____________ Interstetial Ads setup ________________________
  const [loaded, setLoaded] = useState(false);

  useEffect(() => {
    const eventListener = interstitial.onAdEvent((type) => {
      if (type === AdEventType.LOADED) {
        setLoaded(true);
      }
    });

    // Start loading the interstitial straight away
    interstitial.load();

    // Unsubscribe from events on unmount
    return () => {
      eventListener();
    };
  }, []);

  // No advert ready to show yet
  if (!loaded) {
    return null;
  }

  return (
    <div className={styles.main}>
      <h1>Hello World</h1>
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <BannerAd
        unitId={BanneradUnitId}
        size={BannerAdSize.FULL_BANNER}
        requestOptions={{
          requestNonPersonalizedAdsOnly: true,
        }}
      />
      <Button
        title="Show Interstitial"
        onPress={() => {
          interstitial.show();
        }}
      />
    </div>
  );
};

const styles = StyleSheet.create({
  main: {
    textAlign: 'center',
  },
});

export default App;
{
  "react-native": {
    "admob_android_app_id": "ca-app-pub-7184661797309439~8217684640"
  }
}

您一定收到了一些错误,因为react native中不支持
div
。将
div
替换为可以从“react native”软件包导入的
视图。

我已经做了更改,但问题仍然存在!!!!