Android Studio LatinIME Project Build – 2 2015-10-02

1. native source 복사
* C:\Users\Administrator\Desktop\새 폴더\LatinIME\native\jni 폴더를 app\src\main폴더에 그대로 복사

2. app/build.gradle 파일 수정

android{
    ...    
    sourceSets.main {
        // 컴파일된 라이브러리 저장경로 지정
        jniLibs.srcDir 'src/main/libs'
        // jni 소스가 포함된 경로를 지정
        // - Android.mk & Application.mk를 자동으로 생성해서 편리
        // - 세부설정이 복잡함
        // - 경로 지정하지 않음
        jni.srcDirs = []
    }
    aaptOptions {
        // dictionary 파일을 압축하지 않음
        // - 미설정시 다음 에러
        // - ERROR : File res/raw/main_en.dict from drawable resource
        noCompress "dict"
    }

3. app/src/main/jni/Android.mk 파일 수정

## 컴파일 옵션수정
LOCAL_CFLAGS += -Werror -Wall -Wformat=2 -Wcast-qual -Wcast-align \
    -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self \
    -Woverloaded-virtual -Wsign-promo -Wno-system-headers
LOCAL_NDK_STL_VARIANT := gnustl_shared # X2
## 테스트 관련 부분은 주석처리
#################### Unit test on host environment
#include $(LOCAL_PATH)/HostUnitTests.mk
#################### Unit test on target environment
#include $(LOCAL_PATH)/TargetUnitTests.mk

4. app/src/main/jni/Application.mk 파일 수정

#APP_ABI=all
#APP_STL := c++_static
APP_STL := gnustl_shared
#APP_CPPFLAGS := -std=c++11
APP_CPPFLAGS := -std=gnu++11
NDK_TOOLCHAIN_VERSION := 4.8

5. app/src/main/jni/NativeFileList.mk 파일 수정

## 테스트 관련 부분은 주석처리
#LATIN_IME_CORE_TEST_FILES := \
#    defines_test.cpp \
#    suggest/core/layout/normal_distribution_2d_test.cpp \
#    suggest/core/dictionary/bloom_filter_test.cpp \
#    suggest/policyimpl/dictionary/structure/v4/content/language_model_dict_content_test.cpp \
#    suggest/policyimpl/dictionary/structure/v4/content/probability_entry_test.cpp \
#    suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer_test.cpp \
#    suggest/policyimpl/dictionary/utils/trie_map_test.cpp \
#    utils/autocorrection_threshold_utils_test.cpp \
#    utils/int_array_view_test.cpp

6. NDK 빌드 후 APP을 실행한다. jni라이브러리를 정상적으로 로드 했다면 에러없이 설정화면으로 이동가능하다.
Screenshot_2015-10-03-11-08-33

이제 개발환경이 완료되었다 다음에는 한글을 입력할 수 있도록 설정해보자

Android Studio LatinIME Project Build – 1 2015-10-02

1. Git Client 다운로드 & 설치
* https://git-scm.com/downloads
* OS에 맞는 설치파일 다운로드 & 설치

2. Git Bash 실행 & Clone
* clone 받을 폴더로 이동
* git clone https://android.googlesource.com/platform/packages/inputmethods/LatinIME 실행
※ 사이트주소 : https://android.googlesource.com/platform/packages/inputmethods/LatinIME/

3. Android Studio 다운로드 & 설치
* https://developer.android.com/sdk/index.html
* OS에 맞는 설치파일 다운로드 & 설치
* SDK & NDK 설치

4. phone에 빌드를 위해 드라이버 설치

5. Project 생성

6. 자동 생성된 소스 삭제 & LatinIME 소스에서 다음을 복사
* app/src/main/java/삭제
* app/src/main/res/삭제
* app/src/main/java/com.android.inputmethod/
=> java 폴더의 소스 + java-overridable 폴더의 소스
* app/src/main/res
* app/src/main/AndroidManifest.xml (overwrite)

7. APP build & Run 에서 에러 발생 – (1)

Error:Execution failed for task ':app:mergeDebugResources'.
> {APP_PATH}\app\src\main\res\values\strings-emoji-descriptions.xml:259:65: Error: 주석에서 부적합한 XML 문자(유니코드: 0xd83c)가 발견되었습니다.

* {APP_PATH}\app\src\main\res\values\strings-emoji-descriptions.xml 파일을 다른에디터에서 문자셋을 변경해서 복사

8. APP build & Run 에서 에러 발생 – (2)

C:\Users\Administrator\Desktop\OneTouchKey\app\src\main\res\values\colors.xml
Error:(2) Attribute "divider" has already been defined

* build.gradle 파일의 의존성을 다음과 같이 수정한다.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v13:23.0.1'
    //compile 'com.android.support:appcompat-v7:23.0.1'
}

9. APP build & Run 에서 에러 발생 – (3)

Error:(28, 24) error: package javax.annotation does not exist
Error:(184, 6) error: cannot find symbol class Nonnull

app/libs/jsr305-1.3.7.jar 라이브러리 추가

10. APP build & Run 에서 에러 발생 – (4)

Error:(22, 37) error: package com.android.inputmethodcommon does not exist
Error:(35, 42) error: cannot find symbol class InputMethodSettingsFragment
...

* 다음 패키지 추가 : com.android.inputmethodcommon
* 클래스 파일 추가 : InputMethodSettingsActivity.java, InputMethodSettingsFragment.java, InputMethodSettingsImpl.java, InputMethodSettingInterface.java

11. APP build & Run 에서 에러 발생 – (5)

Error:Execution failed for task ':app:compileDebugNdk'.
> Error: NDK integration is deprecated in the current plugin.  Consider trying the new experimental plugin.  For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.  Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.

* Android Studio 1.3 이상의 경우 기본적으로 Android Gradle Plugin에서 지원하는 방식으로 NDK를 빌드하지만 이전방식을 사용하기 위해서는 gradle.properties파일에 다음내용을 추가

# gradle.properties
android.useDeprecatedNdk=true

12. APP 실행
* 앱이 실행됨을 확인
* 키보드가 동작하기 위해서는 NDK build 설정이 필요하다 이는 따로 블로깅예정
Screenshot_2015-10-02-18-09-24

[문제해결] Cannot run program “svn” (in directory “C:\…): CreateProcess error=2, 지정된 파일을 찾을 수 없습니다. 2015-09-26

1. 문제상황

> Android Studio에서 Subversion 에 Import 시도시 다음과 같은 에러메시지가 출력되었다.

Cannot run program "svn" (in directory "C:\...): CreateProcess error=2, 지정된 파일을 찾을 수 없습니다.

androidStudio


2. 문제확인

> Subversion command-line client를 설치해야한다.


3. 문제해결

> program download : http://server.opendocs.co.kr/Apache-Subversion-1.9.2.zip

http://www.visualsvn.com/downloads/ 에 접속하여 `Apache Subversion command line tools`를 다운로드 한다.

androidStudio_download
> 환경변수 설정

압축을 해제하면 bin, License 폴더가 있고 bin 폴더의 파일을 실행할 수 있도록 PATH 환경 변수를 설정한다.

androidStudio_path