2016-04-26 91 views
0

我試圖將Android Studio中的Android應用程序移植到Visual Studio 2015/Xamarin。我嘗試運行該項目,並獲得:在'RequiresPermission'類型中找不到註釋方法'anyOf()':

Android application is debugging. 
    The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true). 

Additionally, check Build->Configuration Manager to ensure this project is set to Deploy for this configuration. 

我加[Activity(MainLauncher = true)]到主類,並檢查Build->Configuration這似乎是正確的,但這些都沒有影響。

我得到這樣的警告:

Cannot find annotation method 'anyOf()' in type 'RequiresPermission': 
class file for android.support.annotation.RequiresPermission not found 
MyApplication.Native.Droid C:\Users\allelopath\AppData\Local\Xamarin\GooglePlayServices.Maps\8.4.0\embedded\classes.jar(com/google/android/gms/maps/GoogleMap.class) 

我也得到這樣的警告:

Warning  
Found conflicts between different versions of the same dependent assembly. 
In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; 
otherwise, add the following binding redirects to the "runtime" node in the application configuration file: 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
<dependentAssembly><assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" /> 
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /></dependentAssembly></assemblyBinding> 
Acquaint.Native.Droid   

我雙擊因爲它表明,它問:

Do you want to fix these conflicts by adding binding redirrect records in the application configuration file? 

我單擊是。這最終沒有效果,重建並嘗試運行後,警告再次出現。

我解鎖了設備上的應用程序,該應用程序曾在Android Studio上運行過,但這也沒有影響。

你能提出什麼建議?

回答

1

對於第一個問題,我會右鍵點擊您的解決方案,轉到配置屬性,並確保正在構建所有正確的項目,並檢查您的Android項目的部署框。這只是一個糟糕的Xamarin傾向。

我自己有第二個警告,這只是因爲Android支持庫要求您針對sdk版本23進行編譯。Google maps包必須使用這些新註釋。我沒有遇到任何問題,因爲這個錯誤,15 minSdkVersion,所以我只是住在它。

我也有相同的依賴程序集警告和我認爲正在發生的是我有一個項目使用.net基元比任何.net http使用更新的引用。只是一個猜測,但我也不擔心讓這個開心。