Skip to content

Commit f3a09e7

Browse files
committed
Update *.apkdesc files.
Otherwise update unit tests.
1 parent 76d4e82 commit f3a09e7

File tree

8 files changed

+114
-56
lines changed

8 files changed

+114
-56
lines changed

Documentation/workflow/DevelopmentTips.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
Tips and tricks while developing Xamarin.Android.
44

5+
# Run MSBuild-Based On-Device Unit Tests
6+
7+
The [`tests/MSBuildDeviceIntegration`](tests/MSBuildDeviceIntegration)
8+
directory contains NUnit-based unit tests which need to run against an attached
9+
Android device (hardware or emulator). There are *lots* of tests in here, and
10+
running them all can take a significant amount of time.
11+
12+
If you need to run only *one* `[Test]` method, you can use
13+
[`dotnet test --filter`](https://docs.microsoft.com/dotnet/core/testing/selective-unit-tests?pivots=mstest):
14+
15+
./dotnet-local.sh test bin/TestDebug/MSBuildDeviceIntegration/net6.0/MSBuildDeviceIntegration.dll --filter "Name~TypeAndMemberRemapping"
16+
517
# Update directory
618

719
When a Xamarin.Android app launches on an Android device, and the app was

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ static class ResourceData
1818
static Lazy<byte []> apacheHttpClient_cs = new Lazy<byte []> (() => GetResourceData ("ApacheHttpClient.cs"));
1919
static Lazy<byte []> javadocCopyright = new Lazy<byte []> (() => GetResourceData ("javadoc-copyright.xml"));
2020
static Lazy<byte []> javaSourceTestExtension = new Lazy<byte []> (() => GetResourceData ("JavaSourceTestExtension.java"));
21-
static Lazy<byte []> remapActivity = new Lazy<byte []> (() => GetResourceData ("RemapActivity.java"));
21+
static Lazy<byte []> remapActivityJava = new Lazy<byte []> (() => GetResourceData ("RemapActivity.java"));
22+
static Lazy<byte []> remapActivityXml = new Lazy<byte []> (() => GetResourceData ("RemapActivity.xml"));
2223

2324
public static byte[] JavaSourceJarTestJar => javaSourceJarTestJar.Value;
2425
public static byte[] JavaSourceJarTestSourcesJar => javaSourceJarTestSourcesJar.Value;
@@ -29,11 +30,15 @@ static class ResourceData
2930
public static byte [] JavadocCopyright => javadocCopyright.Value;
3031

3132
public static string JavaSourceTestExtension => Encoding.ASCII.GetString (javaSourceTestExtension.Value);
32-
public static string RemapActivity => Encoding.UTF8.GetString (remapActivity.Value);
33+
public static string RemapActivityJava => Encoding.UTF8.GetString (remapActivityJava.Value);
34+
public static string RemapActivityXml => Encoding.UTF8.GetString (remapActivityXml.Value);
3335

3436
static byte[] GetResourceData (string name)
3537
{
3638
using var s = typeof (ResourceData).Assembly.GetManifestResourceStream (name);
39+
if (s == null) {
40+
throw new NotSupportedException ($"Could not find resource `{name}` in assembly `{typeof (ResourceData).Assembly}`!");
41+
}
3742
using var m = new MemoryStream (checked ((int) s.Length));
3843
s.CopyTo (m);
3944
return m.ToArray ();

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,67 @@
55
"Size": 3032
66
},
77
"assemblies/Java.Interop.dll": {
8-
"Size": 54979
8+
"Size": 60616
99
},
1010
"assemblies/Mono.Android.dll": {
11-
"Size": 88763
11+
"Size": 153083
1212
},
1313
"assemblies/rc.bin": {
1414
"Size": 1083
1515
},
16+
"assemblies/System.Collections.Concurrent.dll": {
17+
"Size": 9171
18+
},
19+
"assemblies/System.Collections.dll": {
20+
"Size": 4584
21+
},
22+
"assemblies/System.Collections.NonGeneric.dll": {
23+
"Size": 6716
24+
},
25+
"assemblies/System.Console.dll": {
26+
"Size": 6898
27+
},
28+
"assemblies/System.IO.Compression.dll": {
29+
"Size": 16871
30+
},
1631
"assemblies/System.Linq.dll": {
17-
"Size": 10111
32+
"Size": 10332
33+
},
34+
"assemblies/System.Net.Http.dll": {
35+
"Size": 65684
36+
},
37+
"assemblies/System.Net.Primitives.dll": {
38+
"Size": 21531
39+
},
40+
"assemblies/System.Net.Requests.dll": {
41+
"Size": 3522
1842
},
1943
"assemblies/System.Private.CoreLib.dll": {
20-
"Size": 537771
44+
"Size": 624995
45+
},
46+
"assemblies/System.Private.Uri.dll": {
47+
"Size": 38378
48+
},
49+
"assemblies/System.Private.Xml.dll": {
50+
"Size": 145345
2151
},
2252
"assemblies/System.Runtime.dll": {
2353
"Size": 2415
2454
},
55+
"assemblies/System.Security.Cryptography.dll": {
56+
"Size": 7697
57+
},
58+
"assemblies/System.Text.RegularExpressions.dll": {
59+
"Size": 9991
60+
},
2561
"assemblies/UnnamedProject.dll": {
26-
"Size": 3550
62+
"Size": 3548
2763
},
2864
"classes.dex": {
29-
"Size": 347628
65+
"Size": 348440
3066
},
3167
"lib/arm64-v8a/libmonodroid.so": {
32-
"Size": 483840
68+
"Size": 484160
3369
},
3470
"lib/arm64-v8a/libmonosgen-2.0.so": {
3571
"Size": 4693664
@@ -44,16 +80,16 @@
4480
"Size": 146816
4581
},
4682
"lib/arm64-v8a/libxamarin-app.so": {
47-
"Size": 9232
83+
"Size": 15904
4884
},
4985
"META-INF/BNDLTOOL.RSA": {
5086
"Size": 1213
5187
},
5288
"META-INF/BNDLTOOL.SF": {
53-
"Size": 2469
89+
"Size": 3773
5490
},
5591
"META-INF/MANIFEST.MF": {
56-
"Size": 2342
92+
"Size": 3646
5793
},
5894
"res/drawable-hdpi-v4/icon.png": {
5995
"Size": 4762
@@ -80,5 +116,5 @@
80116
"Size": 1904
81117
}
82118
},
83-
"PackageSize": 3020692
119+
"PackageSize": 3521396
84120
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"Size": 7114
99
},
1010
"assemblies/Java.Interop.dll": {
11-
"Size": 61933
11+
"Size": 66697
1212
},
1313
"assemblies/Mono.Android.dll": {
14-
"Size": 445015
14+
"Size": 448225
1515
},
1616
"assemblies/mscorlib.dll": {
1717
"Size": 3892
@@ -41,7 +41,7 @@
4141
"Size": 6183
4242
},
4343
"assemblies/System.Console.dll": {
44-
"Size": 6955
44+
"Size": 7059
4545
},
4646
"assemblies/System.Core.dll": {
4747
"Size": 2059
@@ -86,13 +86,13 @@
8686
"Size": 778570
8787
},
8888
"assemblies/System.Private.DataContractSerialization.dll": {
89-
"Size": 192732
89+
"Size": 192829
9090
},
9191
"assemblies/System.Private.Uri.dll": {
9292
"Size": 43511
9393
},
9494
"assemblies/System.Private.Xml.dll": {
95-
"Size": 222925
95+
"Size": 228438
9696
},
9797
"assemblies/System.Private.Xml.Linq.dll": {
9898
"Size": 17268
@@ -119,19 +119,19 @@
119119
"Size": 1914
120120
},
121121
"assemblies/UnnamedProject.dll": {
122-
"Size": 117240
122+
"Size": 117237
123123
},
124124
"assemblies/Xamarin.AndroidX.Activity.dll": {
125-
"Size": 5942
125+
"Size": 5941
126126
},
127127
"assemblies/Xamarin.AndroidX.AppCompat.AppCompatResources.dll": {
128-
"Size": 5965
128+
"Size": 5964
129129
},
130130
"assemblies/Xamarin.AndroidX.AppCompat.dll": {
131-
"Size": 112444
131+
"Size": 112443
132132
},
133133
"assemblies/Xamarin.AndroidX.CardView.dll": {
134-
"Size": 6683
134+
"Size": 6681
135135
},
136136
"assemblies/Xamarin.AndroidX.CoordinatorLayout.dll": {
137137
"Size": 16474
@@ -140,16 +140,16 @@
140140
"Size": 96576
141141
},
142142
"assemblies/Xamarin.AndroidX.DrawerLayout.dll": {
143-
"Size": 14137
143+
"Size": 14138
144144
},
145145
"assemblies/Xamarin.AndroidX.Fragment.dll": {
146-
"Size": 39795
146+
"Size": 39794
147147
},
148148
"assemblies/Xamarin.AndroidX.Legacy.Support.Core.UI.dll": {
149-
"Size": 5997
149+
"Size": 5996
150150
},
151151
"assemblies/Xamarin.AndroidX.Lifecycle.Common.dll": {
152-
"Size": 6465
152+
"Size": 6464
153153
},
154154
"assemblies/Xamarin.AndroidX.Lifecycle.LiveData.Core.dll": {
155155
"Size": 6539
@@ -158,25 +158,25 @@
158158
"Size": 3140
159159
},
160160
"assemblies/Xamarin.AndroidX.Loader.dll": {
161-
"Size": 12540
161+
"Size": 12541
162162
},
163163
"assemblies/Xamarin.AndroidX.RecyclerView.dll": {
164-
"Size": 84553
164+
"Size": 84554
165165
},
166166
"assemblies/Xamarin.AndroidX.SavedState.dll": {
167-
"Size": 4944
167+
"Size": 4945
168168
},
169169
"assemblies/Xamarin.AndroidX.SwipeRefreshLayout.dll": {
170170
"Size": 10254
171171
},
172172
"assemblies/Xamarin.AndroidX.ViewPager.dll": {
173-
"Size": 17853
173+
"Size": 17854
174174
},
175175
"assemblies/Xamarin.Forms.Core.dll": {
176176
"Size": 528450
177177
},
178178
"assemblies/Xamarin.Forms.Platform.Android.dll": {
179-
"Size": 384800
179+
"Size": 384799
180180
},
181181
"assemblies/Xamarin.Forms.Platform.dll": {
182182
"Size": 56878
@@ -185,13 +185,13 @@
185185
"Size": 60774
186186
},
187187
"assemblies/Xamarin.Google.Android.Material.dll": {
188-
"Size": 40005
188+
"Size": 40004
189189
},
190190
"classes.dex": {
191-
"Size": 3460300
191+
"Size": 3460820
192192
},
193193
"lib/arm64-v8a/libmonodroid.so": {
194-
"Size": 483840
194+
"Size": 484160
195195
},
196196
"lib/arm64-v8a/libmonosgen-2.0.so": {
197197
"Size": 4693664
@@ -1961,5 +1961,5 @@
19611961
"Size": 341228
19621962
}
19631963
},
1964-
"PackageSize": 8393037
1964+
"PackageSize": 8405325
19651965
}

tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<Compile Include="..\..\tools\assembly-store-reader\AssemblyStore*.cs" />
2828
<EmbeddedResource Include="Resources\LinkDescTest\*.*" />
2929
</ItemGroup>
30+
<ItemGroup>
31+
<EmbeddedResource Include="Resources\RemapActivity*">
32+
<LogicalName>%(FileName)%(Extension)</LogicalName>
33+
</EmbeddedResource>
34+
</ItemGroup>
3035

3136
<ItemGroup>
3237
<PackageReference Include="NodaTime" Version="2.4.5" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<replacements>
2+
<replace-type from="android/app/Activity" to="example/RemapActivity" />
3+
<replace-method
4+
source-type="example/RemapActivity"
5+
source-method-name="onCreate"
6+
target-type="example/RemapActivity"
7+
target-method-name="onMyCreate" target-method-instance-to-static="false" />
8+
<replace-method
9+
source-type="android/view/View"
10+
source-method-name="setOnClickListener"
11+
target-type="example/ViewHelper"
12+
target-method-name="mySetOnClickListener" target-method-instance-to-static="true" />
13+
</replacements>

tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,33 +166,20 @@ public void TypeAndMemberRemapping ([Values (false, true)] bool isRelease)
166166
var proj = new XASdkProject () {
167167
IsRelease = isRelease,
168168
OtherBuildItems = {
169-
new AndroidItem._AndroidRemapMembers ("remap.xml") {
170-
TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8"" ?>
171-
<replacements>
172-
<replace-type from='android/app/Activity' to='example/RemapActivity' />
173-
<replace-method
174-
source-type='example/RemapActivity'
175-
source-method-name='onCreate'
176-
target-type='example/RemapActivity'
177-
target-method-name='onMyCreate' target-method-instance-to-static='false' />
178-
<replace-method
179-
source-type='android/view/View'
180-
source-method-name='setOnClickListener'
181-
target-type='example/ViewHelper'
182-
target-method-name='mySetOnClickListener' target-method-instance-to-static='true' />
183-
</replacements>
184-
",
169+
new AndroidItem._AndroidRemapMembers ("RemapActivity.xml") {
170+
Encoding = Encoding.UTF8,
171+
TextContent = () => ResourceData.RemapActivityXml,
185172
},
186173
new AndroidItem.AndroidJavaSource ("RemapActivity.java") {
187-
Encoding = Encoding.UTF8,
188-
TextContent = () => ResourceData.RemapActivity,
174+
Encoding = new UTF8Encoding (encoderShouldEmitUTF8Identifier: false),
175+
TextContent = () => ResourceData.RemapActivityJava,
189176
Metadata = {
190177
{ "Bind", "True" },
191178
},
192179
},
193180
},
194181
};
195-
proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", "global::Example.RemapActivity");
182+
proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": global::Example.RemapActivity");
196183
proj.SetRuntimeIdentifier (DeviceAbi);
197184
var relativeProjDir = Path.Combine ("temp", TestName);
198185
var fullProjDir = Path.Combine (Root, relativeProjDir);
@@ -206,7 +193,7 @@ public void TypeAndMemberRemapping ([Values (false, true)] bool isRelease)
206193
Assert.IsTrue (dotnet.Run (), "`dotnet run` should succeed");
207194

208195
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity",
209-
Path.Combine (fullProjDir, "logcat.log"), 30);
196+
Path.Combine (fullProjDir, "logcat.log"));
210197
Assert.IsTrue (didLaunch, "MainActivity should have launched!");
211198
var logcatOutput = File.ReadAllText (Path.Combine (fullProjDir, "logcat.log"));
212199

0 commit comments

Comments
 (0)