在Android上以发布模式链接和AzureMobileServices的问题

时间:2014-08-13 23:19:11

标签: android msbuild linker xamarin

在我的Android项目中,我使用的是AzureMobileServices,但是当我在发布时启动它时会抛出一个NullReferenceException,它在AMS中有一些深度。

据我所知,这个问题与链接一些Sdk程序集有关,而且我也可以通过禁用链接来解决这个问题。但这会增加应用程序的大小,而且足够大

这是堆栈跟踪

08-14 03:07:13.298 I/MonoDroid(24480): UNHANDLED EXCEPTION: System.ArgumentNullException: Argument cannot be null.
08-14 03:07:13.298 I/MonoDroid(24480): Parameter name: method
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 
An unhandled exception occured.

08-14 03:07:13.298 I/MonoDroid(24480):   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Linq.Expressions.Expression.Lambda (System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Linq.Expressions.Expression.Lambda (System.Linq.Expressions.Expression body, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at System.Linq.Expressions.Expression.Lambda (System.Linq.Expressions.Expression body, System.Linq.Expressions.ParameterExpression[] parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.PartialEvaluator+<>c__DisplayClass4.<EvaluateIndependentSubtrees>b__3 (System.Linq.Expressions.Expression expr, System.Func`2 recur) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.Visit (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.VisitBinary (System.Linq.Expressions.BinaryExpression b) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.<>n__FabricatedMethod4 (System.Linq.Expressions.Expression ) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.<Visit>b__3 (System.Linq.Expressions.Expression e) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.PartialEvaluator+<>c__DisplayClass4.<EvaluateIndependentSubtrees>b__3 (System.Linq.Expressions.Expression expr, System.Func`2 recur) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.Visit (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.VisitLambda (System.Linq.Expressions.LambdaExpression lambda) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.<>n__FabricatedMethod4 (System.Linq.Expressions.Expression ) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.<Visit>b__3 (System.Linq.Expressions.Expression e) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.PartialEvaluator+<>c__DisplayClass4.<EvaluateIndependentSubtrees>b__3 (System.Linq.Expressions.Expression expr, System.Func`2 recur) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.Visit (System.Linq.Expressions.Expression expression) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.VisitUnary (System.Linq.Expressions.UnaryExpression u) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x00000] in <filename unknown>:0 
08-14 03:07:13.298 I/MonoDroid(24480):   at Microsoft.WindowsAzure.MobileServices.VisitorHelper.<>n__FabricatedMethod4 (System.Linq.Expressions.Expression ) [0x00000] 
08-14 03:07:13.928 E/mono    (24480): 
08-14 03:07:13.928 E/mono    (24480): Unhandled Exception:
08-14 03:07:13.928 E/mono    (24480): System.ArgumentNullException: Argument cannot be null.
08-14 03:07:13.928 E/mono    (24480): Parameter name: method
08-14 03:07:13.928 E/mono    (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono    (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono    (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono    (24480):   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono    (24480):   at System.Linq.Expressions.Expression.Lambda (System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in <filename un
08-14 03:07:13.928 E/mono-rt (24480): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Argument cannot be null.
08-14 03:07:13.928 E/mono-rt (24480): Parameter name: method
08-14 03:07:13.928 E/mono-rt (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) [0x00000] in <filename unknown>:0 
In mgmain JNI_OnLoad
08-14 03:07:13.928 E/mono-rt (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono-rt (24480):   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono-rt (24480):   at System.Linq.Expressions.Expression.CreateLambda (System.Type delegateType, System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, System.Collections.ObjectModel.ReadOnlyCollection`1 parameters) [0x00000] in <filename unknown>:0 
08-14 03:07:13.928 E/mono-rt (24480):   at System.Linq.Expressions.Expression.Lambda (System.Linq.Expressions.Expression body, System.String name, Boolean tailCall, IEnumerable`1 parameters) [0x00000] in

我读了official xamarin topic about linkingMSBuild AndroidLinkSkip。 我添加了这个程序集以跳过标记System.Linq;System.Reflection;Microsoft.WindowsAzure.Mobile.Ext,但这根本没有帮助。

这是proj文件的一部分

<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>System.Linq;System.Reflection;Microsoft.WindowsAzure.Mobile.Ext</AndroidLinkSkip>
</PropertyGroup>

我不知道还应该添加什么来解决问题。可能我会尝试添加所有程序集,看看它会有所帮助。同时,任何人都可以给我任何建议我应该添加到链接跳过什么?

1 个答案:

答案 0 :(得分:0)

我也有同样的问题,我不得不跳过一组装配,直到它正常工作。 这些是我在链接时跳过的程序集:(我的项目顺便称为MvvMAppiAppi)

  • Mono.Android;系统;
  • System.Core程序;
  • System.Net.Http;
  • 的System.Xml;
  • MvvMAppiAppi.Droid;
  • MvvMAppiAppi.Core;
  • MvvMAppiAppi.AzureSvc;
  • Microsoft.WindowsAzure.Mobile;
  • Microsoft.WindowsAzure.Mobile.Ext;
  • Newtonsoft.Json;

只有这样才能完成链接工作。我确实会添加程序集,看看你需要跳过多少才能编译...我认为还有另一种方法。