안드로이드에서 동영상 목록을 뿌려주려고 Cursor 객체를 받아오려는데


managedQuery(Uri, String[], String, String[], String) 함수를 사용하려고 했더니 다음과 같은 deprecated되었다는 경고메시지가 떴다.


The method managedQuery(Uri, String[], String, String[], String) from the type Activity is deprecated



그냥 사용 가능하지만 거슬리기때문에 수정할 필요가 있겠다.


(Activity를 상속한 클래스 내에서라면) 경고메시지를 없애기 위해 다음의 메소드로 변경해주면 된다.


물론 여기서, 메소드 호출할 때의 파라미터는 각자의 용법에 맞게 고쳐 쓰도록 한다.


getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);



이 메소드의 원형은 다음과 같다.

Cursor android.content.ContentResolver.query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)





참고: http://stackoverflow.com/questions/12714701/deprecated-managedquery-issue

Posted by Kugi
,



간단한 테스트용 클래스를 만드는데  vector때문에 컴파일 에러가 발생했다.


error C2143: 구문 오류 : ';'이(가) '<' 앞에 없습니다.

error C4430: 형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다.

error C2238: ';' 앞에 예기치 않은 토큰이 있습니다.


헤더 선언 [#include <vector>] 및 네임스페이스 선언 [using namespace std;]는 미리 컴파일된 헤더[stdafx.h]에 추가해두었기 때문에

정상적으로 컴파일이 되어야 했으나 그러지 못했다.


짐작되는 원인으로는,

openCV라이브러리를 사용하고 있는데 이 라이브러리 내부의 네임스페이스와 겹치거나 하는 일이 생기는 듯 하다.



vector 선언에 네임스페이스를 명시해주니 문제가 해결되었다.

  --> std::vector<PCTYPE> m_ticks;



header


#pragma once

#define PCTYPE		__int64

class PerformCheck
{
private:
	PCTYPE m_lastTick;
	PCTYPE m_currentTick;

	vector<pctype> m_ticks;   // a compile error occurred here. attach "std::"

public:
	PerformCheck();
	~PerformCheck();

public:
	// Add current tick count to the queue with incremental index.
	// @return: elapsed time from last call to current call
	PCTYPE AddCheck();

	PCTYPE GetElapsed(const unsigned int& idxFrom, const unsigned int& idxTo);

	inline
	void Clear()
	{
		m_ticks.clear();
		m_lastTick = cvGetTickCount();
	}
};


Posted by Kugi
,



Problem:


오랜만에 Cpp 프로젝트를 다루다가 한 줄 짜리 클래스 멤버 함수를 inline으로 선언했더니 에러가 발생했다.


1>main.obj : error LNK2019: "public: FunctionType ClassName::FunctionName(void)" (?FunctionName@ClassName@@ObjID) 외부 기호(참조 위치: _main 함수)에서 확인하지 못했습니다.

1>...\test.exe : fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.



Solution:


해결 방법은 간단하다.


클래스 멤버 함수의 경우, inline으로 선언하면 함수 정의는 .cpp가 아닌 .h파일에 포함되어야 한다.







예전에도 비슷한 실수를 한 적이 있었는데, 또 저지르고 말았다. 반성... ㅜ ^ ㅜ

Posted by Kugi
,



Windows Embedded Compact 7 응용 어플리케이션 개발 설정을 위해 테스트 도중 다음과 같은 에러가 발생했다.

1>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\atlmfc\include\atlbase.h(7362) : error C2668: 'ATL::InlineIsEqualGUID' : 오버로드된 함수에 대한 호출이 모호합니다.
1>        c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ce\atlmfc\include\atlosapice.h(1313): 'int ATL::InlineIsEqualGUID(const GUID &,const GUID &)'일 수 있습니다.
1>        C:\Program Files (x86)\Windows CE Tools\SDKs\TCC892x_W7_SDK\include\ARMv4I\guiddef.h(138): 또는 'int InlineIsEqualGUID(const GUID &,const GUID &)'[인수 종속성을 조회하여 발견)

 

원인:

  AtlBase.h에 using namepace ATL;이 선언되어있기 때문에 sdk와 충돌이 생기는 듯 하다. 

 

해결 방법:

  atlbase.h의 전역 네임스페이스 이름을 명시해준다.

::ATL::InlineIsEqualGUID()

 

예시:

if ((pEntry->pfnGetClassObject != NULL) && ::ATL::InlineIsEqualGUID(rclsid, *pEntry->pclsid))
{
	if (pEntry->pCF == NULL)
	{
		CComCritSecLock lock(_AtlComModule.m_csObjMap, false);
		hr = lock.Lock();
		if (FAILED(hr))
		{
			ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CComModule::GetClassObject\n"));
			ATLASSERT(0);
			break;
		}
		if (pEntry->pCF == NULL)
			hr = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, __uuidof(IUnknown), (LPVOID*)&pEntry->pCF);
	}
	if (pEntry->pCF != NULL)
		hr = pEntry->pCF->QueryInterface(riid, ppv);
	break;
}

 

 

 

참고 링크:

BUG: A "C2668: 'InlineIsEqualGUID'" error occurs when you try to build a default ATL project that contains a COM object in Visual C++

 

 

 

 

Posted by Kugi
,



우분투에서 angularJS 프로젝트의 테스트를 위해

karma server를 실행시키려고 했는데 다음과 같은 에러 메시지가 떴다.

Starting Karma Server (http://karma-runner.github.io)
-------------------------------------------------------------------
INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome
    Can not find the binary google-chrome
    Please set env variable CHROME_BIN


크롬의 바이너리 실행파일에 대한 환경변수가 설정되어있지 않아서 뜨는 에러인 것 같다.


우분투 소프트웨어 센터에서 크롬 브라우저를 이미 설치했다면


터미널에서 다음 구문을 실행시켜서 간단하게 해결할 수 있다.

export CHROME_BIN="/usr/bin/chromium-browser"


Posted by Kugi
,