(각 종속 항목들 버전 확인 -> https://firebase.google.com/docs/android/setup?hl=ko#available_libraries)
▶ project Gradle
buildscript
{
repositories
{
....
}
dependencies
{
classpath 'com.android.tools.build:gradle:3.3.0-alpha06'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects
{
repositories
{
google()
jcenter()
maven {url "https://maven.google.com" }
}
}
...
▶ app Gradle
apply plugin: 'com.google.gms.google-services' 하단에 추가
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
// 본래 여기까지 있음. 이 밑으로는 추가
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation 'com.google.android.gms:play-services-games:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
}
apply plugin: 'com.google.gms.google-services'
project.ext {
// Configure the Firebase C++ SDK location.
firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
firebase_cpp_sdk_dir = System.getenv('FIREBASE_CPP_SDK_DIR')
if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
if ((new File('firebase_cpp_sdk')).exists()) {
firebase_cpp_sdk_dir = 'firebase_cpp_sdk'
} else {
throw new StopActionException(
'firebase_cpp_sdk.dir property or the FIREBASE_CPP_SDK_DIR ' +
'environment variable must be set to reference the Firebase C++ ' +
'SDK install directory. This is used to configure static library ' +
'and C/C++ include paths for the SDK.')
}
}
}
if (!(new File(firebase_cpp_sdk_dir)).exists()) {
throw new StopActionException(
sprintf('Firebase C++ SDK directory %s does not exist',
firebase_cpp_sdk_dir))
}
// Check the NDK location using the same configuration options as the
// experimental Gradle plug-in.
ndk_dir = project.android.ndkDirectory
if (ndk_dir == null || !ndk_dir.exists()) {
ndk_dir = System.getenv('ANDROID_NDK_HOME')
if (ndk_dir == null || ndk_dir.isEmpty()) {
throw new StopActionException(
'Android NDK directory should be specified using the ndk.dir ' +
'property or ANDROID_NDK_HOME environment variable.')
}
}
}
▶ android.mk
LOCAL_PATH := $(call my-dir) 하단
FIREBASE_CPP_SDK_DIR := $(LOCAL_PATH)/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)/libfirebase_app.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)/libfirebase_auth.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(FIREBASE_CPP_SDK_DIR)/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := firebase_admob
LOCAL_SRC_FILES := $(FIREBASE_LIBRARY_PATH)/libfirebase_admob.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(FIREBASE_CPP_SDK_DIR)/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := firebase_database
LOCAL_SRC_FILES := $(FIREBASE_LIBRARY_PATH)/libfirebase_database.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_STATIC_LIBRARIES := cocos2dx_static 밑으로
LOCAL_STATIC_LIBRARIES += firebase_feature
LOCAL_STATIC_LIBRARIES += firebase_admob
LOCAL_STATIC_LIBRARIES += firebase_database
LOCAL_STATIC_LIBRARIES += firebase_app
※ 순서가 중요한것으로 보여짐.
▶ gradle.properties 하단
systemProp.firebase_cpp_sdk.dir= firebase SDK가 있는 폴더의 절대 경로
ex)
systemProp.firebase_cpp_sdk.dir = D\:/ [ FolderName ] / [ ProjectPackage ] / proj.android / app / jni / firebase_cpp_sdk
만일 Unable to get provider com.google.firebase.provider.FirebaseInitProvider ~~ 하면서 에러가 뜨면 instant run 체크 해제한다.
'Programming > Cocos2d-x (with. cpp & java )' 카테고리의 다른 글
cocos2d 3.17 box2d (0) | 2018.12.24 |
---|---|
AppDelegate::applicationWillEnterForeground (0) | 2018.12.12 |
cocos2d-x DisplayState가 작아서 안보일 경우 (0) | 2018.12.09 |
template 사용법 (0) | 2018.01.21 |
[cocos2d-x] 스마트폰 Back키 & PC ESC 입력에 따른 화면 전환 (0) | 2017.12.17 |