Android应用过大和链接功能禁用 [英] Android App is too large and Linking disables functionality

查看:237
本文介绍了Android应用过大和链接功能禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的应用程序做,现在我试图建立.apk文件,并测试它在我的手机(没有调试,在释放模式)。

I'm done with my app and now I'm trying to build the .apk and test it on my phone (without debug, in release mode).

设置链接到一切工作正常。
这里的问题是,该应用程序是过大 - 它的 20MB 和多数民众垃圾

Setting the Linking to "None" everything works fine. The Problem here is, that the App is too large - its 20MB and thats rubbish.

我读到一篇关于链接:
点击这里

I read that article about Linking: Click Here

于是,我就 SDK组件仅 SDK和用户大会。第二个选项(这两个组件)直接失败了,我当时甚至无法看到我的应用程序的第一个屏幕(登录)。

So I tried "Sdk Assemblies Only" and "Sdk and User Assemblies". The second option (Both Assemblies) failed directly, I wasn't even able to see the first screen (Login) of my App.

通过链接设置为<强> SDK组件仅我能走到第一个屏幕(Loginscreen)。该应用程序还 6.73MB 什么更好的,更符合要求。

With Linking set to "Sdk Assemblies Only" I was able to come to the first screen (Loginscreen). The App is also 6.73MB whats much better and more eligible.

我现在面临的问题是,这当我按钮登录,单击第一个屏幕上,的什么也没有发生的(通常它会重定向我到下一个活动)。

The Problem I face now is, that when I click on the Button "Log In" on the first screen, nothing happens (normally it would redirect me to the next Activity).

该按钮被绑定到一个命令:

The Button is binded to a Command:

public IMvxCommand LoginCommand
{
    get
    {
         return new MvxRelayCommand(DoLogin);
    }
}

private void DoLogin()
{
     //Do Stuff
}

把一个断点DoLogin() - 表明,它永远不会在散步

Putting a Breakpoint in DoLogin() - shows, that it never walks in.

好了,我怎么能解决这个问题?好像mvvmcross的功能以任何理由禁止?

Well, how could I solve the problem? Seems like the functionality of mvvmcross is disabled for any reason?

我的主要目的是减少应用程序的大小。

My main aim is to reduce the size of app.

下面,如果重要的从.csproj的必要部分。

Here if important the necessary section from the .csproj

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidLinkSkip />
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>



推荐答案

通过MvvmCross,我一般使用 SDK组件

With MvvmCross, I generally use SDK Assemblies only.

要那么解决办法链接失败MvvmCross(而对于一般的MonoTouch / MonoDroid的问题),那么我想补充 LinkerPleaseInclude 键入文件欺骗链接。

To then workaround Linker fails for MvvmCross (and for general MonoTouch/MonoDroid issues) then I add LinkerPleaseInclude type files to trick the linker.

这是示例文件是:

public class LinkerIncludePlease
{
    private void IncludeClick(View view)
    {
        view.Click += (s, e) => { };
    }

    private void IncludeVisibility(View view)
    {
        view.Visibility = view.Visibility + 1;
    }

    private void IncludeRelativeLayout(RelativeLayout relative)
    {
        relative.Visibility = ViewStates.Visible;
    }
}



来自:的https://github.com/slodge/MvvmCross/blob/vnext/Sample%20- %20TwitterSearch / TwitterSearch.UI.Droid / LinkerIncludePlease.cs

这是烦人不得不这样做...但它并不需要很长时间 - 大多数应用程序实际上不绑定到许多不同的属性/事件。

It is annoying to have to do this... but it doesn't take long - most apps don't actually bind to many different properties/events.

这篇关于Android应用过大和链接功能禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆