Issue
I followed all the steps listed here: crashlytics NDK Android
I copy pasted this file into my project: crashlytics.h
I am calling it with the following:
#include "Crashlytics.h"
void NDKCrashlytics::logToCrashlytics(char *result) {
firebase::crashlytics::Initialize();
firebase::crashlytics::Log(result);
}
As soon as I call the method my app crashes and this is the log I get:
E/AndroidRuntime(20818): FATAL EXCEPTION: Thread-10 E/AndroidRuntime(20818): Process: com.insync.loopad, PID: 20818 E/AndroidRuntime(20818): java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.crashlytics.FirebaseCrashlytics" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/lib64]] E/AndroidRuntime(20818): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196) E/AndroidRuntime(20818): at java.lang.ClassLoader.loadClass(ClassLoader.java:379) E/AndroidRuntime(20818): at java.lang.ClassLoader.loadClass(ClassLoader.java:312) 2 (greylist, linking, allowed) D/libcrashlytics(20818): Initializing libcrashlytics version 3.0.0
I also saw this issue here but it is not solved. What am I doing wrong?
Solution
On C++ side (replace com_xxx_lib with your package id):
#include "Crashlytics.h"
extern "C"
{
JNIEXPORT void JNICALL
Java_com_xxx_lib_MyNativeActivity_jniCrashlyticsInit(JNIEnv * env ) {
firebase::crashlytics::Initialize();
}
}
void CrashlyticsLog(char const *msg)
{
firebase::crashlytics::Log(msg);
}
On Java side: call jniCrashlyticsInit() in onCreate() in your NativeActivity
public class MyNativeActivity extends NativeActivity
{
static {
System.loadLibrary("XXX");//your c++ library
}
public native void jniCrashlyticsInit();
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
jniCrashlyticsInit();
}
}
After that you can use firebase::crashlytics::Log(msg) in your C++ code.
Answered By - Boris
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.