노력과 삽질 퇴적물

크로스 플랫폼: Xamarin(자마린) 앱 개발 (2) 본문

프로그래밍note/언어. C# 계열

크로스 플랫폼: Xamarin(자마린) 앱 개발 (2)

MTG 2016. 12. 29. 02:16


* 만약기본 프로젝트 생성 직후 빌드시, error: duplicate class: src.droid.R등으로 빌드 실패가 뜰 경우
솔루션을 정리하거나 하드상에 완전히 삭제후 다시 시도하다보면 정상적으로 빌드가 됩니다.

* 개인 프로젝트와 병행한 포스팅이라 폴더명등에 모자이크 처리가 존재합니다.


크로스 플랫폼: Xamarin(자마린) 앱 개발 (1)

크로스 플랫폼: Xamarin(자마린) 앱 개발 (2)

크로스 플랫폼: 자마린 설치 번외, VS2017






1. 프로젝트 구성


* Xamarin(자마린) 앱 개발 (1)내 '솔루션 및 프로젝트 생성'에서 이어지는 내용입니다.


1) 공유 데이터 서비스 코드 작성

프로젝트명(이식가능)이 PCL 프로젝트, 플랫폼 공용코드를 작업할 프로젝트입니다.

해당 프로젝트에 폴더등을 추가하고, 또한 공용 클래스를 작성합니다.

(예. SQL등등)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace SOLUTION_NAME
{
    class USR_CLASS
    {
        public string OPT { get; set; }
        ... ... ...
 
        public USR_CLASS()
        {
            //Because labels bind to these values, set them to an empty string to
            //ensure that the label appears on all platforms by default.
            this.OPT = " ";
            ... ... ...
        }
    }
}
cs



2) UI 코드 작성 시작

안드로이드 프로젝트에서 다음과 같은 항목을 추가합니다.






2. 프로젝트 설정


1) 어플 정보 변경

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
 
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
 
namespace proj_name.Droid
{
    [Activity(Label = "앱 이름", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
 
            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());// 공용 프로젝트에 있는 클래스
        }
    }
}
cs

> Label: 출력되는 앱 이름

> Icon

   Resources/drawable등에서 icon.png파일을 교체합니다.

   JAVA&이클립스와 달리 아이콘 파일명이 시스템 상으로 고정된듯합니다.

* 라벨과 아이콘은 [안드로이드용 프로젝트 우클릭>AndroidManifest]에서도 지정이 가능합니다. 간결성을 위해 스크립트가 아닌 AndroidManifest에서 하는방법도 있습니다.

> 패키지 네임

   안드로이드용 프로젝트 우클릭>AndroidManifest



2) 빌드시 유의사항

> 안드로이드용 빌드일 경우, 안드로이드용 프로젝트를 시작 프로젝트로 설정해야합니다.

Application Package Sizes - Xamarin

> Publishing an Application - Xamarin

Linking on Android - Xamarin






3. UI 및 레이아웃 관련


1) 입력 제어

Detect a Touch - Xamarin



2) UI구성

ListView Example in Xamarin.Android (BaseAdapter)

Part 2 - Populating a ListView With Data - Xamarin

Part 3 - Customizing a ListView's Appearance - Xamarin

커스텀 다이얼로그(for xamarin android)

axml, java관련 에러 처리



3) 로컬 저장

SQLite.NET

Create a Database with SQLiteNET

Working with a Local Database

An Introduction to Xamarin.Forms and SQLite

> 샘플 프로젝트: TaskyPortable

> PCL기준입니다. Shared Projects방식은 Working with a Local Database에서 'Using SQLite with Shared Projects'항목을 보시면 됩니다.


Android.Net: Xamarin Android - Application Overview- Using the application class for global variables


sqlite-net-pcl 패키지를 PCL&플랫폼별 프로젝트에 설치합니다. 유사검색결과가 많은데, 작성자와 신고 페이지등등 다음의 정보를 확인해야 합니다.

작성자: Frank A. Krueger

NuGet 링크: https://www.nuget.org/packages/sqlite-net-pcl/xxx/xxx  (xxx부분 생략 가능)


만약, 안드로이드로만 개발하신다면 SharedPreferences로도 가능합니다. [#링크]






기타. openTK


1) 라이브러리

① 연결

에러: OpenTK 설치실패


② 버전 및 API대응

OpenGL ES 1.0 and 1.1 - This API specification is supported by Android 1.0 and higher.

OpenGL ES 2.0 - This API specification is supported by Android 2.2 (API level 8) and higher.

OpenGL ES 3.0 - This API specification is supported by Android 4.3 (API level 18) and higher.

OpenGL ES 3.1 - This API specification is supported by Android 5.0 (API level 21) and higher. 



2) 기본구조

OpenTK.Graphics (OpenGL and ES)

Frame Buffer Objects (FBO)

> Every OpenGL application has at least one framebuffer.

> FBO allows 2 Renderbuffers



3) 2D

2D Texture differences

Drawing

Drawing Optimizations

OpenTK: Simple Movable Sprite



4) 3D

GL Triangle  [#3.0] [#2.0] [#1.0]


5) 오디오

OpenTK.Audio (OpenAL)






기타. 참조자료


Samples - Xamarin

GitHub - xamarin/urho-samples: Samples for the Urho bindings

Stripping unused Java code (from components) - Xamarin Forums


최초가 되거나 최고가 되어라 :: 03. Xamarin(자마린)을 이용하여 Android/Windows/iOS에 Hello World 출력하기


Building Cross Platform Applications - Xamarin

Part 1. Getting Started with XAML - Xamarin

Creating Mobile Apps with Xamarin.Forms Book First Edition - Xamarin

Part 3 - Setting Up A Xamarin Cross Platform Solution - Xamarin

Part 1 - Designer Basics - Xamarin






기타. 변경이력


일자

변경이력

2016-12-29

 초안