리눅스 민트(버전13)을 설치하고 한글 언어 설정을 하려고 했는데 다음과 같은 형태의 Failed가 떴다.
(정확한 내용은 기억이 나질 않아서 유사한 형태의 메시지를 첨부한 것이다. 서버 IP 주소는 91.189.91.13 : 80 으로 동일하다.
...
Failed to fetch http://security.ubuntu.com/ubuntu/dists/nadia-security/main/binary-amd64/Packages 404 Not Found [IP: 91.189.92.200 80]
...
Failed to fetch http://mirror.umd.edu/linuxmint/packages/dists/nadia/restricted/source/Sources 404 Not Found
...
터미널에서 apt-get 을 이용해서 시도해보아도 마찬가지 결과였다.
구글링을 통해 해결 방법을 찾았는데, 터미널에 다음과 같이 입력함으로써 간단하게 해결 가능하다.
인터넷에서 구한 안드로이드 프로젝트를 이클립스에서 실행시켜보려고 했는데 에러 표시가 생겼다.
가장 먼저 눈에 들어오는 에러 원인은 안드로이드 라이브러리 설정이 제대로 되어있지 않을 경우 발생하는 다음의 에러이다.
The import android cannot be resolved
Android SDK 및 Build Path 등의 설정이 잘못된 것이라고 생각하여 프로젝트 설정을 변경하려고 했는데 다음과 같은 에러 메시지 팝업이 떴다.
The currently displayed page contains invalid values.
여러 번 테스트 해 본 결과
프로젝트를 선택하여 마우스 오른쪽클릭 후 나오는 팝업메뉴에서 [Properties] 창을 열었을 경우,
OR
프로젝트를 선택하여 마우스 오른쪽클릭 후 나오는 팝업메뉴에서 [Properties] -> [Android] 항목을 선택했을 경우에
창이 제대로 열리지 않고 위와 같은 메시지가 떴다.
문제를 해결하기 위해 다양한 시도를 하던 중, 이클립스를 다시 실행시켰더니 콘솔에 아래와 같은 메시지가 뜨는 것을 발견하였다.
Project has no project.properties file! Edit the project properties to set one.
[project.properties] 파일이 누락되어 있었기 때문에 발생하는 문제였다.
이 경우, 간단하게 프로젝트에 [project.properties] 파일을 추가해주면 된다.
파일에 아무런 내용이 없어도 문제되지 않는다. 찝찝하다면 다음의 예시를 참고하면 된다.
# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be checked in Version Control Systems. # # To customize properties used by the Ant build system use, # "ant.properties", and override values to adapt the script to your # project structure.
# Project target. target=android-14
프로젝트에 [project.properties] 파일을 추가하고 나면, 이제 정상적으로 [Properties] 창이 열린다.
필자의 경우, 라이브러리를 정상적으로 불러오지 못하고 있기 때문에 [Properties] 창의 [Java Build Path]에서 [Libraries] 탭에
[Unable to get system library for the project] 라는 항목이 있었는데 이것을 제거한 후에
[Properties] -> [Android] 항목을 열어서 다음 이미지와 같이 적당한 버전의 Build Target을 선택해 주었다.
* 참고로, 이 항목은 Android SDK 및 플러그인이 설치되어 있어야만 나타난다.
[Apply] 버튼을 눌러서 적용시키고 나면 [Package Explorer] 및 속성 창에서 프로젝트에 정상적으로 라이브러리가 추가된 것을 볼 수 있다.
소켓을 통해 서버에서 전송받은 .mp4 녹음 파일을 안드로이드 어플리케이션에서 재생하려고 했는데
다음과 같은 예외를 만났다.
error (1, -2147483648) java.io.IOException: Prepare failed.: status=0x1 at android.media.MediaPlayer.prepare(Native Method)
if ( player == null )
{
player = new MediaPlayer();
player.setOnCompletionListener(comlistener);
}
player.setDataSource(filePath);
player.prepare();
player.start();
그래서 위와 같이 되어 있던 소스를 다음과 같이 FileDescriptor를 이용하도록 바꾸어보았다.
(참고로, 'player' 변수의 null 검사 부분의 조건문은 이 글에서 별로 중요하지 않다. 단지 변수의 객체 타입을 파악하기 쉽도록 하기 위해 제외하지 않았다.)
if ( player == null )
{
player = new MediaPlayer();
player.setOnCompletionListener(comlistener);
}
File sourceFile = new File(filePath);
if ( sourceFile.exists() )
{
FileInputStream fs = new FileInputStream(sourceFile);
FileDescriptor fd = fs.getFD();
fs.close();
player.setDataSource(fd);
player.prepare();
player.start();
}
그러자 이번엔 다음과 같은 예외가 발생했다.
Unable to to create media player java.io.IOException: setDataSourceFD failed.: status=0x80000000 at android.media.MediaPlayer.setDataSource(Native Method)
스트림이 닫히는 순서가 문제일까 싶어서 다음과 같이 FileInputStream의 닫는 순서를 약간 변경해보았다.
if ( player == null )
{
player = new MediaPlayer();
player.setOnCompletionListener(comlistener);
}
File sourceFile = new File(filePath);
if ( sourceFile.exists() )
{
FileInputStream fs = new FileInputStream(sourceFile);
FileDescriptor fd = fs.getFD();
player.setDataSource(fd);
fs.close(); // 데이터 소스를 설정한 후 스트림을 닫았다.
player.prepare();
player.start();
}
이번엔 파일이 정상적으로 다운로드 되어있는 경우, 문제 없이 재생이 되었다.
0x80000000 예외일 경우 대부분 파일이 잘못된 경우가 많으니 파일 크기를 확인하거나, 먼저 다른 플레이어로 재생해보는 편이 좋다.
Visual Studio 2010으로 만든 C/C++ 콘솔 프로그램을 실행했을 때 자동으로 닫힌다면 (바로 닫히기 때문에 안 열린다고 생각할 수도 있다)
일반적으로 다음 두 가지 방법을 통해 해결할 수 있다.
첫 번째,
프로젝트를 생성할 때 'Win32 콘솔 응용 프로그램'이 아닌 '빈 프로젝트'로 생성했을 경우
이 때는 [프로젝트 속성->구성 속성->링커->시스템->하위 시스템] 항목을 '콘솔 (/SUBSYSTEM:CONSOLE)'로 변경해주면 된다.
두 번째,
프로그램의 맨 끝에 'getchar()'를 추가한다.
예시)
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(void)
{
srand(time(NULL));
int mynumber = 0;
cout << "what is your number: ";
cin >> mynumber;
cout << "your number is " << mynumber << endl << endl;
getchar(); // 이 부분을 빠뜨리면 작업 완료 후 콘솔이 곧바로 닫힌다.
return 0;
}