This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 51480 - Improved fast deployment doesn't build my app
Summary: Improved fast deployment doesn't build my app
Status: NEEDINFO
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.1 (C9)
Hardware: PC Windows
: High major
Target Milestone: master
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2017-01-12 13:48 UTC by Michal Dobrodenka
Modified: 2017-08-03 08:00 UTC (History)
8 users (show)

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


Attachments
Xamarin.Android Version: 7.1.99.72 build log (755.61 KB, text/plain)
2017-02-10 23:31 UTC, Michal Dobrodenka
Details

Description Michal Dobrodenka 2017-01-12 13:48:38 UTC
# Steps to reproduce
Set <AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>, I've tried to set in in Xamarin.Android.Common.Before.targets or in csproj file.

# Expected behavior
To build app, deploy faster after code change.

# Actual behavior
Build error

# Supplemental info (logs, images, videos)

VS2015 output windows
Target _ExamineAndroidManifestChanges:
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : styleable 'AndroidManifestCompatibleScreensScreen' specifies unknown styleable 'AndroidManifest.AndroidManifestCompatibleScreens' as a parent. It has to be excluded.
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : styleable 'AndroidManifestSupportsInputInputType' specifies unknown styleable 'AndroidManifest.AndroidManifestSupportsInput' as a parent. It has to be excluded.
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : Manifest reference cache not found. The entire manifest check is disabled.
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018: The "DetectAndroidManifestDependencyChanges" task failed unexpectedly.\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tools.ResourceProcessors.ManifestUpdateSnapshot.ToLogString()\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tasks.DetectAndroidManifestDependencyChanges.DoExecute()\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tasks.DetectAndroidManifestDependencyChanges.Execute()\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

# Test environment (full version information)
VS2015, Xamarin.Android 7.1.0.19
Comment 1 Atsushi Eno 2017-01-26 08:49:23 UTC
What is your target Android? (OS version, emulator/device etc.) I found a case that Android N changed some framework internals that prevent assets fast deployment. (The improved fast deployment depends on Android internals just like Android Instant Run and things could happen.)

----
01-26 05:21:23.145 31755 31755 E AndroidRuntime: java.lang.RuntimeException: Unable to create application mono.android.incrementaldeployment.StubApplication: java.lang.IllegalStateException: java.lang.NoSuchFieldException: No field mAssets in class Landroid/content/res/Resources; (declaration of 'android.content.res.Resources' appears in /system/framework/framework.jar)
----
Comment 2 Michal Dobrodenka 2017-01-26 10:33:10 UTC
I've tried Target Android 5.0, 6.0, 7.1 and the result is still the same.

Now using Xamarin.Android 7.1.0.25/VS2015

1>Task "DetectAndroidManifestDependencyChanges" (TaskId:216)
1>  Task Parameter:AndroidManifest=obj\Debug\android\AndroidManifest.xml (TaskId:216)
1>  Task Parameter:ManifestReferenceCache=obj\Debug\manifestdatarecord.cache (TaskId:216)
1>  Task Parameter:ResourceDirectory=obj\Debug\res (TaskId:216)
1>  Task Parameter:PackageName=com.taphome.android.offline (TaskId:216)
1>  Task Parameter:AndroidSdkPath=C:\Users\mixal\AppData\Local\Android\android-sdk\ (TaskId:216)
1>  Task Parameter:TargetPlatform=21 (TaskId:216)
1>  DetectAndroidManifestDependencyChanges Task (TaskId:216)
1>    AndroidManifest: obj\Debug\android\AndroidManifest.xml (TaskId:216)
1>    ManifestReferenceCache: obj\Debug\manifestdatarecord.cache (TaskId:216)
1>    ResourceDirectory: obj\Debug\res (TaskId:216)
1>    PackageName: com.taphome.android.offline (TaskId:216)
1>    AndroidSdkPath: C:\Users\mixal\AppData\Local\Android\android-sdk\ (TaskId:216)
1>    TargetPlatform: 21 (TaskId:216)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : styleable 'AndroidManifestCompatibleScreensScreen' specifies unknown styleable 'AndroidManifest.AndroidManifestCompatibleScreens' as a parent. It has to be excluded.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : styleable 'AndroidManifestSupportsInputInputType' specifies unknown styleable 'AndroidManifest.AndroidManifestSupportsInput' as a parent. It has to be excluded.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): warning : Manifest reference cache not found. The entire manifest check is disabled.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018: The "DetectAndroidManifestDependencyChanges" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tools.ResourceProcessors.ManifestUpdateSnapshot.ToLogString()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tasks.DetectAndroidManifestDependencyChanges.DoExecute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Xamarin.Android.Tasks.DetectAndroidManifestDependencyChanges.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets(150,4): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>Done executing task "DetectAndroidManifestDependencyChanges" -- FAILED. (TaskId:216)
Comment 3 Atsushi Eno 2017-01-30 09:03:13 UTC
Thank you for the feedback. I think I figured out why this could happen. It is likely Windows-specific. A possible remedy is, if you have any "unresolved" project references (i.e. projects that fail to resolve) in your Android application project, try removing that from the project and see if it builds. That would fix it, if applicable.
Comment 4 Atsushi Eno 2017-01-30 09:15:14 UTC
This should be fixed internally - leaving QA team to verify it. [master 7701e46]
Comment 5 Michal Dobrodenka 2017-01-30 10:27:28 UTC
I tried it on mac, the error is different, hopefuly more descriptive:

		Errors:
		
		CSC: error CS2011: Unable to open response file: /var/folders/v4/265_jbh916vb_y1zvpx3gpb80000gn/T/tmp773e0238.tmp
		
		/Users/mixal11/Projects/Taphome/TapHome.Android/TapHome.Android.csproj (Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets (_ExamineAndroidManifestChanges target) ->

			/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets: error : Error executing task DetectAndroidManifestDependencyChanges: Could not load file or assembly 'Xamarin.Android.Tools.ResourceProcessors, Version=1.0.6229.34298, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Comment 6 Michal Dobrodenka 2017-01-30 11:40:27 UTC
I dont't see any unresolved project references, only clue for me is build on mac error about missing assembly "Xamarin.Android.Tools.ResourceProcessors" but don't know how to fix it.
Comment 7 Atsushi Eno 2017-01-30 14:50:47 UTC
Ah, that is another issue that we have already fixed (but not yet released). Technically, copying the same dll from Windows version should fix that specific issue, in case you'd like to try.

(Private bug recorded at https://bugzilla.xamarin.com/show_bug.cgi?id=51636)
Comment 8 Saurabh 2017-02-01 12:00:39 UTC
@Atsushi, I Have tried to reproduce this Issue with X.Android 7.1.0.19 but I am not seeing this Issue. I am getting build error which is mentioned in Bug 51636 

Could you please provide me steps how can I get proper error mentioned in comment#5 so that I can verify it?
Comment 9 narayanp 2017-02-01 13:21:20 UTC
I have checked this issue with latest Cycle 9 (Xamarin 4.3.0.627 (80a60c8) & Xamarin.Android 7.1.0.30 (3cde9f7)) and I am successfully able to build my 
app by setting: <AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType> into the apps csproj.

Screencast: https://www.screencast.com/t/HQVTRmrjmp

But, I am getting another issue that is already filed i.e., bug 51647.

Hence, I am closing this issue by marking it as verified.

Thanks!
Comment 10 Michal Dobrodenka 2017-02-01 13:28:01 UTC
@narayanp in video you have ';' instead of ':' in

<AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>

Thank you all, hope it will be fixed.

I as a reporter of the bug can say that simple test app is buildable in 7.1.0.23 with <AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>
but our company mobile app is not. It's a pitty I can not upload it here.

I'll test it with next RC release and let you know.
Comment 11 philip 2017-02-01 17:33:45 UTC
My app also still shows the same error with the latest cycle 9 beta as of today, so it seems that this is not properly fixed yet.
Comment 12 narayanp 2017-02-02 13:55:18 UTC
Thanks @Michal Dobrodenka, I have just checked this issue with ';' and ':' with template application of Android and observed that both are building fine.

As you have told in comment 10, that this issue is also working fine with the template app of Android for you also. Hence, this issue is not reproducible at our end. 

So, please feel free to reopen this issue if you are still getting this issue with release lane builds.

thanks
Comment 13 Michal Dobrodenka 2017-02-08 19:54:51 UTC
I've tested it with Xamarin.Android 7.1.0.34 and it is still a problem.

Build is generally ok, but I can not deploy it. Still the same error. There are no unresolved references in solution.

Small template app has no problem.
Comment 14 Michal Dobrodenka 2017-02-09 18:31:09 UTC
Tested with Xamarin.Android 7.1.0.34 on Mac:
		
		Errors:
		
		/Users/mixal11/Projects/Taphome/TapHome.Android/TapHome.Android.csproj (Build) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets (_ExamineAndroidManifestChanges target) ->

			/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets: error : Error executing task DetectAndroidManifestDependencyChanges: Object reference not set to an instance of an object
		
			 264 Warning(s)
Comment 15 Peter Collins 2017-02-10 18:28:34 UTC
@Michal or @philip, We believe a fix should now exist in recent master builds, if any of you would be willing to give the following a try. We haven't managed to reproduce the issue internally and these have not received any formal testing so your mileage may vary.

# Mac #
https://www.dropbox.com/s/dd7fftu511nh3xz/xamarin.android-7.1.99-75.pkg?dl=0

# Win #
https://www.dropbox.com/s/xk06ajq5kjyi3yf/Xamarin.VisualStudio_99.1.0.613.msi?dl=0
Comment 16 Michal Dobrodenka 2017-02-10 23:31:50 UTC
Created attachment 19792 [details]
Xamarin.Android Version: 7.1.99.72 build log
Comment 17 Michal Dobrodenka 2017-02-10 23:33:10 UTC
@Peter Collins Still no luck. Plz find attached complete build log from Xamarin Studio 6.2 on Windows with Xamarin.Android 7.1.99.72

If you want I can check it on Mac.
Comment 18 Luis Aguilera 2017-02-18 00:21:32 UTC
C9 is now closed. We'll move this bug to the next scheduled milestone, "15.1". We'll continue working on these issues, and will attempt to resolve them ASAP.
Comment 19 Jonathan Pryor 2017-03-23 17:50:42 UTC
We don't currently understand why there's a NullReferenceException. In the meantime, monodroid/307d63ad -- present in Xamarin.Android 7.1.0-38 and later -- attempts to be more resilient to `null` values, and will hopefully fix the NullReferenceException.

The current stable release is Xamarin.Android 7.1.0.43, which should contain the fix. Please try the current stable release.
Comment 20 Michal Dobrodenka 2017-03-23 20:35:08 UTC
With Xamarin.Android 7.1.0.43 I can build the app, but app fails to start. Without Improved fast deploy the app starts normally, from the same source code is current app in google play.

Start Log:

Forwarding debugger port 8884
Detecting existing process
> am start -n "com.taphome.android.offline/md57433e17c652419aebb1a4fa1a84759dc.DashboardActivity"
> Starting: Intent { cmp=com.taphome.android.offline/md57433e17c652419aebb1a4fa1a84759dc.DashboardActivity }

[art] Late-enabling -Xcheck:jni
[HyLog] I : openReadStream, /data/font/config/sfconfig.dat, case (2)
[HyLog] D: Wrong tag (927 : loadPreData() : frameworks/base/core/jni/android/graphics/TypefaceHyFontManager.cpp)
[HyLog] I : openReadStream, /data/font/config/sfconfig.dat, case (2)
[art] Rejecting re-init on previously-failed class java.lang.Class<md57433e17c652419aebb1a4fa1a84759dc.App>
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.taphome.android.offline, PID: 15665
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate application md57433e17c652419aebb1a4fa1a84759dc.App: java.lang.ClassNotFoundException: Didn't find class "md57433e17c652419aebb1a4fa1a84759dc.App" on path: DexPathList[[zip file "/data/app/com.taphome.android.offline-1/base.apk"],nativeLibraryDirectories=[/data/app/com.taphome.android.offline-1/lib/arm, /data/app/com.taphome.android.offline-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:622)
[AndroidRuntime] 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4768)
[AndroidRuntime] 	at android.app.ActivityThread.access$1600(ActivityThread.java:157)
[AndroidRuntime] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:148)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:5525)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "md57433e17c652419aebb1a4fa1a84759dc.App" on path: DexPathList[[zip file "/data/app/com.taphome.android.offline-1/base.apk"],nativeLibraryDirectories=[/data/app/com.taphome.android.offline-1/lib/arm, /data/app/com.taphome.android.offline-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:981)
[AndroidRuntime] 	at android.app.LoadedApk.makeApplication(LoadedApk.java:617)
[AndroidRuntime] 	... 9 more
[AndroidRuntime] 	Suppressed: java.lang.NoClassDefFoundError: md57433e17c652419aebb1a4fa1a84759dc.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: md57433e17c652419aebb1a4fa1a84759dc.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
Comment 21 Michal Dobrodenka 2017-03-23 20:48:20 UTC
Just to add, I tried to Clean project/delete bin/obj folders, tested on a real device/emulator.
Comment 22 Jonathan Pryor 2017-04-11 20:50:08 UTC
@Michal: Does your app contain an Application subclass written in C#? If so, this might be Bug #55050.
Comment 23 Michal Dobrodenka 2017-04-11 21:15:46 UTC
@Jonathan Pryor: yes!
Comment 24 Michal Dobrodenka 2017-07-09 07:23:39 UTC
Once Bug #55050 will be fixed I will recheck this bug and give info.
Comment 25 Michal Dobrodenka 2017-08-03 08:00:00 UTC
I had to spend hours and hours figuring out why multi-dex crashes. I found out that I have to name Application derived class. I also mentioned it in multidex.keep file.

From now Improved fast deplyment works! Bad news is that it does not bring any benefit. Not even second. Still around 50 sec on small code change in c#, eg string constant.

Note You need to log in before you can comment on or make changes to this bug.