Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@
path = external/opentk
url = https://github.com/mono/opentk.git
branch = master
[submodule "external/libzip"]
path = external/libzip
url = https://github.com/nih-at/libzip.git
branch = master
[submodule "external/LibZipSharp"]
path = external/LibZipSharp
url = https://github.com/grendello/LibZipSharp.git
branch = master
4 changes: 4 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<JavaInteropSourceDirectory Condition=" '$(JavaInteropSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\Java.Interop</JavaInteropSourceDirectory>
<MonoSourceDirectory>$(MSBuildThisFileDirectory)external\mono</MonoSourceDirectory>
<OpenTKSourceDirectory>$(MSBuildThisFileDirectory)external\opentk</OpenTKSourceDirectory>
<LibZipSourceDirectory Condition=" '$(LibZipSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\libzip</LibZipSourceDirectory>
<LibZipSharpSourceDirectory Condition=" '$(LibZipSharpSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\LibZipSharp</LibZipSharpSourceDirectory>
<SqliteSourceDirectory Condition=" '$(SqliteSourceDirectory)' == '' ">$(MSBuildThisFileDirectory)external\sqlite</SqliteSourceDirectory>
<XamarinAndroidSourcePath>$(MSBuildThisFileDirectory)</XamarinAndroidSourcePath>
<AllSupported32BitTargetAndroidAbis>armeabi;armeabi-v7a;x86</AllSupported32BitTargetAndroidAbis>
Expand All @@ -40,6 +42,8 @@
<MonoSourceFullPath>$([System.IO.Path]::GetFullPath ('$(MonoSourceDirectory)'))</MonoSourceFullPath>
<SqliteSourceFullPath>$([System.IO.Path]::GetFullPath ('$(SqliteSourceDirectory)'))</SqliteSourceFullPath>
<OpenTKSourceFullPath>$([System.IO.Path]::GetFullPath ('$(OpenTKSourceDirectory)'))</OpenTKSourceFullPath>
<LibZipSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LibZipSourceDirectory)'))</LibZipSourceFullPath>
<LibZipSharpSourceFullPath>$([System.IO.Path]::GetFullPath ('$(LibZipSharpSourceDirectory)'))</LibZipSharpSourceFullPath>
</PropertyGroup>
<!--
"Fixup" $(AndroidSupportedHostJitAbis) so that Condition attributes elsewhere
Expand Down
22 changes: 22 additions & 0 deletions Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.Boots
EndProject
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "mono-runtimes", "build-tools\mono-runtimes\mono-runtimes.mdproj", "{C03E6CF1-7460-4CDC-A4AB-292BBC0F61F2}"
EndProject
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "libzip", "build-tools\libzip\libzip.mdproj", "{900A0F71-BAAD-417A-8D1A-8D330297CDD0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jnienv-gen", "build-tools\jnienv-gen\jnienv-gen.csproj", "{AFB8F6D1-6EA9-42C3-950B-98F34C669AD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api-merge", "build-tools\api-merge\api-merge.csproj", "{3FC3E78B-F7D4-42EA-BBE8-4535DF42BFF8}"
Expand Down Expand Up @@ -79,6 +81,8 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "sqlite-xamarin", "src\sqlit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "src\OpenTK-1.0\OpenTK.csproj", "{5EB9E888-E357-417E-9F39-DDEC195CE47F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libZipSharp", "external\LibZipSharp\libZipSharp.csproj", "{E248B2CA-303B-4645-ADDC-9D4459D550FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
Expand Down Expand Up @@ -358,6 +362,22 @@ Global
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.Release|AnyCPU.ActiveCfg = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.Release|AnyCPU.Build.0 = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{900A0F71-BAAD-417A-8D1A-8D330297CDD0}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.Release|AnyCPU.Build.0 = Release|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
{E248B2CA-303B-4645-ADDC-9D4459D550FD}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
Expand Down Expand Up @@ -395,6 +415,8 @@ Global
{26781D3A-FF20-4F55-9824-C8A06AA9E484} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{B8F799C5-D7CE-4E09-9CE6-BAA4173E7EC8} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{5EB9E888-E357-417E-9F39-DDEC195CE47F} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{900A0F71-BAAD-417A-8D1A-8D330297CDD0} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{E248B2CA-303B-4645-ADDC-9D4459D550FD} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
Expand Down
8 changes: 4 additions & 4 deletions build-tools/android-toolchain/android-toolchain.targets
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@
DependsOnTargets="_SetMxeToolchainMakefileTimeToLastCommitTimestamp"
Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))"
Inputs="..\..\external\mxe\Makefile"
Outputs="$(AndroidMxeFullPath)\bin\i686-w64-mingw32.static-gcc">
Outputs="$(AndroidMxeFullPath)\bin\i686-w64-mingw32.static-gcc;$(AndroidMxeFullPath)\bin\i686-w64-mingw32.static-cmake">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the update to Outputs? The make MXE_TARGETS value is unchanged, so it won't actually build i686-w64-mingw32.static-cmake, will it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Exec
Command="make $(MAKEFLAGS) MXE_TARGETS=&quot;i686-w64-mingw32.static&quot; gcc PREFIX=&quot;$(AndroidMxeFullPath)&quot;"
Command="make $(MAKEFLAGS) MXE_TARGETS=&quot;i686-w64-mingw32.static&quot; gcc cmake zlib PREFIX=&quot;$(AndroidMxeFullPath)&quot;"
WorkingDirectory="..\..\external\mxe"
/>
</Target>
<Target Name="_CreateMxeW64Toolchain"
DependsOnTargets="_SetMxeToolchainMakefileTimeToLastCommitTimestamp"
Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))"
Inputs="..\..\external\mxe\Makefile"
Outputs="$(AndroidMxeFullPath)\bin\x86_64-w64-mingw32.static-gcc">
Outputs="$(AndroidMxeFullPath)\bin\x86_64-w64-mingw32.static-gcc;$(AndroidMxeFullPath)\bin\x86_64-w64-mingw32.static-cmake">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Exec
Command="make $(MAKEFLAGS) MXE_TARGETS=&quot;x86_64-w64-mingw32.static&quot; gcc PREFIX=&quot;$(AndroidMxeFullPath)&quot;"
Command="make $(MAKEFLAGS) MXE_TARGETS=&quot;x86_64-w64-mingw32.static&quot; gcc cmake zlib PREFIX=&quot;$(AndroidMxeFullPath)&quot;"
WorkingDirectory="..\..\external\mxe"
/>
</Target>
Expand Down
32 changes: 32 additions & 0 deletions build-tools/libzip/libzip.mdproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{900A0F71-BAAD-417A-8D1A-8D330297CDD0}</ProjectGuid>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\bin\$(Configuration)</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<BuildDependsOn>
ResolveReferences;
_Configure;
_Make
</BuildDependsOn>
</PropertyGroup>
<Import Project="libzip.targets" />
<ItemGroup>
<ProjectReference Include="..\android-toolchain\android-toolchain.mdproj">
<Project>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</Project>
<Name>android-toolchain</Name>
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions build-tools/libzip/libzip.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<_LibZipTarget Include="host-mxe-Win64" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':mxe-Win64:'))">
<CMake>$(AndroidMxeFullPath)\bin\x86_64-w64-mingw32.static-cmake</CMake>
<CMakeFlags></CMakeFlags>
<OutputLibrary>libzip.dll</OutputLibrary>
<OutputLibraryPath>lib/libzip.dll</OutputLibraryPath>
</_LibZipTarget>
<_LibZipTarget Include="host-Darwin" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':Darwin:'))">
<CMake>cmake</CMake>
<CMakeFlags>-DCMAKE_OSX_ARCHITECTURES=&quot;i386;x86_64&quot;</CMakeFlags>
<OutputLibrary>libzip.3.0.dylib</OutputLibrary>
<OutputLibraryPath>lib/libzip.3.0.dylib</OutputLibraryPath>
</_LibZipTarget>
<_LibZipTarget Include="host-Linux" Condition="$(AndroidSupportedHostJitAbisForConditionalChecks.Contains (':Linux:'))">
<CMake>cmake</CMake>
<CMakeFlags></CMakeFlags>
<OutputLibrary>libzip.so</OutputLibrary>
<OutputLibraryPath>libzip.so</OutputLibraryPath>
</_LibZipTarget>
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions build-tools/libzip/libzip.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
</PropertyGroup>
</Project>
35 changes: 35 additions & 0 deletions build-tools/libzip/libzip.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_SourceTopDir>..\..</_SourceTopDir>
</PropertyGroup>
<UsingTask AssemblyFile="$(_SourceTopDir)\bin\Build$(Configuration)\Xamarin.Android.Tools.BootstrapTasks.dll" TaskName="Xamarin.Android.Tools.BootstrapTasks.GetNugetPackageBasePath" />
<Import Project="libzip.props" />
<Import Project="libzip.projitems" />
<Target Name="_SetCMakeListsTxtTimeToLastCommitTimestamp">
<Exec
Command="touch -m -t `git log -1 --format=%25cd --date=format-local:%25Y%25m%25d%25H%25M.%25S` CMakeLists.txt"
WorkingDirectory="$(LibZipSourceFullPath)"
/>
</Target>
<Target Name="_Configure"
DependsOnTargets="_SetCMakeListsTxtTimeToLastCommitTimestamp"
Inputs="$(LibZipSourceFullPath\CMakeLists.txt"
Outputs="$(IntermediateOutputPath)\%(_LibZipTarget.Identity)\Makefile">
<MakeDir Directories="@(_LibZipTarget->'$(IntermediateOutputPath)\%(Identity)')" />
<Exec
Command="%(_LibZipTarget.CMake) %(_LibZipTarget.CMakeFlags) $(LibZipSourceFullPath)"
WorkingDirectory="@(_LibZipTarget->'$(IntermediateOutputPath)\%(Identity)')"
/>
</Target>
<Target Name="_Make"
Inputs="$(IntermediateOutputPath)\%(_LibZipTarget.Identity)\Makefile"
Outputs="$(IntermediateOutputPath)\%(_LibZipTarget.Identity)\%(_LibZipTarget.OutputLibraryPath)">
<Exec
Command="make"
WorkingDirectory="$(IntermediateOutputPath)\%(_LibZipTarget.Identity)"
/>
<Copy SourceFiles="@(_LibZipTarget->'$(IntermediateOutputPath)\%(Identity)\%(_LibZipTarget.OutputLibraryPath)')"
DestinationFiles="@(_LibZipTarget->'$(OutputPath)\lib\xbuild\Xamarin\Android\%(_LibZipTarget.OutputLibrary)')"/>
</Target>
</Project>
1 change: 1 addition & 0 deletions external/LibZipSharp
Submodule LibZipSharp added at 16c468
1 change: 1 addition & 0 deletions external/libzip
Submodule libzip added at 1d8b1a
54 changes: 24 additions & 30 deletions src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using System.Text;
using System.Text.RegularExpressions;

using System.IO.Compression;

using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;

Expand All @@ -18,6 +16,7 @@
using ArchiveFileList = System.Collections.Generic.List<System.Tuple<string, string>>;
using Mono.Cecil;
using Xamarin.Android.Build.Utilities;
using Xamarin.Tools.Zip;

namespace Xamarin.Android.Tasks
{
Expand Down Expand Up @@ -111,12 +110,12 @@ void ExecuteWithAbi (string supportedAbis, string apkInputPath, string apkOutput
ArchiveFileList files = new ArchiveFileList ();
if (apkInputPath != null)
File.Copy (apkInputPath, apkOutputPath + "new", overwrite: true);
using (var apk = ZipFile.Open (apkOutputPath + "new", apkInputPath != null ? ZipArchiveMode.Update : ZipArchiveMode.Create)) {
using (var apk = ZipArchive.Open (apkOutputPath + "new", apkInputPath != null ? FileMode.Open : FileMode.Create )) {
apk.AddEntry ("NOTICE",
Assembly.GetExecutingAssembly ().GetManifestResourceStream ("NOTICE.txt"));

// Add classes.dx
apk.AddFiles (DalvikClasses, string.Empty);
apk.AddFiles (DalvikClasses);

if (EmbedAssemblies && !BundleAssemblies)
AddAssemblies (apk);
Expand All @@ -128,7 +127,7 @@ void ExecuteWithAbi (string supportedAbis, string apkInputPath, string apkOutput
AddNativeLibrariesFromAssemblies (apk, supportedAbis);

foreach (ITaskItem typemap in TypeMappings) {
apk.AddFile (typemap.ItemSpec, directoryPathInZip: "", compressionLevel: CompressionLevel.NoCompression);
apk.AddFile (typemap.ItemSpec, compressionMethod: CompressionMethod.Store);
}

foreach (var file in files) {
Expand All @@ -138,7 +137,7 @@ void ExecuteWithAbi (string supportedAbis, string apkInputPath, string apkOutput
Log.LogWarning (null, "XA4301", null, file.Item1, 0, 0, 0, 0, "Apk already contains the item {0}; ignoring.", item);
continue;
}
apk.AddFile (file.Item1, file.Item2);
apk.AddFile (file.Item1, item);
}
if (_Debug)
AddGdbservers (apk, files, supportedAbis, debugServer);
Expand All @@ -156,23 +155,22 @@ void ExecuteWithAbi (string supportedAbis, string apkInputPath, string apkOutput
jarFilePaths = MonoAndroidHelper.DistinctFilesByContent (jarFilePaths);

foreach (var jarFile in jarFilePaths) {
using (var jar = new ZipArchive (File.Open (jarFile, FileMode.Open), ZipArchiveMode.Read)) {
foreach (var jarItem in jar.Entries.Where (ze => !ze.IsDirectory () && !ze.FullName.StartsWith ("META-INF") && !ze.FullName.EndsWith (".class") && !ze.FullName.EndsWith (".java") && !ze.FullName.EndsWith ("MANIFEST.MF"))) {
byte[] data;
using (var d = new System.IO.MemoryStream ())
using (var i = jarItem.Open ()) {
i.CopyTo (d);
using (var jar = ZipArchive.Open (File.Open (jarFile, FileMode.Open))) {
foreach (var jarItem in jar.Where (ze => !ze.IsDirectory && !ze.FullName.StartsWith ("META-INF") && !ze.FullName.EndsWith (".class") && !ze.FullName.EndsWith (".java") && !ze.FullName.EndsWith ("MANIFEST.MF"))) {
byte [] data;
using (var d = new System.IO.MemoryStream ()) {
jarItem.Extract (d);
data = d.ToArray ();
}
if (apk.Entries.Any (e => e.FullName == jarItem.FullName))
if (apk.Any (e => e.FullName == jarItem.FullName))
Log.LogMessage ("Warning: failed to add jar entry {0} from {1}: the same file already exists in the apk", jarItem.FullName, Path.GetFileName (jarFile));
else
apk.AddEntry (jarItem.FullName, data);
apk.AddEntry (data, jarItem.FullName);
}
}
}
if (StubApplicationDataFile != null && File.Exists (StubApplicationDataFile))
AddZipEntry (apk, StubApplicationDataFile, string.Empty);
apk.AddFile (StubApplicationDataFile, Path.GetFileName (StubApplicationDataFile));
}
MonoAndroidHelper.CopyIfZipChanged (apkOutputPath + "new", apkOutputPath);
File.Delete (apkOutputPath + "new");
Expand Down Expand Up @@ -244,19 +242,14 @@ public override bool Execute ()
return !Log.HasLoggedErrors;
}

void AddZipEntry (ZipArchive apk, string file, string path)
{
apk.AddFile (file, path);
}

private void AddAssemblies (ZipArchive apk)
{
bool debug = _Debug;
bool use_shared_runtime = String.Equals (UseSharedRuntime, "true", StringComparison.OrdinalIgnoreCase);

foreach (ITaskItem assembly in ResolvedUserAssemblies) {
// Add assembly
apk.AddFile (assembly.ItemSpec, GetTargetDirectory (assembly.ItemSpec), compressionLevel: CompressionLevel.NoCompression);
apk.AddFile (assembly.ItemSpec, GetTargetDirectory (assembly.ItemSpec), compressionMethod: CompressionMethod.Store);

// Try to add config if exists
var config = Path.ChangeExtension (assembly.ItemSpec, "dll.config");
Expand All @@ -267,7 +260,7 @@ private void AddAssemblies (ZipArchive apk)
var symbols = Path.ChangeExtension (assembly.ItemSpec, "dll.mdb");

if (File.Exists (symbols))
apk.AddFile (symbols, "assemblies", compressionLevel: CompressionLevel.NoCompression);
apk.AddFile (symbols, "assemblies", compressionMethod: CompressionMethod.Store);
}
}

Expand All @@ -276,15 +269,15 @@ private void AddAssemblies (ZipArchive apk)

// Add framework assemblies
foreach (ITaskItem assembly in ResolvedFrameworkAssemblies) {
apk.AddFile (assembly.ItemSpec, "assemblies", compressionLevel: CompressionLevel.NoCompression);
apk.AddFile (assembly.ItemSpec, "assemblies", compressionMethod: CompressionMethod.Store);
var config = Path.ChangeExtension (assembly.ItemSpec, "dll.config");
AddAssemblyConfigEntry (apk, config);
// Try to add symbols if Debug
if (debug) {
var symbols = Path.ChangeExtension (assembly.ItemSpec, "dll.mdb");

if (File.Exists (symbols))
apk.AddFile (symbols, "assemblies", compressionLevel: CompressionLevel.NoCompression);
apk.AddFile (symbols, "assemblies", compressionMethod: CompressionMethod.Store);
}
}
}
Expand All @@ -299,7 +292,7 @@ void AddAssemblyConfigEntry (ZipArchive apk, string configFile)
source.CopyTo (dest);
dest.WriteByte (0);
dest.Position = 0;
apk.AddEntry ("assemblies/" + Path.GetFileName (configFile), dest, compressionLevel: CompressionLevel.NoCompression);
apk.AddEntry ("assemblies/" + Path.GetFileName (configFile), dest, compressionMethod: CompressionMethod.Store);
}
}

Expand Down Expand Up @@ -462,18 +455,19 @@ void AddNativeLibrariesFromAssemblies (ZipArchive apk, string supportedAbis)
continue;
var data = ressozip.GetResourceData ();
using (var ms = new MemoryStream (data)) {
using (var zip = new ZipArchive (ms, ZipArchiveMode.Read)) {
foreach (var e in zip.Entries.Where (x => abis.Any (a => x.FullName.Contains (a)))) {
if (e.IsDirectory ())
using (var zip = ZipArchive.Open (ms)) {
foreach (var e in zip.Where (x => abis.Any (a => x.FullName.Contains (a)))) {
if (e.IsDirectory)
continue;
var key = e.FullName.Replace ("native_library_imports", "lib");
if (apk.ContainsEntry (key)) {
if (apk.Any(k => k.FullName == key)) {
Log.LogCodedWarning ("4301", "Apk already contains the item {0}; ignoring.", key);
continue;
}
using (var s = new MemoryStream ()) {
e.Extract (s);
apk.AddEntry (key, s.ToArray ());
s.Position = 0;
apk.AddEntry (s.ToArray (),key);
}
}
}
Expand Down
Loading