You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Xamarin.Android.Build.Tasks] fix bug in AndroidFastDeploymentType=Assemblies::Dexes
The app at runtime in the `ApplicationRunsWithDebuggerAndBreaks` test
was crashing at runtime with:
01-16 13:11:42.395 4273 4273 E monodroid-assembly: typemap: failed to stat TypeMap index file '/data/user/0/com.xamarin.applicationrunswithdebuggerandbreaks/files/.__override__/typemaps/typemap.index': No such file or directory
01-16 13:11:42.395 4273 4273 F monodroid-assembly: typemap: unable to load TypeMap data index from '/data/user/0/com.xamarin.applicationrunswithdebuggerandbreaks/files/.__override__/typemaps/typemap.index'
This only happens when `AndroidFastDeploymentType=Assemblies::Dexes` is
used, as it is the case when typemap files like this are fast deployed
and used at runtime.
What was even more odd, was the file seems to exist after a
`-t:Install`, but ends up missing after `-t:Run`:
> adb shell run-as com.xamarin.applicationrunswithdebuggerandbreaks ls -la files/.__override__/typemaps/typemap.index
ls: files/.__override__/typemaps/typemap.index: No such file or directory
It appears that `-t:Install` successfully deploys the file:
Pushed 3969 to /data/local/tmp/.xatools/typemap.index
DEBUG RunShellCommand emulator-5554 "run-as" "com.xamarin.applicationrunswithdebuggerandbreaks" "--user" "0" "files/.__tools__/xamarin.cp" "/data/local/tmp/.xatools/typemap.index" "files/.__override__/typemaps/typemap.index" "1705432079367" [5ms]
files/.__tools__/xamarin.cp returned: moved [/data/local/tmp/.xatools/typemap.index] to [files/.__override__/typemaps/typemap.index] modifieddate [1705432079367]
moved /data/local/tmp/.xatools/typemap.index to files/.__override__/typemaps/typemap.index
Installed files/.__override__/typemaps/typemap.index. [12ms]
NotifySync CopyFile obj\Debug\android\typemaps\typemap.index. [0ms]
But then `-t:Run` deletes the file!
Remove redundant file files/.__override__/typemaps/typemap.index
DEBUG RunShellCommand 0A041FDD400327 "run-as" "com.xamarin.applicationrunswithdebuggerandbreaks" "rm" "-Rf" "files/.__override__/typemaps/typemap.index" [29ms]
This happens because the `@(_AndroidTypeMapping)` item group is empty
during an incremental build:
* The `<GenerateJavaStubs/>` MSBuild task, during the first build
outputs `@(_AndroidTypeMapping)` items
* During an incremental build, the `_GenerateJavaStubs` MSBuild *target*
is skipped, and so the `@(_AndroidTypeMapping)` item group is empty!
* The `<FastDeploy/>` task happily deletes files that it thinks should
be removed.
For now, let's add logic to the `_GenerateJavaStubs` target to fill in
the `@(_AndroidTypeMapping)` item group during incremental builds:
<ItemGroup Condition=" '$(_InstantRunEnabled)' == 'True' and '@(_AndroidTypeMapping->Count())' == '0' ">
<_AndroidTypeMapping Include="$(_NativeAssemblySourceDir)typemaps\*" />
</ItemGroup>
`<ItemGroup>`s are still evaluated when a target is *skipped*, solving
the problem.
I assume this is working in `main`, because Xamarin.AndroidX.Migration
package was involved. It likely was running the `_GenerateJavaStubs`
target on every build. Will verify.
0 commit comments