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

Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app. #17

Open
thienphuoc opened this issue Jun 11, 2018 · 6 comments

Comments

@thienphuoc
Copy link

thienphuoc commented Jun 11, 2018

06-11 09:33:07.161 2083-2109/com.mygame.game1 E/FirebaseInstanceId: Google Play services missing or without correct permission.
06-11 09:33:07.353 2083-2111/com.mygame.game1 E/firebase: Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app.
clazz
06-11 09:33:07.353 2083-2111/com.mygame.game1 A/firebase: Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app.

*build.grade (Project:proj.android)
buildscript {
repositories {
google()
jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
google()
jcenter()
}
}

*build.grade (Module App)
......
dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'

}

apply plugin: 'com.google.gms.google-services'

Is my application missing the firebase-ads-x-x.aar file ?

Can someone help me ? Thanks you very much!

@formatCvt
Copy link
Contributor

Which version of cocos and firebase cpp sdk do you use?
I think you should add this to project dependencies
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'

@thienphuoc
Copy link
Author

thienphuoc commented Jun 13, 2018

@formatCvt

I added this , But it's not working !

And then i created a new project named "sampleAdmob" , i also followed the guide https://firebase.google.com/docs/admob/cpp/cocos2d-x .

**After completing step : **
"3.Follow the steps to Add Firebase to your app that is located in the proj.android-studio/ directory."
-> i built debug and release .apk, it work fine !
.......
.......
**After completing step : **
"C++ integration"
-> i built debug .apk , it work fine . But the release .apk , it error with log :

06-13 11:53:27.935 3917-3948/? E/FirebaseInstanceId: Google Play services missing or without correct permission.
06-13 11:53:27.936 3917-3937/? V/FA: Connection attempt already in progress
06-13 11:53:27.937 3917-3937/? V/FA: Connection attempt already in progress
Activity resumed, time: 11913031
06-13 11:53:28.085 3917-3942/? D/EngineDataManager.cpp: setAnimationInterval by game: 0.0167
JNI setAnimationInterval: 0.016667
06-13 11:53:28.102 3950-3950/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-13 11:53:28.102 3950-3950/? I/dex2oat: /system/bin/dex2oat --runtime-arg -classpath --runtime-arg --instruction-set=x86 --instruction-set-features=default --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/com.sample.admob/cache/app_resources_lib.jar --oat-fd=18 --oat-location=/data/data/com.sample.admob/code_cache/app_resources_lib.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
06-13 11:53:28.120 3950-3950/? I/dex2oat: dex2oat took 18.765ms (threads: 4)
06-13 11:53:28.124 3917-3942/? E/firebase: Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app.
06-13 11:53:28.125 3917-3942/? E/firebase: clazz
06-13 11:53:28.125 3917-3942/? A/firebase: Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app.
06-13 11:53:28.125 3917-3942/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3942 (GLThread 297)
06-13 11:53:28.209 3917-3917/? D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=true
06-13 11:53:28.213 3917-3917/? V/FA: Local AppMeasurementService is starting up
06-13 11:53:28.214 843-843/com.android.launcher3 W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
06-13 11:53:28.229 121-121/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'generic/vbox86p/vbox86p:5.0/LRX21M/genymotion09281726:userdebug/test-keys'
Revision: '0'
ABI: 'x86'
pid: 3917, tid: 3942, name: GLThread 297 >>> com.sample.admob <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
06-13 11:53:28.230 573-601/system_process I/ActivityManager: Displayed com.sample.admob/org.cocos2dx.cpp.AppActivity: +960ms
06-13 11:53:28.234 121-121/? I/DEBUG: Abort message: 'Java class com/google/firebase/FirebaseApp not found. Please verify the AAR which contains the com/google/firebase/FirebaseApp class is included in your app.'
eax 00000000 ebx 00000f4d ecx 00000f66 edx 00000006

I use :
Android Studio 3.1.2
Cocos2d-x 3.17 (latest version)
NDK: android-ndk-r16b

Have you built the cocos2dx-cpp-sample with release mode ?

Could you please give me a sample project with successful release build ?

Thanks you very much @formatCvt !

@formatCvt
Copy link
Contributor

formatCvt commented Jun 14, 2018

yes, we have about 5 projects with admob integration. Cocos developers made a lot of changes in 3.17 for Android and samples a little bit not valid right now.
Try to disable proguard. In your app/build.gradle find release build type and disable minification (set minifyEnabled false). If it helps you can restore minification and add correspond proguard rules

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/app.pro")
        proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/analytics.pro")
        proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/admob.pro")
        [...and so on, for each Firebase C++ library and Ad SDK you are using.]

@thienphuoc
Copy link
Author

thienphuoc commented Jun 14, 2018

@formatCvt Thanks you very much!
I resolved my problem . If anyone encounter this problem , plz follow below :

*project.android/gradle.properties:

systemProp.firebase_cpp_sdk.dir=../firebase_cpp_sdk
*proj.android\app\build.gradle:

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.')
}
}
}
....
buildTypes {
release {
//debuggable false
//jniDebuggable false
//renderscriptDebuggable false
minifyEnabled false
//shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/app.pro")
proguardFile file(project.ext.firebase_cpp_sdk_dir + "/libs/android/admob.pro")
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
..............................................

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-common:16.0.0'

}
.......

ref : https://github.com/firebase/quickstart-cpp/blob/master/admob/testapp/build.gradle

Hope this help you ! If you cannot solve your problem, plz contact @formatCvt for help ! He is very good 👍 ^^

@formatCvt
Copy link
Contributor

you're welcome =)

by the way, don't forget enable Test Ads IDs for development builds (https://developers.google.com/admob/android/test-ads). Using production Ads IDs for developments builds can be reason for account suspension (our account is suspended right now and it is very-very hard to unsuspend account)

@thienphuoc
Copy link
Author

I enabled Test Ads IDs ! Thanks you for your help ! 👍 👍 Have a nice day bro !

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

2 participants