Home Php C# Sql C C++ Javascript Python Java Go Android Git Linux Asp.net Django .net Node.js Ios Xcode Cocoa Iphone Mysql Tomcat Mongodb Bash Objective-c Scala Visual-studio Apache Elasticsearch Jar Eclipse Jquery Ruby-on-rails Ruby Rubygems Android-studio Spring Lua Sqlite Emacs Ubuntu Perl Docker Swift Amazon-web-services Svn Html Ajax Xml Java-ee Maven Intellij-idea Rvm Macos Unix Css Ipad Postgresql Css3 Json Windows-server Vue.js Typescript Oracle Hibernate Internet-explorer Github Tensorflow Laravel Symfony Redis Html5 Google-app-engine Nginx Firefox Sqlalchemy Lucene Erlang Flask Vim Solr Webview Facebook Zend-framework Virtualenv Nosql Ide Twitter Safari Flutter Bundle Phonegap Centos Sphinx Actionscript Tornado Register | Login | Edit Tags | New Questions | 繁体 | 简体


10 questions online user: 49

0
votes
answers
29 views
+10

安裝IOS應用程序錯誤與設備在VS與Xamarin建設

0

我嘗試構建應用程序,在VS與Xamarin創建,以測試它在真正的設備上(在iPhoneSimulator它工作沒有問題)。我使用AdHoc生成所有需要的證書和規定(創建像Xamarin tutorial描述)。但是當我嘗試通過iTunes上傳IPA文件到設備時,它完成失敗。在iPhone上完成後,它會消失,在iPad上它會拋出「應用程序無法安裝」的錯誤信息。這兩款設備都已添加到配置文件中。配置文件已激活。 所有幫助將不勝感激安裝IOS應用程序錯誤與設備在VS與Xamarin建設

沙发
0
0

你可以找到一個更具描述性的原因,如果你打開「部署到設備」窗口

Menu -> View -> Pads -> Deploying to Device

+0

對不起,但我無法看到圖像託管的圖片。 –

+0

對不起,但還是不明白,這個菜單在哪裏,我需要打開? –

+0

@AdeptusMechanicus如果找不到它,請在頂部找到最右側的菜單(幫助),然後在那裏輸入「部署到設備」,它會告訴您它位於何處。 – Taier

板凳
0
0

問題解決了這種方式 - 複製的項目到Visual Studio的Mac,安裝在主機構建機器上,構建應用程序,將項目移回。現在應用上傳沒有問題。

0
votes
answers
25 views
+10

在自定義ContentView中隱藏框架

0

我在我的ListView中使用名爲CardViewTemplate.xaml的內容視圖頁面來呈現一些帶有兩個框架的內容,其中一個應該是可見的,另一個不是同時顯示的。在自定義ContentView中隱藏框架

 <ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
     ...> 
     <Frame IsVisible="{Binding IsNotBreak}" IsClippedToBounds="True"> 
    .... content .... 
     </Frame> 
     <Frame IsVisible="{Binding IsBreak}" IsClippedToBounds="True"> 
    --content 2- 
     </Frame> 
     </ContentView> 

和在列表視圖中用於結合和查看一些數據的ListView像下面的代碼在上述頁:

<ListView x:Name="listView" SelectedItem="{Binding SelcetedItem,Mode=TwoWay}" 
      RowHeight="-1" 
      ItemsSource="{Binding SelectedCard}" HasUnevenRows="True" > 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <ViewCell> 
         <Custom:CardViewTemplate/> 
        </ViewCell> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 
    </StackLayout> 

出乎意料我的列表視圖僅示出了第二幀,它看起來像附加的圖像:

Frame 1 Doesn't view any Content

沙发
0
0

這是因爲ContentView應該只生一個孩子,而第二Frame重寫了第一個Frame

嘗試添加視圖容器狀AbsoluteLayout,或Grid到保持兩個(多個)幀內部ContentView

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    ...> 
    <AbsoluteLayout> 

     <Frame IsVisible="{Binding IsNotBreak}" IsClippedToBounds="True"> 
    .... content .... 
     </Frame> 
     <Frame IsVisible="{Binding IsBreak}" IsClippedToBounds="True"> 
    --content 2- 
     </Frame> 

    </AbsoluteLayout> 
</ContentView> 
0
votes
answers
51 views
+10

SkiaSharp不斷在Xamarin.Droid項目中安裝,但安裝並未完成。它只是繼續安裝。?

0

我在VS中使用Telerik UI控件的xamarin.Forms應用程序。當我構建我的.Droid項目時,它給了我一個例外:FileNotFoundException - > SkiaSharp 1.59.0缺失,可能它沒有安裝用於單聲道的android。SkiaSharp不斷在Xamarin.Droid項目中安裝,但安裝並未完成。它只是繼續安裝。?

我想從Nuget安裝SkiaSharp,但它只是繼續安裝,但從來沒有完成。我等了10分鐘,但沒有發生,它只是繼續安裝它。 任何解決方案,請? 謝謝

沙发
0
0

我試圖從nuget包安裝SkiaSharp在Mac和沒有問題。當你安裝其他的nuget包是同樣的問題?如果是這樣,也許你的VS網絡配置有一些問題,所以它不能下載這個軟件包。您可以重新啓動VS和Mac,然後重試。

作爲一種替代選擇,您可以直接從link下載nuget軟件包,然後您可以在本地將此nuget軟件包供給您的項目參考。

0
votes
answers
16 views
+10

爲什麼列表視圖行項目被點擊多次?

0

我已經在中實現了ListView,Xamarin.Android在rowlist中有幾個按鈕,但是當我點擊按鈕時,它不止一次地被點擊。我試過這種方式,但沒有爲我工作。 我在BaseAdapter<DA_ClassSectionAttendance>爲什麼列表視圖行項目被點擊多次?

public override View GetView(int position, View convertView, ViewGroup parent) 
    { 
     View view = convertView; 

     // re-use an existing view, if one is available 
     // otherwise create a new one 
     if (view == null) 
      view = context.LayoutInflater.Inflate(Resource.Layout.AttendanceCreateRowList, parent, false); 
     var viewHolder = new ViewHolder(view); 

     DA_ClassSectionAttendance attendance = this[position]; 

     view.Tag = viewHolder; 
     viewHolder.ClassSection.Text = attendance.ClassName + " " + attendance.SectionName; 
     viewHolder.AttendanceEdit.Text = "Edit"; 
     viewHolder.AttendanceNew.Text = "New"; 
     viewHolder.AttendanceNew.Tag = viewHolder; 
     viewHolder.AttendanceNew.Click += (object sender, EventArgs ex) => 
     { 

      var obj = sender as Button; 
      var listView = parent as ListView; 
      //int objectPosition = (int)obj.Tag; 
      var itemPosition = listView.GetPositionForView(obj); 
      if (itemPosition != ListView.NoId) 
      { 

       CustomFragmentManager fragManager = new CustomFragmentManager(); 
       var fragment = new AttendanceCreateRecyclerFragment(); 
       Bundle args = new Bundle(); 
       var jsonData = JsonConvert.SerializeObject(this[itemPosition]).ToString(); 
       args.PutString(AttendanceCreateRecyclerFragment.DATA_RECEIVE, jsonData); 
       fragment.Arguments = args; 

       fragManager.ReplaceFragment(context, fragment); 

      } 

     }; 

     return view; 
    } 

這種方法和觀點持有者是如下

private class ViewHolder : Java.Lang.Object 
    { 
     public ViewHolder(View view) 
     { 
      ClassSection = view.FindViewById<TextView>(Resource.Id.class_section); 
      AttendanceNew = view.FindViewById<Button>(Resource.Id.new_attendance); 
      AttendanceEdit = view.FindViewById<Button>(Resource.Id.edit_attendance); 
     } 

     public TextView ClassSection { get; set; } 
     public Button AttendanceNew { get; set; } 
     public Button AttendanceEdit { get; set; } 
    } 

我想實現點擊事件,而不是點擊監聽器。如果任何示例代碼以及解釋將非常感謝。謝謝。

+0

RecylerView比ListView更高效。你應該使用RecylerView。 '我想實現點擊事件而不是點擊偵聽器 - 有什麼區別?如果將點擊偵聽器設置爲視圖,則可以在單擊視圖時攔截點擊事件。如果您想攔截點擊事件,則需要設置點擊偵聽器。 –

+0

使用recylerView你將獲得大量的動畫和平滑滾動 –

沙发
0
1

的原因是,點擊事件得到與viewHolder.AttendanceNew.Click += (object sender, EventArgs ex) =>

多次附加您創建和使用視圖持有人是不工作的方式。將代碼更改爲如下所示:

public override View GetView(int position, View convertView, ViewGroup parent) 
{ 
    View view = convertView; 

    // re-use an existing view, if one is available 
    // otherwise create a new one 
    if (view == null) 
     view = context.LayoutInflater.Inflate(Resource.Layout.AttendanceCreateRowList, parent, false); 

    var viewHolder = view.Tag as ViewHolder; 

    if (viewHolder == null) 
    { 
     viewHolder = new ViewHolder(view); 
     viewHolder.AttendanceNew.Click += (object sender, EventArgs ex) => 
     { 
      var obj = sender as Button; 
      var listView = parent as ListView; 

      var itemPosition = listView.GetPositionForView(obj); 

      if (itemPosition != ListView.NoId) 
      { 
       CustomFragmentManager fragManager = new CustomFragmentManager(); 
       var fragment = new AttendanceCreateRecyclerFragment(); 
       Bundle args = new Bundle(); 
       var jsonData = JsonConvert.SerializeObject(this[itemPosition]).ToString(); 
      args.PutString(AttendanceCreateRecyclerFragment.DATA_RECEIVE, jsonData); 
       fragment.Arguments = args; 

       fragManager.ReplaceFragment(context, fragment); 
      } 
     }; 
    } 

    var attendance = this[position]; 

    viewHolder.ClassSection.Text = attendance.ClassName + " " + attendance.SectionName; 
    viewHolder.AttendanceEdit.Text = "Edit"; 
    viewHolder.AttendanceNew.Text = "New"; 

    view.Tag = viewHolder; 

    return view; 
} 
0
votes
answers
22 views
+10

如何水平排列三個項目並使第二個和第三個右側對齊?

0

我有一個ViewCell,看起來像這樣:如何水平排列三個項目並使第二個和第三個右側對齊?

<ViewCell x:Name="bBtn" NoTap="true"> 
    <Grid VerticalOptions="CenterAndExpand" Padding="20, 0"> 
     <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal"> 
     <Label Text="XX" HorizontalOptions="StartAndExpand" /> 
     <Label HorizontalOptions="End" Text="{Binding BBtnLabel}" /> 
     </StackLayout> 
     <Stepper x:Name="bBtnStepper" Maximum="10" Minimum="0" ValueChanged="bBtnStepperValueChanged" HorizontalOptions="End" /> 
    </Grid> 
</ViewCell> 

這將顯示爲:

XX 123    [Stepper Here] 

我想達到的效果是:

XX    123 [Stepper Here] 

我嘗試添加Horizo??ntalOptions到第二個標籤,但它似乎沒有將其移動到步進器前面。

有人可以給我一些想法,我做什麼錯了嗎?

沙发
0
0

我不太瞭解xaml,但看起來您還沒有定義行和列的定義,而且您並不是將網格的哪個位置插入stacklayout和步進器的設置。 Placing_Views_in_a_Grid

其次,你應該有一個1row,2cols的網格:將row0col0和StackLayout(123和「stepper here」)添加到row0col1並嘗試設置123 Horizo??ntalOptions爲「End」和「stepper here」 Horizo??ntalOptions到「End」

0
votes
answers
22 views
+10

Xamarin.Forms中用於存儲應用程序數據的最佳Environment.SpecialFolder是什麼?

2

我是Xamarin.Forms和移動開發新手。我想將我的應用程序用戶的用戶和加密密碼存儲在移動設備上的文件中。我正在使用xamarin表單技術。我知道有很多differenet文件夾。在例如:Xamarin.Forms中用於存儲應用程序數據的最佳Environment.SpecialFolder是什麼?

System.Environment.SpecialFolder.Personal 
System.Environment.SpecialFolder.LocalApplicationData 
System.Environment.SpecialFolder.MyDocuments 

全部列表,你可以在這裏找到:https://msdn.microsoft.com/en-gb/en-enl/library/system.environment.specialfolder(v=vs.110).aspx

什麼是店裏最好的文件夾/目錄:

  • 用戶名和密碼數據
  • 其他應用specyfic數據

?? ??

編輯:我發現「個人」對我很好,但是如果你有其他答案,也可以發佈。 SpecialFolder.Personal location

沙发
0
4

存放小鍵值對:

Xamarin.Forms實現Application.Current.Properties存儲在應用程序和訪問這些鍵值對的本地存儲的鍵值數據是安全的到應用程序只有誰存儲他們。

存儲文件/數據庫(SQLite的):

每個平臺都有它自己的文件夾結構下存儲的應用程序特定的數據/文件。

的Android

Environment.SpecialFolder.Personal & MyDocuments都映射到:/data/data/@[email protected]/files

Environment.SpecialFolder.LocalApplicationData映射爲:/data/data/@[email protected]/files/.local/share

我們可以存儲在任何基於它們是如何在文件中映射上述目錄的文件系統。 上述目錄都不能被其他應用程序訪問,用戶也不能在世界之外訪問它們,除非電話是根植的。

的iOS

Environment.SpecialFolder.Personal, LocalApplicationData & MyDocuments所有地圖:/Documents

iOS版具有以下目錄結構:

/Documents 
/Library 
/Library/Application Support 
/Library/Caches 
/tmp 

/Documents如果iTunes共享,在打開的iTunes獲取可見info.plist在應用程序中。內容可以由iTunes/iCloud備份。

/LibraryiTunes中不可見。可以通過iTunes/iCloud備份,但Caches目錄除外。

不需要公開給用戶的文件/數據應存儲在庫目錄中。防爆。數據庫文件。我會去尋求Library目錄以加密安全性(如果需要的話)。

要到庫路徑:

Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "..", "Library"); 

要了解更多關於每個枚舉的映射與目錄Go Here

查找有關iOS File System Basics的基本信息。

0
votes
answers
14 views
+10

Xamarin.froms如何電網改變方向從右到左或列的內容之間的替代

0

個網格中兩列一行,我想progremmaticallyXamarin.froms如何電網改變方向從右到左或列的內容之間的替代

列1和2之間,以取代我想:

grdMainGrid.Children.Remove(child1); 
    grdMainGrid.Children.Remove(child2); 
grdMainGrid.Children.Add(child1, 0, 0); 
grdMainGrid.Children.Add(child2, 0, 0); 

但是這個動作刪除了child1和child2的所有孩子。

沙发
0
0

所以最終它並沒有消除孩子。但是將子女添加到網格的順序決定了圖像覆蓋了其他孩子。

0
votes
answers
12 views
+10

升級後的xamarin表單不能正確呈現按鈕

2

使用xamarin表單開發跨平臺應用程序,最初該應用程序是使用Xamarin.Forms.2.4.0.38779,目標框架爲6.0以及Android支持庫版本23.3.0構建的。 UI代碼是:升級後的xamarin表單不能正確呈現按鈕

// styles 
<Style x:Key="DefaultButtonStyle" TargetType="Button"> 
    <Setter Property="TextColor" Value="DodgerBlue"></Setter> 
    <Setter Property="BackgroundColor" Value="Transparent"></Setter> 
</Style> 
<Style x:Key="RoundBorderButtonStyle" TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}"> 
    <Setter Property="BorderWidth" Value="1"></Setter> 
    <Setter Property="BorderRadius" Value="30"></Setter> 
    <Setter Property="BorderColor" Value="DodgerBlue"></Setter> 
</Style> 

<StackLayout Margin="15,0" Spacing="20" Orientation="Horizontal"> 
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Copy"></Button> 
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Addresses"></Button> 
</StackLayout> 

然後vs2017得到了更新,所以沒有xamarin形式,所以我還更新了項目中使用最新的庫,與Xamarin.Forms.2.4.0.38779和android目標框架8.0版,支持庫26.1.0.1。然後突然按鈕不能正確渲染。 enter image description here

更新後:更新之前

enter image description here

還有什麼我需要做更新xamarin形式?

更新

我創建了最低test case,藉以說明問題,在VS創建一個跨平臺的項目,唯一的文件更改爲TestButton/TestButton/MainPage.xaml中。該應用程序截圖:

enter image description here

+0

您能否發佈'RoundBorderButtonStyle'的代碼? –

+0

@ ElvisXia-MSFT它的帖子,上面的按鈕xaml – fluter

+0

對不起,錯過了,我會嘗試在我身邊。 –

沙发
0
2

所以我還更新了項目中使用最新的庫,與Xamarin.Forms.2.4.0.38779和android目標框架8.0版,支持庫26.1.0.1。然後突然按鈕不能正確呈現

我轉載您的項目的問題,我發現它是由Xamarin.Forms庫造成的。我注意到您的示例項目Xamarin.Forms的版本是最新版本(2.4.0.74863)。

解決方案:通過將Xamarin.Forms降級到2.4.280並執行乾淨的重建並重新安裝該應用程序將解決該問題。

+0

我將Xamarin表格降級到2.4.0.280並再次嘗試,但沒有任何變化。一樣的問題。 – fluter

+0

你有沒有卸載你的手機/模擬器中的應用程序,並清理重建應用程序?此外,您還需要在PCL和Xamarin.Android項目中降級lib。 –

+0

是的,確實現在它卸載應用程序後現在工作。謝謝。 – fluter

0
votes
answers
16 views
+10

Does anyone have benchmarks (code & results) comparing performance of Android apps written in Xamarin C# and Java? [closed]

I came across Xamarin claims that their Mono implementation on Android and their C# compiled apps are faster than Java code. Did anyone perform actual benchmarks on very similar Java and C# code on different Android platforms to verify such claims, could post the code and results?

Added June 18, 2013

Since there was no answer and could not find such benchmarks done by others, decided to do my own tests. Unfortunately, my question remains "locked" so I cannot post this as the answer, only edit the question. Please vote to re-open this question. For C#, I used Xamarin.Android Ver. 4.7.09001 (beta). The source code, all the data I used for testing and compiled APK packages are on GitHub:

Java: https://github.com/gregko/TtsSetup_Java

C#: https://github.com/gregko/TtsSetup_C_sharp

If someone would like to repeat my tests on other devices or emulators, I'd be interested to learn the results as well.

Results from my testing

I ported my sentence extractor class to C# (from my @Voice Aloud Reader app) and run some tests on 10 HTML files in English, Russian, French, Polish and Czech languages. Each run was performed 5 times on all 10 files, and the total time for 3 different devices and one emulator are posted below. I tested "Release" builds only, without debugging enabled.

HTC Nexus One Android 2.3.7 (API 10) - CyanogenMod ROM

Java: Grand total time (5 runs): 12361 ms, with file reading total: 13304 ms

C#: Grand total time (5 runs): 17504 ms, with file reading total: 17956 ms

Samsung Galaxy S2 SGH-I777 (Android 4.0.4, API 15) - CyanogenMod ROM

Java: Grand total time (5 runs): 8947 ms, with file reading total: 9186 ms

C#: Grand total time (5 runs): 9884 ms, with file reading total: 10247 ms

Samsung GT-N7100 (Android 4.1.1 JellyBean, API 16) - Samsung ROM

Java: Grand total time (5 runs): 9742 ms, with file reading total: 10111 ms

C#: Grand total time (5 runs): 10459 ms, with file reading total: 10696 ms

Emulator - Intel (Android 4.2, API 17)

Java: Grand total time (5 runs): 2699 ms, with file reading total: 3127 ms

C#: Grand total time (5 runs): 2049 ms, with file reading total: 2182 ms

Emulator - Intel (Android 2.3.7, API 10)

Java: Grand total time (5 runs): 2992 ms, with file reading total: 3591 ms

C#: Grand total time (5 runs): 2049 ms, with file reading total: 2257 ms

Emulator - Arm (Android 4.0.4, API 15)

Java: Grand total time (5 runs): 41751 ms, with file reading total: 43866 ms

C#: Grand total time (5 runs): 44136 ms, with file reading total: 45109 ms

Brief discussion

My test code contains mainly text parsing, replacing and Regex searches, perhaps for other code (e.g. more numeric operations) the results would be different. On all devices with ARM processors, Java performed better than Xamarin C# code. The largest difference was under Android 2.3, where C# code run at approx. 70% of Java speed.

On Intel emulator (with Intel HAX technology, emulator runs in fast virt mode), Xamarin C# code runs my sample code much faster than Java - about 1.35 time faster. Maybe Mono virtual machine code and libraries are much better optimized on Intel than on ARM?

Edit July 8, 2013

I just installed Genymotion Android emulator, which runs in Oracle VirtualBox, and again this one uses native Intel processor, not emulating ARM processor. As with Intel HAX emulator, again C# runs here much faster. Here are my results:

Genymotion emulator - Intel (Android 4.1.1, API 16)

Java: Grand total time (5 runs): 2069 ms, with file reading total: 2248 ms

C#: Grand total time (5 runs): 1543 ms, with file reading total: 1642 ms

I then noticed that there was an update to Xamarin.Android beta, version 4.7.11, with release notes mentioning some changes in Mono runtime as well. Decided to quickly test some ARM devices, and big surprise - C# numbers improved:

BN Nook XD+, ARM (Android 4.0)

Java: Grand total time (5 runs): 8103 ms, with file reading total: 8569 ms

C#: Grand total time (5 runs): 7951 ms, with file reading total: 8161 ms

Wow! C# is now better than Java? Decided to repeat the test on my Galaxy Note 2:

Samsung Galaxy Note 2 - ARM (Android 4.1.1)

Java: Grand total time (5 runs): 9675 ms, with file reading total: 10028 ms

C#: Grand total time (5 runs): 9911 ms, with file reading total: 10104 ms

Here C# seems to be only slightly slower, but these numbers gave me a pause: Why the time is longer than on Nook HD+, even though Note 2 has a faster processor? The answer: power saving mode. On Nook, it was disabled, on Note 2 - enabled. Decided to test with power saving mode disabled (as with enabled, it also limits the processor speed):

Samsung Galaxy Note 2 - ARM (Android 4.1.1), power saving disabled

Java: Grand total time (5 runs): 7153 ms, with file reading total: 7459 ms

C#: Grand total time (5 runs): 6906 ms, with file reading total: 7070 ms

Now, surprisingly, C# is slightly faster than Java on ARM processor as well. Big improvement!

Edit July 12, 2013

We all know, that nothing beats native code for speed, and I was not satisfied with the performance of my sentence splitter in Java or C#, particularly that I need to improve it (and thus make it even slower). Decided to re-write it in C++. Here is a small (i.e. a smaller set of files than previous tests, for other reasons) comparison of the speed of native vs. Java on my Galaxy Note 2, with power saving mode disabled:

Java: Grand total time (5 runs): 3292 ms, with file reading total: 3454 ms

Native thumb: Grand total time (5 runs): 537 ms, with file reading total: 657 ms

Native arm: Grand total time (5 runs): 458 ms, with file reading total: 587 ms

Looks like for my particular test, the native code is 6 to 7 times faster than Java. Caveat: could not use std::regex class on Android, so had to write my own specialized routines searching for paragraphs breaks or html tags. My initial tests of the same code on a PC using regex, were about 4 to 5 times faster than Java.

Phew! Waking raw memory with char* or wchar* pointers again, I instantly felt 20 years younger! :)

Edit July 15, 2013

(Please see below, with edits of 7/30/2013, for much better results with Dot42)

With some difficulty, I managed to port my C# tests to Dot42 (version 1.0.1.71 beta), another C# platform for Android. Preliminary results show that Dot42 code is about 3x (3 times) slower than Xamarin C# (v. 4.7.11), on an Intel Android emulator. One problem is that System.Text.RegularExpressions class in Dot42 does not have the Split() function that I used in Xamarin tests, so I used Java.Util.Regex class instead, and Java.Util.Regex.Pattern.Split(), so in this particular place in the code, there is this small difference. Should not be a big problem though. Dot42 compiles to Dalvik (DEX) code, so it cooperates with Java on Android natively, does not need expensive interop from C# to Java like Xamarin.

Just for comparison, I also run the test on ARM devices - here the Dot42 code is "only" 2x slower than Xamarin C#. Here are my results:

HTC Nexus One Android 2.3.7 (ARM)

Java: Grand total time (5 runs): 12187 ms, with file reading total: 13200 ms

Xamarin C#: Grand total time (5 runs): 13935 ms, with file reading total: 14465 ms

Dot42 C#: Grand total time (5 runs): 26000 ms, with file reading total: 27168 ms

Samsung Galaxy Note 2, Android 4.1.1 (ARM)

Java: Grand total time (5 runs): 6895 ms, with file reading total: 7275 ms

Xamarin C#: Grand total time (5 runs): 6466 ms, with file reading total: 6720 ms

Dot42 C#: Grand total time (5 runs): 11185 ms, with file reading total: 11843 ms

Intel emulator, Android 4.2 (x86)

Java: Grand total time (5 runs): 2389 ms, with file reading total: 2770 ms

Xamarin C#: Grand total time (5 runs): 1748 ms, with file reading total: 1933 ms

Dot42 C#: Grand total time (5 runs): 5150 ms, with file reading total: 5459 ms

To me, it was also interesting to note that Xamarin C# is slightly faster than Java on a newer ARM device and slightly slower on the old Nexus One. If anyone would like to run these tests as well, please let me know and I'll update the sources on GitHub. It would be particularly interesting to see results from a real Android device with Intel processor.

Update 7/26/2013

Just a quick update, re-compiled by benchmark apps with the latest Xamarin.Android 4.8, and also with dot42 1.0.1.72 update released today - no significant changes from the results reported before.

Update 7/30/2013 - better results for dot42

Re-tested Dot42 with Robert's (from dot42 makers) port of my Java code to C#. In my C# port done initially for Xamarin, I replaced some native Java classes, like ListArray, with List class native to C#, etc. Robert did not have my Dot42 source code, so he ported it again from Java and used original Java classes in such places, which benefits Dot42, I guess because it runs in Dalvik VM, like Java, and not in Mono, like Xamarin. Now Dot42 results are much better. Here is a log from my testing:

7/30/2013 - Dot42 tests with more Java classes in Dot42 C#

Intel emulator, Android 4.2

Dot42, Greg's Code using StringBuilder.Replace() (as in Xamarin):
Grand total time (5 runs): 3646 ms, with file reading total: 3830 ms

Dot42, Greg's Code using String.Replace() (as in Java and Robert's code):
Grand total time (5 runs): 3027 ms, with file reading total: 3206 ms

Dot42, Robert's Code:
Grand total time (5 runs): 1781 ms, with file reading total: 1999 ms

Xamarin:
Grand total time (5 runs): 1373 ms, with file reading total: 1505 ms

Java:
Grand total time (5 runs): 1841 ms, with file reading total: 2044 ms

ARM, Samsung Galaxy Note 2, power saving off, Android 4.1.1

Dot42, Greg's Code using StringBuilder.Replace() (as in Xamarin):
Grand total time (5 runs): 10875 ms, with file reading total: 11280 ms

Dot42, Greg's Code using String.Replace() (as in Java and Robert's code):
Grand total time (5 runs): 9710 ms, with file reading total: 10097 ms

Dot42, Robert's Code:
Grand total time (5 runs): 6279 ms, with file reading total: 6622 ms

Xamarin:
Grand total time (5 runs): 6201 ms, with file reading total: 6476 ms

Java:
Grand total time (5 runs): 7141 ms, with file reading total: 7479 ms

I still think that Dot42 has a long way to go. Having Java-like classes (e.g. ArrayList) and a good performance with them would make porting code from Java to C# slightly easier. However, this is something I would not be likely to do a lot. I would rather want to use existing C# code (libraries etc.), which will use native C# classes (e.g. List), and that would perform slowly with the current dot42 code, and very well with Xamarin.

Greg

0
votes
answers
23 views
+10

Xamarin車手共享項目?

-1

JetBrains Rider是否支持Xamarin共享項目?Xamarin車手共享項目?

我知道Rider支持Xamarin iOS和Android應用程序,但我想知道我是否可以在此處使用與Visual Studio相同的代碼共享。我搜查JetBrains網站並找不到任何東西。

沙发
0
1

是的,騎手應該適用於任何類型的共享項目。如果您知道有關xamarin共享項目支持的任何問題,請在此告訴我們:https://youtrack.jetbrains.com/issues/RIDER#newissue