Esptouch移植xamarin記要

目標:android

1.支持最新esptouch庫更新ios

2.android和IOS雙端混合UI開發Appgit

解決思路:github

到esptouch官方開源項目庫(android,ios)編譯jar及ios標準庫到xamarin項目引用。app

實現:測試

1. 下載esptouch庫,開源地址: https://github.com/EspressifApp/EsptouchForAndroidui

2. 經過android studio編譯aar文件3d

Gradle/Tasks/build 雙擊build選項code

image

編譯完成後會在當前項目目錄下的如下路徑生成arr文件對象

esptouch\build\outputs\aar

image

3.建立Xamarin工程

a.啓動 vs2017 新建項目

image

b.選擇項目模板

image

c.項目創建

image

d.建立android轉換庫項目

image

e. 添加aar文件到jars文件夾

image

f.引入aar文件

image

g.設置編譯生成操做爲LibraryProjectZip

image

h.編譯轉換庫項目

image

編譯錯誤:

image

雙擊錯誤提示進入錯誤代碼段:

image

改正後:

image

雙擊錯誤提示針法進入代碼可先選擇EmbeddedNativeLibrary編一次再選回LibraryProjectZip編後便可雙擊錯誤提示進入代碼。

image

從新編譯:

image

統譯成功

i.引用庫到android項目

image

j.庫對象瀏覽能夠查看接口

image

k.配置android項目權限,鉤選兩個圖中打鉤的項

image

4.測試運行功能

a.打開app項目引用接口項目

image

b.在任意代碼位置以下使用:

           var esp = DependencyService.Get<ISmartConfigTask>();            if (esp != null)            {                esp.SetSmartConfigTask("", "", "12345678");            }

相關文章
相關標籤/搜索