Translate

2016년 2월 24일 수요일

[Toad] You are user 3. Only 2 simultaneous freeware connections are allowed to each database. 문제



Program: Toad for Oracle Freeware v12.8 (64-bit)



증상

DB 접속 시 아래와 같이 메시지가 나오며 DB에 정상적으로 접속이 되지 않는다.


 You are user 3. Only 2 simultaneous freeware connections are allowed to each database.






원인 및 해결방법

Freeware Toad 의 경우에는 2개까지만 DB커넥션이 가능한데 이 기준이 본인 PC에서의 커넥션 기준이 아니라 같은 네트워크의 커넥션 기준이다.

공유기를 사용하는 환경이라면 여러명이서 Freeware Toad 로 DB에 붙는경우 3번째로 Toad를 켜고 DB에 접속하는 경우에 위와같은 화면을 볼 수 있다.


회사같이 협업해야 하는 경우에는 여러명이서 각각 DB접속을 해야 할 텐데..
실질적으로 Freeware Toad 로는 업무가 어렵다고 보면 된다.



결국 상용 툴을 사용하거나 Oracle SQL Developer (Download Link) 와 같은 무료 툴을 사용할 수 밖에 없다.



2016년 2월 20일 토요일

[Android] WebView 에서 Javascript apply function이 작동되지 않는 이슈




증상

PC 버전의 Chrome 에서는 Function 객체에 apply 사용 시 정상적으로 작동이 되는 것을 확인했는데 안드로이드에서 apply 작동이 되지 않았다.

내가 사용한 코드는 아래와 같았다.
window.[method].apply(null, args);






원인

apply 함수의 첫번째 인자로 this 객체를 넘겨주지 않아서 문제가 되었다.








해결방법

apply 함수 실행 시 첫번째 인자로 Android Bridge 객체를 같이 넘겨줘야 한다.


안드로이드
WebView.setJavaScriptEnabled( true );
WebView.addJavascriptInterface( new MyBridge(), "AppInterface" );

private class MyBridge{
 public void functionName( String arg ){
  // do sth..
 }
}



자바스크립트
var args = {};
window.AppInterface.functionName.apply(window.AppInterface, args);







참고
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
http://stackoverflow.com/questions/14231463/javascript-apply-function-is-not-working-on-android-webview


2016년 2월 19일 금요일

[Android] already added: Lcom/google/ads/AdRequest 오류 해결방법




증상

Android 프로젝트 빌드 시 아래와 같은 오류가 발생하며 정상적으로 빌드가 되지 않았다.



Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$ErrorCode;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$Gender;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdSize;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zza;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zzb;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zzc;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/ads/mediation/AbstractAdViewAdapter$zzd;
Unable to execute DX
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
... 13 more










원인


기존에 제작하던 App 에서 google-play-services 모듈을 의존성 걸고 사용하고 있었는데 카카오연동을 하면서 카카오모듈에 있는 google-play-services 와 충돌이 난 것으로 보인다.





구조를 보자면 아래와 같다.

My App Dependency
  ㄴ google-play-services_lib
  ㄴ kakao-android-sdk-project







해결방법

kakao 모듈의 lib에 있는 google-play-services.jar 가 들어있는 libs디렉토리 BuildPath 를 빼고 다음의 구조와 같이 변경해 줬다.

My App Dependency
  ㄴ google-play-services_lib
  ㄴ kakao-android-sdk-project
      ㄴ google-play-services_lib





IntelliJ 기준





참고
http://stackoverflow.com/questions/19814956/android-admob-exception-after-refresh-sdk



[Ubuntu] VNC 접속 시 회색 화면만 나오는 증상 해결방법



OS: Ubuntu 14.04



증상

우분투에 VNC 설치를 후 아래와 같이 기동시 회색 화면이 나왔다.


 $ vncserver







원인
위와같이 나온 이유는 VNC 접속 후 실행될 Application 이 아무것도 없어서 위와같이 나온다.



해결방법
아래와 같이 작업 후 정상적으로 나오는 것을 확인했다.



1. 기동중인 VNC 종료
1004lucifer

 # 구동된 VNC포트번호에 따라 숫자가 1~5 로 변경될 수 있다.
 $ vncserver -kill :1




2. ~/.vnc/xstartup 파일 내용변경


$ vi ~/.vnc/xstartup

# ======= 내용 ========
#!/bin/sh
def
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

gnome-terminal &
#===================




3. VNC 기동


 $ vncserver

 New 'X' desktop is server:1

 Starting applications specified in /home/user/.vnc/xstartup
 Log file is /home/user/.vnc/server:1.log

 $







2016년 2월 15일 월요일

[Android] signal 6 (SIGABRT) 해결방법




signal 6 에러가 발생을하며 App 이 종료되는 이슈가 있어서 원인분석을 해봤다.




App 이 종료되며 아래와 같은 로그가 발생된다.


Fatal signal 6 (SIGABRT) at 0x000045fd (code=-6), thread 17917 (r.blabla)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Revision: '0'
pid: 17917, tid: 17917, name: r.blabla  >>> kr.or.blabla <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    r0 00000000  r1 000045fd  r2 00000006  r3 00000000
    r4 00000006  r5 0000000c  r6 000045fd  r7 0000010c

...


backtrace:
    #00  pc 000220dc  /system/lib/libc.so (tgkill+12)
    #01  pc 00013131  /system/lib/libc.so (pthread_kill+48)

...

    #27  pc 0000105b  /system/bin/app_process
    #28  pc 0000e49b  /system/lib/libc.so (__libc_init+50)
    #29  pc 00000d7c  /system/bin/app_process
    at android.graphics.Typeface.nativeCreateFromAsset(Native Method)
    at android.graphics.Typeface.createFromAsset(Typeface.java:+4)
    at kr.or.blabla.ui.ProductCustomTV.applyTypeface(ProductCustomTV.java:+10)
    at kr.or.blabla.ui.ProductCustomTV.applyTypeface(ProductCustomTV.java:+22)
    at kr.or.blabla.ui.ProductCustomTV.<init>(ProductCustomTV.java:+6)
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:+20)
    at android.view.LayoutInflater.createView(LayoutInflater.java:+168)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:+148)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:+224)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:+246)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:+498)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:+24)
    at kr.or.blabla.left.CategoryAdapter.getView(CategoryAdapter.java:+16)
    at android.widget.AbsListView.obtainView(AbsListView.java:+284)
    at android.widget.GridView.onMeasure(GridView.java:+282)
    at kr.or.blabla.util.ExpandableHeightGridView.onMeasure(ExpandableHeightGridView.java:+30)
    at android.view.View.measure(View.java:+274)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:+84)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:+12)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:+482)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:+10)
    at android.view.View.measure(View.java:+274)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:+84)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:+12)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:+482)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:+10)
    at android.view.View.measure(View.java:+274)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:+84)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:+12)
    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:+914)








원인을 알고나니 위의 로그가 확실히 보였지만
App이 종료되며 아래와 같은 로그가 같이 발생한 경우가 있었다.


mmap(0,1665467) failed: Out of memory
create map from entry failed
java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:195)
at android.graphics.Typeface.createFromAsset(Typeface.java:169)
at kr.or.blabla.ui.ProductCustomTV.applyTypeface(ProductCustomTV.java:36)
at kr.or.blabla.ui.ProductCustomTV.applyTypeface(ProductCustomTV.java:29)
at kr.or.blabla.ui.ProductCustomTV.<init>(ProductCustomTV.java:18)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)





전체로그 다운받기 => Link




PS.
생성된 로그를 가지고 분석 시 아래와 같은 원인&해결방법을 알아내었다.
로그에 따라 원인&해결방법이 달라질 수 있다.




원인

Custom Font 를 사용하면서 Font Resource 를 재사용하지 않아서 발생한 문제였다.
(로그 분석시..)






해결방법
1004lucifer
Custom Font 의 Resource 를 재사용 하도록 수정 후에는 증상이 발생하지 않았다.




기존 소스

public class HansalimCustomTV extends TextView {

 public HansalimCustomTV(Context context) {
  super(context);
 }

 public HansalimCustomTV(Context context, AttributeSet attrs) {
  super(context, attrs);
  applyTypeface(context, attrs);
 }

 public HansalimCustomTV(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  applyTypeface(context, attrs);
 }

 private void applyTypeface(Context context, AttributeSet attrs) {
  TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.HansalimCustomTV);
  String typefaceName = arr.getString(R.styleable.HansalimCustomTV_typeface);
  applyTypeface(context, typefaceName);
  arr.recycle();
 }

 public boolean applyTypeface(Context context, String asset) {
  Typeface typeface = null;
  try {
   typeface = Typeface.createFromAsset(context.getAssets(), asset);
  } catch (Exception e) {
   e.printStackTrace();
   return false;
  }
  setTypeface(typeface);
  return true;
 }
}




수정 후

public class HansalimCustomTV extends TextView {
 
 private static Typeface typeface;

 public HansalimCustomTV(Context context) {
  super(context);
 }

 public HansalimCustomTV(Context context, AttributeSet attrs) {
  super(context, attrs);
  applyTypeface(context, attrs);
 }

 public HansalimCustomTV(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  applyTypeface(context, attrs);
 }

 private void applyTypeface(Context context, AttributeSet attrs) {
  TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.HansalimCustomTV);
  String typefaceName = arr.getString(R.styleable.HansalimCustomTV_typeface);
  applyTypeface(context, typefaceName);
  arr.recycle();
 }

 public boolean applyTypeface(Context context, String asset) {
  
  try {
   if (typeface == null) {
    typeface = Typeface.createFromAsset(context.getAssets(), asset);
   }
  } catch (Exception e) {
   e.printStackTrace();
   return false;
  }
  setTypeface(typeface);
  return true;
 }
}




참조:
http://stackoverflow.com/questions/23977114/custom-font-in-android-leaking-memory
https://code.google.com/p/android/issues/detail?id=9904
http://blog.csdn.net/qlx2522/article/details/47101947


2016년 2월 3일 수요일

[리뷰][서적] 자바스크립트 이해와 AngularJS 활용 - 빠르게 앵귤러 프레임워크를 습득하기에 좋은책




자바스크립트 이해와 AngularJS 활용 - 8점
강요천 지음/이한디지털리(프리렉)


AngularJS 프레임워크를 이용해서 처음 개발을 시작했을 때..

AngularJS 로 만들어진 프로젝트 소스를 보면서 어떻게 사용해야 하는지 이해하기 힘들어서 위의 책을 사서 읽었는데 400페이지 라고는 하지만 않게 책이 상당히 얇다.

게다가 책의 절반이 자바스크립트 설명으로 이루어져 있어서
Angular 프레임워크에 대한 내용은 그리 많지 않다.



점수를 후하게 준 이유는 회사 퇴근 후 집에서 두어시간 정도 봤는데 이틀만에 앵귤러 부분을 다 보고 기본적인 사용방법을 알 수가 있었기 때문이다.

초급자가 보기에 상당히 좋으며 빠르게 바로 앵귤러 프로젝트를 해야 하는 상황에서 상당히 적합한 책이라고 생각이 든다.


단점으로는 Angular에 대해서 심도있게 다루지 않다보니 중고급 서적을 하나 더 봐야 한다는게 단점이랄까..



[Youtube] Failed to execute 'postMessage' on 'DOMWindow' 오류




Youtube 연동 중 아래와 같은 상황이 발생했다.



Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://youtube.com') does not match the recipient window's origin ('https://www.youtube.com').





메시지를 잘 읽어보면 금방 해결될 문제였는데..
두시간 정도 구글을 찾아보다가 이전에 Youtube API 연동 글(Link)을 보면서 비교해가며 찾았다.

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://youtube.com') does not match the recipient window's origin ('https://www.youtube.com').


결론은 iFrame 으로 Youtube 영상을 삽입 시 도메인을 https://www.youtube.com 으로 해줘야 한다.



틀린방법 (X)

<iframe 
id="gangnamStyleIframe" 
width="560" 
height="315" 
src="https://youtube.com/embed/9bZkp7q19f0?rel=0&enablejsapi=1" 
frameborder="0" 
allowfullscreen></iframe>




올바른 방법 (O)

<iframe 
id="gangnamStyleIframe" 
width="560" 
height="315" 
src="https://www.youtube.com/embed/9bZkp7q19f0?rel=0&enablejsapi=1" 
frameborder="0" 
allowfullscreen></iframe>