[英]Xamarin.Android Google Play Services dependency via AAR Binding
I am using Visual Studio 2015 Update 3 to write a Xamarin cross-platform app for Android and iOS. 我正在使用Visual Studio 2015 Update 3编写适用于Android和iOS的Xamarin跨平台应用程序。 I need to make use of a 3rd party SDK written in Java for functionality related to Push messaging.
我需要利用Java编写的第三方SDK来实现与Push消息相关的功能。 For the Android side of the solution, I have tried many, many things (over the course of days now), but have not been successful.
对于该解决方案的Android方面,我已经尝试了很多很多事情(现在已经过了几天),但是没有成功。 I would like to solve for the following solution:
我想解决以下问题:
Ever since including Google Play Services to the myApp.Android.BindSDK project via NuGet, I get the following compilation error: 自从通过NuGet将Google Play服务包含到myApp.Android.BindSDK项目中以来,我收到以下编译错误:
error APT0000: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
I have tried a lot of things posted on forums like cleaing the solution, deleting bin and obj folders, extracting the version.xml file from the JAR inside the AAR for Google Play, etc, etc, etc. It still gets this build error. 我已经尝试了很多在论坛上发布的内容,例如关闭解决方案,删除bin和obj文件夹,从AAR中的JAR中的JAR中提取version.xml文件以用于Google Play等,等等。它仍然会收到此构建错误。
Does anyone have a good example of how to create a Xamarin binding wrapper for an android/Java SDK that (itself) has dependencies on Google Play Services? 有没有人有一个很好的例子说明如何为本身依赖于Google Play服务的android / Java SDK创建Xamarin绑定包装?
Check to see if your binding project's .csproj
contains the Xamarin.GooglePlayServices.Basement.targets
as the resource task within that package is the one that extracts the Play Services version and adds it to your library's resources: 检查您的绑定项目的
.csproj
包含Xamarin.GooglePlayServices.Basement.targets
因为该包中的资源任务是提取Play服务版本并将其添加到库资源中的任务:
Example: 例:
<Import Project="..\packages\Xamarin.GooglePlayServices.Basement.42.1001.0\build\MonoAndroid70\Xamarin.GooglePlayServices.Basement.targets" Condition="Exists('..\packages\Xamarin.GooglePlayServices.Basement.42.1001.0\build\MonoAndroid70\Xamarin.GooglePlayServices.Basement.targets')" />
Also check that the binding project manifest does not already contain an entry for com.google.android.gms.version
as this should be auto-generated/merged by the build process: 此外,检查结合项目清单尚未包含一个条目
com.google.android.gms.version
,因为这应该是自动生成/编译过程合并:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
Note: I have never had to do this manually in my binding projects that included Play Services, I have come across some client's binding projects that cause the .aar
resources merge process to fail on referenced packages (assuming there is a conflicting Play Services resource in the .aar
but modifying the 3rd-party .aar
is usually not worth it) 注意:我从来没有在包含Play Services的绑定项目中手动执行此操作,遇到了一些客户端的绑定项目,这些项目会导致
.aar
资源合并过程在引用的程序包上失败(假设在其中存在冲突的Play Services资源.aar
但修改第三方.aar
通常不值得)
In the Resources
directory, create a values
folder and add a values.xml
file with the google_play_services_version
integer value: 在
Resources
目录中,创建一个values
文件夹,并添加一个带有google_play_services_version
整数值的values.xml
文件:
<integer name="google_play_services_version">10084000</integer>
Note: If the Google Play Services version changes you need to update the version value otherwise your app will end up throwing strange errors especially if you do InApp purchases.... 注意:如果Google Play服务版本更改,则需要更新版本值,否则您的应用最终会引发奇怪的错误,尤其是在您进行InApp购买时。
After much trial and error, I was able to create a working solution. 经过反复试验,我能够创建一个可行的解决方案。
How-To is provided in this post in detail . 这篇文章中详细提供了操作方法 。
Key: The thing that I had been missing above seems to have been to include the 3rd party SDK's dependencies not in the Binding Assembly eg: "myApp.Android.BindSDK" used to wrap the SDK, but instead via NuGet into the Solution's Android assembly that was referencing the Binding Assembly eg: "myApp.Android". 关键:我上面遗漏的东西似乎是在绑定程序集中不包含第三方SDK的依赖项,例如:用于包装SDK的“ myApp.Android.BindSDK”,而是通过NuGet进入解决方案的Android程序集引用绑定程序集,例如:“ myApp.Android”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.