Firebase Admob crashes

I’ve installed Firebase, did the whole setup, but when I load my app on my android is says “Unfortunately, (APP) has stopped”.

proj.android-studio\app\jni\Android.mk:

LOCAL_PATH := $(call my-dir)

FIREBASE_CPP_SDK_DIR := ../../../firebase_cpp_sdk

APP_ABI := armeabi-v7a x86
STL := $(firstword $(subst _, ,$(APP_STL)))
FIREBASE_LIBRARY_PATH := $(FIREBASE_CPP_SDK_DIR)/libs/android/$(TARGET_ARCH_ABI)/$(STL)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_app
LOCAL_SRC_FILES := $(FIREBASE_LIBRARY_PATH)/libapp.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(FIREBASE_CPP_SDK_DIR)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_feature
LOCAL_SRC_FILES := $(FIREBASE_LIBRARY_PATH)/libadmob.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(FIREBASE_CPP_SDK_DIR)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos/audio/include)

LOCAL_MODULE := MyGame_shared

LOCAL_MODULE_FILENAME := libMyGame

LOCAL_SRC_FILES := hellocpp/main.cpp \
				   ../../../Classes/AppDelegate.cpp \
				   ../../../Classes/HelloWorldScene.cpp \
				   ../../../Classes/FirebaseHelper.cpp


LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES += firebase_app
LOCAL_STATIC_LIBRARIES += firebase_feature

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

AppDelegate.cpp:

#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "firebase/app.h"
#include "firebase/admob.h"

// #define USE_AUDIO_ENGINE 1
// #define USE_SIMPLE_AUDIO_ENGINE 1

#if USE_AUDIO_ENGINE && USE_SIMPLE_AUDIO_ENGINE
#error "Don't use AudioEngine and SimpleAudioEngine at the same time. Please just select one in your game!"
#endif

#if USE_AUDIO_ENGINE
#include "audio/include/AudioEngine.h"
using namespace cocos2d::experimental;
#elif USE_SIMPLE_AUDIO_ENGINE
#include "audio/include/SimpleAudioEngine.h"
using namespace CocosDenshion;
#endif

USING_NS_CC;

static cocos2d::Size designResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size smallResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024, 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048, 1536);

AppDelegate::AppDelegate()
{
}

AppDelegate::~AppDelegate() 
{
#if USE_AUDIO_ENGINE
	AudioEngine::end();
#elif USE_SIMPLE_AUDIO_ENGINE
	SimpleAudioEngine::end();
#endif
}

// if you want a different context, modify the value of glContextAttrs
// it will affect all platforms
void AppDelegate::initGLContextAttrs()
{
	// set OpenGL context attributes: red,green,blue,alpha,depth,stencil
	GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};

	GLView::setGLContextAttrs(glContextAttrs);
}

// if you want to use the package manager to install more packages,  
// don't modify or remove this function
static int register_all_packages()
{
	return 0; //flag for packages manager
}

bool AppDelegate::applicationDidFinishLaunching() {
	// initialize director
	auto director = Director::getInstance();
	auto glview = director->getOpenGLView();
	if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
		glview = GLViewImpl::createWithRect("Shaokang", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
		glview = GLViewImpl::create("Shaokang");
#endif
		director->setOpenGLView(glview);
	}

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	// Initialize Firebase for Android.
	firebase::App* app = firebase::App::Create(
		firebase::AppOptions(), JniHelper::getEnv(), JniHelper::getActivity());
	// Initialize AdMob.
	firebase::admob::Initialize(*app, "INSERT_YOUR_ADMOB_ANDROID_APP_ID");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	// Initialize Firebase for iOS.
	firebase::App* app = firebase::App::Create(firebase::AppOptions());
	// Initialize AdMob.
	firebase::admob::Initialize(*app, "INSERT_YOUR_ADMOB_IOS_APP_ID");
#endif
	// Initialize AdMob.
	firebase::admob::Initialize(*app);

	// turn on display FPS
	director->setDisplayStats(true);

	// set FPS. the default value is 1.0/60 if you don't call this
	director->setAnimationInterval(1.0f / 60);

	// Set the design resolution
	glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
	auto frameSize = glview->getFrameSize();
	// if the frame's height is larger than the height of medium size.
	if (frameSize.height > mediumResolutionSize.height)
	{        
		director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
	}
	// if the frame's height is larger than the height of small size.
	else if (frameSize.height > smallResolutionSize.height)
	{        
		director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
	}
	// if the frame's height is smaller than the height of medium size.
	else
	{        
		director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
	}

	register_all_packages();

	// create a scene. it's an autorelease object
	auto scene = HelloWorld::createScene();

	// run
	director->runWithScene(scene);

	return true;
}

// This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
void AppDelegate::applicationDidEnterBackground() {
	Director::getInstance()->stopAnimation();

#if USE_AUDIO_ENGINE
	AudioEngine::pauseAll();
#elif USE_SIMPLE_AUDIO_ENGINE
	SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
	SimpleAudioEngine::getInstance()->pauseAllEffects();
#endif
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
	Director::getInstance()->startAnimation();

#if USE_AUDIO_ENGINE
	AudioEngine::resumeAll();
#elif USE_SIMPLE_AUDIO_ENGINE
	SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
	SimpleAudioEngine::getInstance()->resumeAllEffects();
#endif
}

HelloWorldScene.cpp:

#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
#include "FirebaseHelper.h"
#include "firebase/admob.h"
#include "firebase/admob/types.h"
#include "firebase/app.h"
#include "firebase/future.h"
#include "firebase/admob/banner_view.h"

USING_NS_CC;

firebase::admob::BannerView* banner_view;

Scene* HelloWorld::createScene()
{
	return HelloWorld::create();
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !Scene::init() )
	{
		return false;
	}

	auto visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	/////////////////////////////
	// 2. add a menu item with "X" image, which is clicked to quit the program
	//    you may modify it.

	// add a "close" icon to exit the progress. it's an autorelease object
	auto closeItem = MenuItemImage::create(
										   "CloseNormal.png",
										   "CloseSelected.png",
										   CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));

	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
								origin.y + closeItem->getContentSize().height/2));

	// create menu, it's an autorelease object
	auto menu = Menu::create(closeItem, NULL);
	menu->setPosition(Vec2::ZERO);
	this->addChild(menu, 1);

	/////////////////////////////
	// 3. add your codes below...

	// add a label shows "Hello World"
	// create and initialize a label

	auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);

	// position the label on the center of the screen
	label->setPosition(Vec2(origin.x + visibleSize.width/2,
							origin.y + visibleSize.height - label->getContentSize().height));

	// add the label as a child to this layer
	this->addChild(label, 1);

	// add "HelloWorld" splash screen"
	auto sprite = Sprite::create("HelloWorld.png");

	// position the sprite on the center of the screen
	sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

	// add the sprite as a child to this layer
	this->addChild(sprite, 0);


#if defined(__ANDROID__)
	// Android ad unit IDs.
	const char* kBannerAdUnit = "ca-app-pub-3940256099942544/6300978111";
#else
	// iOS ad unit IDs.
	const char* kBannerAdUnit = "ca-app-pub-3940256099942544/2934735716";
#endif

	// Create and initialize banner view.
	firebase::admob::BannerView* banner_view;
	banner_view = new firebase::admob::BannerView();
	firebase::admob::AdSize ad_size;
	ad_size.ad_size_type = firebase::admob::kAdSizeStandard;
	ad_size.width = 320;
	ad_size.height = 50;
	banner_view->Initialize(getAdParent(), kBannerAdUnit, ad_size);

	// Schedule updates so that the Cocos2d-x update() method gets called.
	this->scheduleUpdate();

	return true;
}


void HelloWorld::menuCloseCallback(Ref* pSender)
{
	//Close the cocos2d-x game scene and quit the application
	Director::getInstance()->end();

	#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	exit(0);
#endif

	/*To navigate back to native iOS screen(if present) without quitting the application  ,do not use Director::getInstance()->end() and exit(0) as given above,instead trigger a custom event created in RootViewController.mm as below*/

	//EventCustom customEndEvent("game_scene_close_event");
	//_eventDispatcher->dispatchEvent(&customEndEvent);


}

void HelloWorld::update(float delta) {
	// Check that the banner has been initialized.
	if (banner_view->InitializeLastResult().status() ==
		firebase::kFutureStatusComplete) {
		// Check that the banner hasn't started loading.
		if (banner_view->LoadAdLastResult().status() ==
			firebase::kFutureStatusInvalid) {
			// Make the banner visible and load an ad.
			CCLOG("Loading a banner.");
			banner_view->Show();
			firebase::admob::AdRequest my_ad_request = {};
			banner_view->LoadAd(my_ad_request);
		}
	}
}

My app is literally the default project, only with everything from the Firebase tutorial added to it, and it crashes. What do I do? What could it be?

Is says the error: E/firebase: Unable to check Google Play services availablity as the com.google.android.gms.common.GoogleApiAvailability class is not present in this application.

Do you have included the Google Play Services within gradle? It’s in play-service-base. You can check it with ./gradlew app:androidDependency within the terminal (in Android Studio) or you just open the external libraries list in the project view.

I got the same error…
i check whole things…
not found a single mistake…
are you solve it out @FailingUser
can you help me

12-01 00:26:10.746 31219-31256/? E/firebase: Unable to check Google Play services availablity as the com.google.android.gms.common.GoogleApiAvailability class is not present in this application.12-01 00:26:10.746 31219-31256/? A/firebase: g_initialized_count`

                                         -------- beginning of crash

12-01 00:26:10.746 31219-31256/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 31256 (GLThread 2192)

                                     [ 12-01 00:26:10.747   430:  430 W/         ]`
                                     debuggerd: handling request: pid=31219 uid=10137 gid=10137 tid=31256

12-01 00:26:10.814 31260-31260/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-01 00:26:10.814 31260-31260/? A/DEBUG: Build fingerprint: xiaomi/tissot/tissot_sprout:7.1.2/N2G47H/7.11.18:user/release-keys
12-01 00:26:10.814 31260-31260/? A/DEBUG: Revision: ‘0’
12-01 00:26:10.814 31260-31260/? A/DEBUG: ABI: ‘arm’
12-01 00:26:10.814 31260-31260/? A/DEBUG: pid: 31219, tid: 31256, name: GLThread 2192 >>> com.demo.firebasedemoapp <<<
12-01 00:26:10.815 31260-31260/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
12-01 00:26:10.819 31260-31260/? A/DEBUG: Abort message: ‘g_initialized_count’
12-01 00:26:10.819 31260-31260/? A/DEBUG: r0 00000000 r1 00007a18 r2 00000006 r3 00000008
12-01 00:26:10.819 31260-31260/? A/DEBUG: r4 eb4b5978 r5 00000006 r6 eb4b5920 r7 0000010c
12-01 00:26:10.819 31260-31260/? A/DEBUG: r8 eb4b4f58 r9 e9c1f200 sl 00000000 fp eb4b4ee4
12-01 00:26:10.819 31260-31260/? A/DEBUG: ip 00000002 sp eb4b4cb0 lr f3ece2d7 pc f3ed0b58 cpsr 200f0010
12-01 00:26:10.824 31260-31260/? A/DEBUG: backtrace:
12-01 00:26:10.824 31260-31260/? A/DEBUG: #00 pc 00049b58 /system/lib/libc.so (tgkill+12)
12-01 00:26:10.824 31260-31260/? A/DEBUG: #01 pc 000472d3 /system/lib/libc.so (pthread_kill+34)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #02 pc 0001d575 /system/lib/libc.so (raise+10)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #03 pc 000190c1 /system/lib/libc.so (__libc_android_abort+34)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #04 pc 00017124 /system/lib/libc.so (abort+4)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #05 pc 00172187 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so
12-01 00:26:10.825 31260-31260/? A/DEBUG: #06 pc 00172235 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so
12-01 00:26:10.825 31260-31260/? A/DEBUG: #07 pc 001721bd /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN8firebase9LogAssertEPKcz+12)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #08 pc 00171dc7 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN20google_play_services9TerminateEP7_JNIEnv+18)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #09 pc 00171285 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so
12-01 00:26:10.825 31260-31260/? A/DEBUG: #10 pc 0017179f /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN8firebase3App6CreateERKNS_10AppOptionsEPKcP7_JNIEnvP8_jobject+266)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #11 pc 001719e1 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN8firebase3App6CreateERKNS_10AppOptionsEP7_JNIEnvP8_jobject+16)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #12 pc 0016b087 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN11AppDelegate29applicationDidFinishLaunchingEv+274)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #13 pc 0016ba89 /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (_ZN7cocos2d11Application3runEv+6)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #14 pc 0016d4ad /data/app/com.demo.firebasedemoapp-1/lib/arm/libMyGame.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+104)
12-01 00:26:10.825 31260-31260/? A/DEBUG: #15 pc 00547e2d /data/app/com.demo.firebasedemoapp-1/oat/arm/base.odex (offset 0x51c000)
12-01 00:26:11.470 1418-2074/? E/IzatSvc_ComboNetworkProvider: E/Exiting with error virtual void izat_manager::ComboNetworkProvider::reportLocationMsg::proc() const line 187 “1”
12-01 00:26:12.020 10268-10268/? E/LegacyNowServiceClient: skipping logEndstates, service is null
12-01 00:26:12.523 10268-10268/? E/LegacyNowServiceClient: skipping logEndstates, service is null
12-01 00:26:13.189 10268-10277/? E/ReloadingLock: Finalizing LOCKED Token[shortcuts 2017-12-01 00:26:13.095]`

Any solution of this problem ? @FailingUser, @ersumitlakhani

Got my solution, No crash when I add below artifact in android build.gradle file

implementation 'com.google.android.gms:play-services-base:12.0.1'