Bug 58940 - java.lang.ClassNotFoundException crash Android API 19
Summary: java.lang.ClassNotFoundException crash Android API 19
Status: RESOLVED DUPLICATE of bug 59036
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.4 (15.3)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-08-22 06:54 UTC by Niels
Modified: 2017-09-06 03:39 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 59036

Description Niels 2017-08-22 06:54:12 UTC
I just updated to the latest STABLE versions for VS, Xamarin Android etc and now our app crashes when running on API 19, see the message below. Everything works fine on API 22. After downgrading to Xamarin.Android 7.3.1.2 everything works fine again. 

[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: nl.company.planning, PID: 15123
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application md5697e74cc556248db79eab3fb52bced1f.MyApplication: java.lang.ClassNotFoundException: Didn't find class "md5697e74cc556248db79eab3fb52bced1f.MyApplication" on path: DexPathList[[zip file "/data/app/nl.company.planning-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.company.planning-2, /vendor/lib, /system/lib]]
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
[AndroidRuntime] 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4702)
[AndroidRuntime] 	at android.app.ActivityThread.access$1600(ActivityThread.java:174)
[AndroidRuntime] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:146)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:5593)
[AndroidRuntime] 	at java.lang.reflect.Method.invokeNative(Native Method)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Method.java:515)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
[AndroidRuntime] 	at dalvik.system.NativeStart.main(Native Method)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "md5697e74cc556248db79eab3fb52bced1f.MyApplication" on path: DexPathList[[zip file "/data/app/nl.company.planning-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.company.planning-2, /vendor/lib, /system/lib]]
[AndroidRuntime] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
[AndroidRuntime] 	at android.app.Instrumentation.newApplication(Instrumentation.java:981)
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
[AndroidRuntime] 	... 11 more
[Process] Sending signal. PID: 15123 SIG: 9


=== Visual Studio Enterprise 2017 for Mac ===

Version 7.1 (build 1297)
Installation UUID: 4483d0e1-4909-4f5e-bc97-f9d6f3d4bf06
Runtime:
	Mono 5.2.0.215 (d15-3/da80840) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000215

=== NuGet ===

Version: 4.3.0.2418

=== .NET Core ===

Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.4.0.19 (Visual Studio Enterprise)
Android SDK: /Users/nielscup/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: 10.12.0.18 (Visual Studio Enterprise)
Hash: 4a279c9a
Branch: d15-3
Build date: 2017-08-02 12:38:11-0400

=== Xamarin.Mac ===

Version: 3.6.0.17 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Build Information ===

Release ID: 701001297
Git revision: 9c5299666538b2f8baf501418a5c064d784d64da
Build date: 2017-08-07 11:29:35-04
Xamarin addins: 3bb0c32a14f1b7e368bf5ac53a84c3581c019391
Build lane: monodevelop-lion-d15-3

=== Operating System ===

Mac OS X 10.12.4
Darwin 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

AddinMaker 1.3.7
Manifest.addin 0.0.0.0
Comment 1 Jon Douglas [MSFT] 2017-08-22 07:25:26 UTC
I would guess you are using multidex and this class is not making the main list. Please see the following bugs for a workaround:

https://bugzilla.xamarin.com/show_bug.cgi?id=47086

https://bugzilla.xamarin.com/show_bug.cgi?id=51480

My blog also has a bit of information on this subject:

http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/

Secondly, do you have the fast deployment enabled? If so, I believe you might be affected by this CONFIRMED bug:

https://bugzilla.xamarin.com/show_bug.cgi?id=55050

Thanks for the report!
Comment 2 Niels 2017-08-22 09:18:51 UTC
Correct, I am using multidex but there aren't any issues in Xamarin.Android 7.3.1.2.

This bug was already reported in BETA: https://bugzilla.xamarin.com/show_bug.cgi?id=47086,.

What I really don't understand is why this BETA release was shipped as STABLE and still contains this same bug.
Comment 3 Jon Douglas [MSFT] 2017-08-22 15:06:08 UTC
(In reply to Niels from comment #2)
> Correct, I am using multidex but there aren't any issues in Xamarin.Android
> 7.3.1.2.
> 
> This bug was already reported in BETA:
> https://bugzilla.xamarin.com/show_bug.cgi?id=47086,.
> 
> What I really don't understand is why this BETA release was shipped as
> STABLE and still contains this same bug.

https://bugzilla.xamarin.com/show_bug.cgi?id=47086 was not fixed by any means by the Xamarin team. This was self resolved by the person who filed the issue:

https://bugzilla.xamarin.com/show_activity.cgi?id=47086

So overall there wasn't a "bug" to fix. The real issue is https://bugzilla.xamarin.com/show_bug.cgi?id=55050 and other small issues around this item in which the custom application class doesn't make the main dex list. For now, the workaround I've provided should get you around this situation until we fix that issue. If you need any additional assistance with getting this to work, feel free to comment on this bug report.

Getting back to the point, can you confirm that Fast Deployment is enabled in your case? Have you tried to disable it and see if the class makes the main dex list?

Thanks!
Comment 4 Niels 2017-08-23 08:51:40 UTC
Have another look at comment 2 in this post: https://bugzilla.xamarin.com/show_bug.cgi?id=47086#c2

I indicate this same issue in BETA and that it went away when switching back to stable channel (7.3.1.2) where the issue does not exist. So overall I think there is definitely a "bug" to fix.

I really don't want any workarounds in our app that I will have to remove after this bug is fixed.

Fast deployment is NOT enabled, multidex is enabled.
Comment 5 Jon Douglas [MSFT] 2017-08-23 16:41:31 UTC
Marking this issue as a duplicate of another existing multidex / custom application bug which has already been confirmed and is under investigation. Please refer to this bug for future updates on a fix for this issue.

*** This bug has been marked as a duplicate of bug 55268 ***
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2017-09-06 03:39:12 UTC
## Note to Xamarin team

I am correcting the duplication status for tallying purposes based on the timing of the report and the description of the symptom "After downgrading to Xamarin.Android 7.3.1.2 everything works fine again." from Comment 0. 
 There is a indeed a regression in Xamarin.Android 7.4 compared to Xamarin.Android 7.3 that accounts for the _change_ behavior described in Comment 0 (related to missing newlines in the generated multidex.keep file).  The bug tracking that regression (Bug 59036) is therefore a better match for this bug for duplication status than Bug 55268.

*** This bug has been marked as a duplicate of bug 59036 ***