레이블이 android인 게시물을 표시합니다. 모든 게시물 표시
레이블이 android인 게시물을 표시합니다. 모든 게시물 표시

2018년 1월 13일 토요일

Android Weekly #282 번역글



원본: http://mailchi.mp/androidweekly/android-weekly-282?e=cae561fb9f


ARTICLES & TUTORIALS

Dagger에서 Koin으로 (미디엄 링크)

이 게시물에서 Arnaud Giuliani는 Dagger에서 Kotlin 기반 종속성 주입 프레임 워크 Koin으로 마이그레이션하는 방법을 설명합니다. 프록시 / CGLib 없고, 코드 생성 없고, introspection 없음. Kotlin 기능 및 DSL 매직을 이야기합니다.

Firebase Predictions 탐험 (링크)

Joe Birch는 새로운 Firebase Predictions에 대해 설명합니다. Firebase Predictions를 사용하면 응용 프로그램의 사용자 행동을 예측하고 이를 사용하여 응용 프로그램의 유지를 향상시킬 수 있습니다.

아키텍쳐 컴포넌트 함정 - 1부 (링크)

Christophe Beyls는 대부분 문서화되지 않았고 거의 논의되지 않는 중요한 함정에 중점을 두고 있으며, 놓친 경우 응용 프로그램에 문제를 일으킬 수 있습니다.

안드로이드에서 높이 다루기 (링크)

Sebastiano Poggi는 높이가 올라가면서 UI 요소의 그림자를 조정할 수 있음을 보여줍니다.

Grox: 상태의 예술 (링크)

이 블로그 포스트에서 Alin Turcu는 최신 Groupon Open Source Library : Grox를 소개합니다. Grox는 모든 애플리케이션의 상태를 유지하는 데 도움을줍니다. Grox의 개념은 Redux 또는 Flux와 같은 JavaScript 프레임워크와 비교할 수 있습니다. 이는 단방향 데이터 흐름이며 불변의 데이터 구조를 뒷받침합니다.

Canvas: 진정한 놀이터! (링크)

이 포스트에서 Saurabh Pant는 뷰 캔버스에 직접 그리는 방법을 설명합니다.

RadialGradient - Layers (링크)

이전 글에서는, RadialGradiant 렌더링은 하드웨어 계층이 아닌 소프트웨어 계층을 사용하여 수행되었습니다. 이 짧은 시리즈에서 Mark Allison은 차이점이 무엇인지 살펴 봅니다.

라이브러리 & 코드

Rings

링크가 사라진 라이브러리입니다..

ads1015

AndroidThings I2C 프로토콜을 사용하는 ADS1015 주변 장치를 지원하는 아날로그 - 디지털 변환기 드라이버입니다.

kotlinconf-app

공식 KotlinConf 응용 프로그램입니다! 응용 프로그램의 모든 부분은 Kotlin으로 구현됩니다. 백엔드, 프론트엔드 및 모바일 응용 프로그램 등등!

grox

Grox는 Java / Android 앱의 상태를 유지하는 데 도움을 줍니다.

뉴스

Kotlin 공식 가이드

이 사이트에는 Android 용 Kotlin Style 및 Java Interop(interoperability) Guides가 포함되어 있습니다.

Kotlin 업데이트

Android에서 최신 Kotlin 지원 상태에 대한 Google의 업데이트.

비디오 & 팟캐스트

droidcon NYC 2017


Kotlin visibility modifiers, internal modifier, modules


droidcon London 2017

2017년 6월 20일 화요일

개인적인 Gradle 공부


요즘 Gradle을 많이 보고 다룰 일이 생겨서 개인적으로 공부해보기로 했습니다.

Gradle, 그래들이라고 불리는 이건 뭘까요?
위키에는 뭐라고 써있는지 보겠습니다.
Gradle은 Groovy를 이용한 빌드 시스템이다. Groovy와 유사한 도메인 언어를 채용하였으며, 현재 안드로이드 앱을 만드는데 필요한 안드로이드 스튜디오의 공식 빌드 시스템이기도 하다. Java, C/C++, Python 등과 같은 여러 가지 언어를 지원한다.
한국 위키는 설명이 좀 부실하네요. 영문 위키가 더 자세히 잘 설명되어있습니다.
https://en.wikipedia.org/wiki/Gradle

그래들이 그루비를 이용한 빌드 시스템이라고 하는데 그럼 그루비는?
https://ko.wikipedia.org/wiki/%EA%B7%B8%EB%A3%A8%EB%B9%84

설명이 꽤나 길군요. 요약해보자면,
자바에 파이썬, 루비, 스몰토크 등의 특징을 더한 
동적 객체 지향 프로그래밍 언어

그래들은 이러한 특징을 가진 그루비를 기반으로 하는 언어를 사용한다고 합니다.
그리고 자바뿐만 아니라 다른 언어를 빌드하는데에도 많이 사용된다고 합니다만,
저는 안드로이드 빌드 때문에 Gradle을 공부하고 싶기때문에
안드로이드 빌드를 중심으로 보겠습니다.

제가 참고한 곳은 안드로이드 개발자 홈페이지 입니다.
https://developer.android.com/studio/build/index.html#detailed-build

빌드의 일반적인 흐름은 다음과 같습니다.


그래들은 이런 빌드 과정을 설정하고 자동화할 수 있도록 해줍니다.
종속성을 어떻게 관리할 것인지, 빌드를 하고 나서 어떻게 처리를 할 것인지,
배포 빌드, 테스트 빌드 등 설정을 할 수가 있습니다.

빌드 구성 파일의 구조는 아래와 같습니다.


제일 위에 있는 build.gradle은 프로젝트의 모든 모듈의 빌드 세팅을 정의합니다.

/**
 * The buildscript {} block is where you configure the repositories and
 * dependencies for Gradle itself--meaning, you should not include dependencies
 * for your modules here. For example, this block includes the Android plugin for
 * Gradle as a dependency because it provides the additional instructions Gradle
 * needs to build Android app modules.
 */

buildscript {

    /**
     * The repositories {} block configures the repositories Gradle uses to
     * search or download the dependencies. Gradle pre-configures support for remote
     * repositories such as JCenter, Maven Central, and Ivy. You can also use local
     * repositories or define your own remote repositories. The code below defines
     * JCenter as the repository Gradle should use to look for its dependencies.
     */

    repositories {
        jcenter()
    }

    /**
     * The dependencies {} block configures the dependencies Gradle needs to use
     * to build your project. The following line adds Android Plugin for Gradle
     * version 2.3.2 as a classpath dependency.
     */

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
    }
}
/**
 * The allprojects {} block is where you configure the repositories and
 * dependencies used by all modules in your project, such as third-party plugins
 * or libraries. Dependencies that are not required by all the modules in the
 * project should be configured in module-level build.gradle files. For new
 * projects, Android Studio configures JCenter as the default repository, but it
 * does not configure any dependencies.
 */

allprojects {
   repositories {
       jcenter()
   }
}
최상위 build.gradle은 프로젝트의 모든 모듈에 공통되는 gradle 저장소와 종속성을 정의하기 위해 buildscript {} 블록을 사용합니다.

모듈 레벨 빌드파일도 한번 보겠습니다. 보통의 안드로이드 앱 프로젝트라면,
project/app/build.gradle 파일을 말합니다.

/**
 * The first line in the build configuration applies the Android plugin for
 * Gradle to this build and makes the android {} block available to specify
 * Android-specific build options.
 */

apply plugin: 'com.android.application'
/**
 * The android {} block is where you configure all your Android-specific
 * build options.
 */

android {

  /**
   * compileSdkVersion specifies the Android API level Gradle should use to
   * compile your app. This means your app can use the API features included in
   * this API level and lower.
   *
   * buildToolsVersion specifies the version of the SDK build tools, command-line
   * utilities, and compiler that Gradle should use to build your app. You need to
   * download the build tools using the SDK Manager.
   */

  compileSdkVersion 25
  buildToolsVersion "25.0.3"

  /**
   * The defaultConfig {} block encapsulates default settings and entries for all
   * build variants, and can override some attributes in main/AndroidManifest.xml
   * dynamically from the build system. You can configure product flavors to override
   * these values for different versions of your app.
   */

  defaultConfig {

    /**
     * applicationId uniquely identifies the package for publishing.
     * However, your source code should still reference the package name
     * defined by the package attribute in the main/AndroidManifest.xml file.
     */

    applicationId 'com.example.myapp'

    // Defines the minimum API level required to run the app.
    minSdkVersion 15

    // Specifies the API level used to test the app.
    targetSdkVersion 25

    // Defines the version number of your app.
    versionCode 1

    // Defines a user-friendly version name for your app.
    versionName "1.0"
  }

  /**
   * The buildTypes {} block is where you can configure multiple build types.
   * By default, the build system defines two build types: debug and release. The
   * debug build type is not explicitly shown in the default build configuration,
   * but it includes debugging tools and is signed with the debug key. The release
   * build type applies Proguard settings and is not signed by default.
   */

  buildTypes {

    /**
     * By default, Android Studio configures the release build type to enable code
     * shrinking, using minifyEnabled, and specifies the Proguard settings file.
     */

    release {
        minifyEnabled true // Enables code shrinking for the release build type.
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

  /**
   * The productFlavors {} block is where you can configure multiple product
   * flavors. This allows you to create different versions of your app that can
   * override defaultConfig {} with their own settings. Product flavors are
   * optional, and the build system does not create them by default. This example
   * creates a free and paid product flavor. Each product flavor then specifies
   * its own application ID, so that they can exist on the Google Play Store, or
   * an Android device, simultaneously.
   */

  productFlavors {
    free {
      applicationId 'com.example.myapp.free'
    }

    paid {
      applicationId 'com.example.myapp.paid'
    }
  }

  /**
   * The splits {} block is where you can configure different APK builds that
   * each contain only code and resources for a supported screen density or
   * ABI. You'll also need to configure your build so that each APK has a
   * different versionCode.
   */

  splits {
    // Screen density split settings
    density {

      // Enable or disable the density split mechanism
      enable false

      // Exclude these densities from splits
      exclude "ldpi", "tvdpi", "xxxhdpi", "400dpi", "560dpi"
    }
  }
}
/**
 * The dependencies {} block in the module-level build configuration file
 * only specifies dependencies required to build the module itself.
 */

dependencies {
    compile project(":lib")
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

제가 보통 보는 블록은 defaultConfig, buildType, dependencies 정도인 것 같네요.
splits나 productFlavors를 잘 사용하면 무료, 유료 앱 따로 빌드하기나 
화면 해상도에 따른 빌드 설정을 각각해줄 수 있을 것 같네요.

그리고 추가적으로, 빌드할 때 필요한 설정을 가지고 있는 파일들이 있습니다.
- gradle.properties: 프로젝트 범위의 그래들 설정을 함. 예, gradle daemon 힙 크기 설정
- local.properties: 빌드 시스템의 로컬 환경을 구성. 예, sdk, ndk 경로 설정

뭔가 간단한 앱을 만들때는 build.gradle 파일을 많이 수정할 일이 없었는데
모듈을 만들어서 붙이고, 다른 플러그인도 같이 사용하게되면
종속성이나 여러가지 신경써야할 포인트가 많은 것 같습니다.

이 포스트를 시작으로 책도 좀 보고 더 깊게 공부해봐야겠습니다.

Gradle의 GitHub 주소를 남기고 글 마치겠습니다.

2017년 1월 12일 목요일

Admob banner not showing on app started issue on Android 6.0

Cocos2d-x 로 게임을 개발하던 중에 배너를 달았지만
앱 시작 시에 바로 나오지않고 1분 뒤에 새로고침될 때에 나오거나 앱이 resume 될 때 
광고가 나오는 현상이 발생했다.

모든 OS에서 그런 줄 알았는데 마시멜로우 버전 이상에서만 발생한다.

여기저기 찾아보던중

아래와 같은 코드가 자꾸 있길래 지웠는데 혹시나해서 그냥 해봤더니
처음 시작부터 광고가 잘나오기 시작한다.

adView.setBackgroundColor(Color.BLACK);
adView.setBackgroundColor(0);

...

이렇게 하니 모든 OS 버전에서 앱 시작과 동시에  광고가 잘 나온다.
어쨌든 해결.

2016년 11월 22일 화요일

Cocos2d-x android back button issue after admob popup webview

Cocos2d-x로 게임을 개발하는중인데
배너광고를 달았는데 그 광고를 터치했을때 광고내용이 나옵니다.
그 이후에 문제가 생겼는데, back 버튼을 누르면 그냥 앱이 나가지는 문제가 발생하였습니다.

그래서 무슨문제인가 찾아봤더니
http://discuss.cocos2d-x.org/t/clicking-back-button-after-clicking-admob-ad-closes-app/17964

액티비티에 focus가 풀려서 그런것이더군요.
코드는 아래와 같이 해결!

if (this.getCurrentFocus() != Cocos2dxGLSurfaceView.getInstance()) { Cocos2dxGLSurfaceView.getInstance().requestFocus(); }

이 코드를 광고가 닫히는 이벤트에 넣으면 알맞게 잘 동작합니다.
I hope this help!

2016년 11월 9일 수요일

안드로이드 보이스 액션(Ok Google, Google Now)


요즘 '오케이 구글'로 검색하고 알림 설정하는데에 재미가 들려서
이렇게 명령을 실행하는 기능의 이름이 뭘까하고 찾아봤습니다.

'보이스 액션' 또는 '구글 나우 액션' 이라고 하네요.
구글 개발자 페이지를 보면 알 수 있었습니다.
https://developers.google.com/voice-actions/system/

그리고 보이스 액션을 사용한다면 어떻게 구현해야하는지도 나와있네요.
https://developers.google.com/voice-actions/system/#step_1_define_an_intent_filter

알람이나 전화걸기, 사진을 가져오는 등에 대한 액션은 이미 정의되어 있어서
어렵지 않게 구현할 수 있을 것 같은데요.

우리가 만든 앱의 특정기능을 실행하는 액션은 어려울 것 같아보입니다.
(한번 해봐야 알겠지만요.)

https://developers.google.com/voice-actions/system/#step_3_update_your_app_completion_status
위의 링크에는 앱 인덱싱을 포함한 빌더를 통해 알람을 세팅할 수 있는
예시코드가 포함되어 있습니다.

시간이 된다면 예시코드와 함께 포스팅을 해봐야겠습니다.

2016년 8월 14일 일요일

Stetho - A debug bridge for Android applications by Facebook



homepage: http://facebook.github.io/stetho/
GitHub: https://github.com/facebook/stetho

이 프로젝트는 간단히 말하면 안드로이드 앱을 디버깅을 쉽게 할 수 있게 해주는
프로젝트입니다.
크롬 개발자 툴을 통해서 안드로이드 앱을 디버깅하겠다는 프로젝트인데
신기해서 한번 들여다봤습니다.

밑에 설명이 더 있는데 한번 가볼까요.


크롬 개발자 툴에서 chrome://inspect로 디버깅 할 수 있고
네트워크 측정을 할 수 있습니다.



데이터베이스도 볼 수 있으며, 뷰 계층도 볼 수 있습니다.



dumpapp은 크롬 DevTool과는 다른 컴포넌트 툴인데 앱을 덤프해서
각종 preference를 설정하고 뭔가 할 수 있는 것 같은데 아직은 잘 모르겠으니
설치하고 한번 알아봐야겠습니다.

또, 자바스크립트 콘솔을 통해서
안드로이드 SDK함수까지도 테스트 할 수 있습니다.

한번 설치하고 튜토리얼을 해보죠.

저는 일단 그래들로 설치해서 설정, 실행까지 해보겠습니다.

app의 build.gradle 파일에서
// Gradle dependency on Stetho dependencies { compile 'com.facebook.stetho:stetho:1.3.1' }
이 compile 'com.facebook.stetho:stetho:1.3.1' 코드를 추가해줍니다.
싱크를 하고나서 onCreate 함수에

//Stetho initStetho.initializeWithDefaults(this);

이 코드를 삽입해줍니다.
(Application 클래스의 onCreate 함수에 넣어 주셔야 합니다.)

그럼 이제 돌려볼까요. 돌리고 나면 Stetho가 디버깅을 하겠다고
영어로 Alert가 뜨는데 그러고 앱이 동작합니다.

그리고 chrome://inspect 에 들어가봅니다.
그러면 지금 돌리고 있는 앱이 나올겁니다.


(요즘 얼굴인식 프로젝트 중이라
여기서 inspect를 눌러보겠습니다.



오오... 한번 뷰가 어떻게 나오는지 보겠습니다.


원래는 웹페이지라면 옆에 스타일을 탭을 통해서 수정할 수 있지만
여기선 별 의미 없는 자리인 것 같습니다.

콘솔테스트도 한번 해보겠습니다.



안되네요.. ㅎㅎ 추가적으로  설치해야하는게 있는 것 같습니다.
"Not supported without stetho-js-rhino dependency"
그럼 추가해줍니다.
아까 추가했던 곳에
compile 'com.facebook.stetho:stetho-js-rhino:1.3.1'

이 코드를 추가해줍니다.
그리고 다시 실행해보겠습니다.



오오... 다른 것도 이것저것 테스트 할 수 있는 좋은 툴인 것 같습니다.

즐거운 코딩하시길!

2016년 7월 21일 목요일

안드로이드 얼굴 인식 해보기 (Android face detection)


이번에 안드로이드 앱 개발 프로젝트가 하나 생겨서
얼굴 인식을 해야할 일이 생겼습니다.

어렵지 않게 안드로이드 쪽 API가 있겠거니 해서 찾아서
테스트 진행!

우선 API가 있나 찾아봅니다.
API 문서: android/media/FaceDetector.html
소개 문서: google/android/gms/vision/face/FaceDetector

코드랩은 쭉 따라가면서 만들어보는 곳인데
사진에 대해서 얼굴 인식을 해보는 예제입니다.
CodeLab: https://codelabs.developers.google.com/codelabs/face-detection/index.html#0

구글 비전 API관련 소스는 아래를 참고하시면 좋습니다.
https://github.com/googlesamples/android-vision

저는 일단은 코드랩을 따라서 진행해봤습니다.
아래와 같은 목표를 가지고 진행을 했는데요.
1. 얼굴의 위치를 가져오자
2. 얼굴의 눈, 코, 입, 등의 구성요소 위치를 가져오자

코드랩을 따라가면
사진을 이용해 1의 목표만을 달성할 수 있었습니다.


코드랩은 이렇게 생겼습니다

2단계에서는 프로젝트를 만들고 프로젝트 세팅을 합니다.
3단계에서는 메인 엑티비티 코드를 수정해서 기능 구현을 하고
4단계에서 결과를 같이 보게 됩니다.

제가 따라하면서 만들었던 코드는 아래와 같습니다.





저는 추가적으로 목표 2를 달성하기 위해
몇줄의 코드를 추가했습니다.

https://developers.google.com/vision/detect-faces-tutorial
여기서 보고 추가한
FaceDetector detector = new FaceDetector.Builder(context)
    .setTrackingEnabled(false)
    .setLandmarkType(FaceDetector.ALL_LANDMARKS)
    .build();
그리고 랜드마크들 위치에 점을 찍기 위해서
얼굴 찾은 반복문에서 랜드마크 리스트를 받고 랜드마크 각각의 위치에
초록색 동그라미를 찍어 주었습니다.


카메라를 이용해서 얼굴인식을 하는 것은 다음 포스트에서 진행하려고 합니다.
그래도 관련 링크는 남겨놓겠습니다!

https://developers.google.com/vision/face-tracker-tutorial

즐거운 코딩하세요!

2016년 5월 8일 일요일

AVD device start error - 'std::logic_error'

My computer ENV

OS: Windows 8.1 embedded
JDK: 1.7.0_79
NDK (not necessary env): r10e
Visual Studio : 2015 community version

This issue occurred when i use Xamarin.
1. Start android emulator
2. Start Nexus 5
3. Error

Error message detail


This error can not fix because of many error factor.
I will fix this error, and post if i can.

2016년 4월 21일 목요일

Cocos2d-x android:label setting fail error



*ENV
- Windows 8.1
- Cocos2d-x 3.9
- Android studio 2.0

*Problem
Merging manifest with lower [proj.android-studio:libcocos2dx:unspecified] AndroidManifest.xml:2:1-16:12
Merging uses-sdk with lower [proj.android-studio:libcocos2dx:unspecified] AndroidManifest.xml:7:5-9:41
Merging application with lower [proj.android-studio:libcocos2dx:unspecified] AndroidManifest.xml:11:5-14:19
Merging result:ERROR
myapp\proj.android-studio\app\AndroidManifest.xml:11:9-41 Error:
        Attribute application@label value=(@string/app_name) from AndroidManifest.xml:11:9-41
        is also present at [proj.android-studio:libcocos2dx:unspecified] AndroidManifest.xml:13:9-36 value=(libcocos2dx).
        Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:8:5-28:19 to override.

I try it Suggestion.

Add code tools:replace="android:label" to element
Like this.


Do Build and success.
PS. It should add xmlns="https://schemas.android.com/tools".


Save your day!

Android Studio 2 install (안드로이드 스투디오2 다운로드)



You can download on this site.
http://tools.android.com/download/studio/builds/2-0

Windows: https://dl.google.com/dl/android/studio/ide-zips/2.0.0.20/android-studio-ide-143.2739321-windows.zip
Mac: https://dl.google.com/dl/android/studio/ide-zips/2.0.0.20/android-studio-ide-143.2739321-mac.zip
Linux: https://dl.google.com/dl/android/studio/ide-zips/2.0.0.20/android-studio-ide-143.2739321-linux.zip


JIRA Plugin - ScriptRunner 소개 #2

관련 글 소개 #1:  https://pineoc.blogspot.com/2019/03/scriptrunner-1.html ScriptRunner 소개 #2 지난 글에서는 Behaviours를 보았고 다음 내용인 콘솔, 리스너 등을 ...