在清理项目之后,FirebaseAnalytics会导致ClassNotFoundException

时间:2017-11-14 12:13:27

标签: c# visual-studio xamarin.android firebase-analytics

从昨天开始,我无法解决这个错误。我在“干净”失败后开始发现这个错误,因为Visual Studio的“冻结”我被迫停止了这个过程。 这是错误堆栈:

11-14 10:57:30.210 I/mono-stdout(20645): Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.217 I/mono-stdout(20645):    --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
11-14 10:57:30.217 I/mono-stdout(20645):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
11-14 10:57:30.218 I/mono-stdout(20645):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0 
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562 
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568 
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0 
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562 
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568 
  at Android.Runtime.J
NIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602 
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602 
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616 
11-14 10:57:30.219 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0 
11-14 10:57:30.220 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0 
11-14 10:57:30.220 I/mono-stdout(20645):   at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677 
11-14 10:57:30.220 I/mono-stdout(20645):   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
  at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616 
  at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0 
  at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0 
  at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677 
  --- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.220 I/mono-stdout(20645): java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.classForName(Native Method)
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.forName(Class.java:324)
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:324)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:6301)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.221 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
11-14 10:57:30.222 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Activity.performCreate(Activity.java:6301)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Handler.dispatchMessage(Handler.java:111)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Looper.loop(Looper.java:207)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.223 I/mono-stdout(20645):    at java.lang.reflect.Method.invoke(Native Method)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
11-14 10:57:30.224 I/mono-stdout(20645): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.224 I/mono-stdout(20645):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
11-14 10:57:30.224 I/mono-stdout(20645):    ... 16 more
11-14 10:57:30.224 I/mono-stdout(20645):    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 16 more
    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        a
t java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 17 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.Class.classForName(Native Method)
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
11-14 10:57:30.225 I/mono-stdout(20645):        ... 17 more
11-14 10:57:30.225 I/mono-stdout(20645):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我尝试重新清理,重建,构建,检查引用(一切正常),尝试使用其他设备(华为Android 7.0,Android 6.0),从Android SDK Manager更新SDK和公司,更新Xamarin和VS { {3}}。 我试图在另一台机器上通过SVN移动所有内容,但另一台机器上也发现了问题。

有任何想法或帮助吗?

  

我在输出中用假的替换了我的包名。

     

在发现错误之前,我更新了设备操作系统(华为P9),但是在具有不同操作系统的THL上也发现了错误

1 个答案:

答案 0 :(得分:1)

在遇到同样问题的几天后,我理解这一点:

如果你从Nuget下载了图书馆,你需要确定一些要点:

1)XAMARIN.DOWNLOAD.BUILD 从Android SDK Manager更新对Xamarin Binders来说是不可用的,这是因为VS在编译过程中使用(我想)Xamarin.Download.Build来对齐jar。这就是您始终需要在项目中包含此组件的原因(如果您使用某些Xamarin Binders)。

要检查您是否已下载所有jar并了解错过了哪些组件,请浏览obj文件夹中的 library_projects \文件夹。 如果一切正常,你会发现classes.jar

请勿手动保存此文件夹,因为任何CLEAN操作都会删除该文件夹的内容。

2)ALIGN VERSIONS DEPENDENCIES 所有Google图书馆都是同一个&#34;服务套餐的一部分&#34; 如果你使用不同的谷歌服务(firebase,地图,云平台) 确保您使用的al组件具有相同的版本,并且组件具有相同的依赖关系(如果不是对齐组件)。如果你不修复它,你可能会在jar文件中加入有关丢失方法的奇怪编译错误。我想这会发生,因为这些库具有相同的依赖性,但版本不同。

3)总是使用NUGET 始终使用NUGET添加/删除组合。当我手动引用以前用NUGET下载的不同版本的组件来解决同样的问题时,我不断地编译错误。造成这种情况的原因是,如果您在项目文件(.prj)中手动引用库(并手动删除先前的引用),则保留&#34;导入指令&#34;错误的参考。

4)检查编译输出 如果你不理解编译错误。检查编译过程的完整详细日志(可以在VS Options中设置)。通常一个奇怪的错误取决于默认输出模式中未列出的先前警告。