Bug 44480 - New improved Fast Deployment feature crashes Android app with custom Application
Summary: New improved Fast Deployment feature crashes Android app with custom Application
Status: RESOLVED DUPLICATE of bug 44633
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.0 (C8)
Hardware: Macintosh Mac OS
: --- blocker
Target Milestone: 7.0.1 (C8SR1)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-09-19 08:24 UTC by Ville Ahti
Modified: 2016-10-05 17:24 UTC (History)
7 users (show)

Tags: BZCU
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 44633

Description Ville Ahti 2016-09-19 08:24:55 UTC
# Steps to reproduce
1. Create a new Android project.
2. Add a custom Android `Application` class like this one:
```
[Application]
    public class App : Application
    {

        public App(IntPtr javaReference, JniHandleOwnership transfer)
            : base(javaReference, transfer)
        {
        }

        public override void OnCreate()
        {
            base.OnCreate();
        }
    }
```
3. Enable new Fast Deployment feature in .csproj by adding this `<AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>`.
4. Start application in Android device.


# Expected behavior
Application should not crash.

# Actual behavior
Application crashes instantly.

# Supplemental info (logs, images, videos)
```
[art] Late-enabling -Xcheck:jni
[art] Rejecting re-init on previously-failed class java.lang.Class<md508e4246dedfc2c9ee7ed3d335045e5ee.App>
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: fi.taiste.applicationbug, PID: 15673
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application md508e4246dedfc2c9ee7ed3d335045e5ee.App: java.lang.ClassNotFoundException: Didn't find class "md508e4246dedfc2c9ee7ed3d335045e5ee.App" on path: DexPathList[[zip file "/data/app/fi.taiste.applicationbug-1/base.apk"],nativeLibraryDirectories=[/data/app/fi.taiste.applicationbug-1/lib/arm, /data/app/fi.taiste.applicationbug-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:582)
[AndroidRuntime] 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4779)
[AndroidRuntime] 	at android.app.ActivityThread.access$1600(ActivityThread.java:154)
[AndroidRuntime] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:234)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:5526)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "md508e4246dedfc2c9ee7ed3d335045e5ee.App" on path: DexPathList[[zip file "/data/app/fi.taiste.applicationbug-1/base.apk"],nativeLibraryDirectories=[/data/app/fi.taiste.applicationbug-1/lib/arm, /data/app/fi.taiste.applicationbug-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
[AndroidRuntime] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
[AndroidRuntime] 	at android.app.Instrumentation.newApplication(Instrumentation.java:982)
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:577)
[AndroidRuntime] 	... 9 more
[AndroidRuntime] 	Suppressed: java.lang.NoClassDefFoundError: md508e4246dedfc2c9ee7ed3d335045e5ee.App
[AndroidRuntime] 		at dalvik.system.DexFile.defineClassNative(Native Method)
[AndroidRuntime] 		at dalvik.system.DexFile.defineClass(DexFile.java:226)
[AndroidRuntime] 		at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
[AndroidRuntime] 		at dalvik.system.DexPathList.findClass(DexPathList.java:338)
[AndroidRuntime] 		at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
[AndroidRuntime] 		... 13 more
[AndroidRuntime] 	Suppressed: java.lang.ClassNotFoundException: md508e4246dedfc2c9ee7ed3d335045e5ee.App
[AndroidRuntime] 		at java.lang.Class.classForName(Native Method)
[AndroidRuntime] 		at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
[AndroidRuntime] 		at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
[AndroidRuntime] 		at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
[AndroidRuntime] 		... 12 more
[AndroidRuntime] 	Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
```
# Test environment (full version information)
```
Xamarin Studio Business
Version 6.1 (build 5441)
Installation UUID: 0bd107a6-75ed-4f58-96fc-6485ed6545a2
Runtime:
	Mono 4.6.0 (mono-4.6.0-branch/746756c) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406000245

NuGet
Version: 3.4.3.0

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

Apple Developer Tools
Xcode 7.3.1 (10188.1)
Build 7D1014

Xamarin.Mac
Not Installed

Xamarin.iOS
Version: 10.0.0.6 (Xamarin Business)
Hash: 6c3fee4
Branch: xcode8
Build date: 2016-09-09 13:01:32-0400

Xamarin.Android
Version: 7.0.0.18 (Xamarin Business)
Android SDK: /Users/villeahti/Library/Android/sdk/
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 24.0.1
SDK Build Tools Version: 23.0.3

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

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

Xamarin Android Player
Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

Xamarin Inspector
Version: 0.10.0.0
Hash: e931a52
Branch: master
Build date: Thu, 18 Aug 2016 17:46:46 GMT

Build Information
Release ID: 601005441
Git revision: 68292d1ab289911c815ddc715dd7cc29a9752f9f
Build date: 2016-09-09 04:43:23-04
Xamarin addins: ed25d008672663eeb9db55f1ccecb3c24d2fd3b2
Build lane: monodevelop-lion-cycle8

Operating System
Mac OS X 10.11.6
Darwin My-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

Enabled user installed addins
AutoTestRunner 1.0
MFractor.Installer 2.2.0
MFractor 2.04.03
Addin Maker 1.3.2
NuGet Package Management Extensions 0.11.1
Paket 0.1
QuickJump 1.0.0.3
QuickSearch 1.0.1
View In Android Studio 0.3
SpecFlow Support 1.9.1.0
Xamarin Inspector 0.10.0.0
Manifest.addin 0.0.0.0
```
Comment 1 Mohammad Zekrallah 2016-09-26 08:48:17 UTC
I confirm the same bug .. it started appearing right after updating to Xamarin 6.0 and 6.1.1 doesn't solve it either .. it happens in debug mode only .. I have DEX and fast deployment enabled. 

=== Xamarin Studio Business ===

Version 6.1.1 (build 15)
Installation UUID: 5afdb4e6-1d91-47f2-8fc2-59000d17061a
Runtime:
	Mono 4.6.0 (mono-4.6.0-branch/8d0eee7) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406000251

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 7.0.1.1 (Xamarin Business)
Android SDK: /Volumes/Data/Android/SDK
	Supported Android versions:
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24.0.2

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

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

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 8.0 (11246)
Build 8A218a

=== Xamarin.Mac ===

Not Installed

=== Xamarin.iOS ===

Version: 10.0.1.5 (Xamarin Business)
Hash: c9eb5b0
Branch: xcode8
Build date: 2016-09-16 20:50:23-0400

=== Build Information ===

Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0

=== Operating System ===

Mac OS X 10.11.6
Darwin Mohammads-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0
    Mon Aug 29 20:21:34 PDT 2016
    root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Redth's Addins 1.0.2
Comment 2 Jon Douglas [MSFT] 2016-09-26 22:01:00 UTC
Sounds related to: https://bugzilla.xamarin.com/show_bug.cgi?id=44633
Comment 3 Peter Collins 2016-10-05 17:24:35 UTC
I believe this to be a dupe of the later reported #44633 as Jon mentioned, a fix for which should be available in the public updater channels in the coming week or two. Please reopen if the upcoming fix does not resolve this issue for you.

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