Search

'ubuntu 12.04'에 해당되는 글 3건

  1. 2012.05.20 Ubuntu 12.04 - Android NDK 설치
  2. 2012.05.18 Ubuntu 12.04 - jdk, eclipse, android sdk 설치
  3. 2012.05.17 ubuntu 12.04 - runlevel 수정

Ubuntu 12.04 - Android NDK 설치

Programming/Java 2012.05.20 22:51 Posted by 파란크리스마스

출처 : http://inmist.tistory.com/entry/%EC%8A%A4%ED%81%AC%EB%9E%A9Android-NDK-%EC%82%AC%EC%9A%A9%EB%B2%95
http://www.kkaneko.com/rinkou/js/andk.html
http://darkryu.egloos.com/m/3299369

NDK 다운로드

http://developer.android.com/sdk/ndk/index.html

NDK 설치

cd 다운로드
tar xvjof android-ndk-r8-linux-x86.tar.bz2
mv android-ndk-r8 ~/dev

NDK 환경 설정

echo 'export ANDROID_NDK_ROOT=/home/user1/dev/android-ndk-r8' | tee -a ~/.bashrc
echo 'export ANDROID_SDK_ROOT=/home/user1/dev/android-sdks' | tee -a ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_NDK_ROOT:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools' | tee -a ~/.bashrc

ToolChain 만들기

sudo ~/dev/android-ndk-r8/build/tools/make-standalone-toolchain.sh --ndk-dir=/home/user1/dev/android-ndk-r8 --platform=android-8 --install-dir=/opt/android-8-toolchain
sudo chown user1:user1 -hR /opt/android-8-toolchain

echo 'export TOOLCHAIN=/opt/android-8-toolchain' | tee -a ~/.bashrc
echo 'export PATH=$TOOLCHAIN/bin:$PATH' | tee -a ~/.bashrc
echo 'export CC=arm-linux-androideabi-gcc' | tee -a ~/.bashrc

cygwin (참조용)
./make-standalone-toolchain.sh --ndk-dir=/opt/android-ndk --platform=android-8 --install-dir=/opt/android-8-toolchain

NDK 테스트 빌드

cd ~/dev/android-ndk-r8/samples/hello-jni/jni
ndk-build

컴파일 확인

NDK Sample 만들기 

기본 Sample을 사용하는 것이라서 HelloJni 입력하고, [Next] 버튼 선택

Target SDK를 Android 2.1로 선택하고, [Next] 버튼 선택

Package Name : com.example.hellojni
Create Activity : HelloJni

HelloJni.java파일를 NDK Sample 폴더에서 복사하거나, 아래와 같이 입력 한다

package com.example.hellojni;

import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;


public class HelloJni extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        /** 
         * Create a TextView and set its content.
         * the text is retrieved by calling a native
         * function.
         */
        TextView  tv = new TextView(this);
        tv.setText( stringFromJNI() );
        setContentView(tv);
    }

    /**
     * A native method that is implemented by the
     * 'hello-jni' native library, which is packaged
     * with this application.
     */
    public native String  stringFromJNI();

    /**
     * This is another native method declaration that is *not*
     * implemented by 'hello-jni'. This is simply to show that
     * you can declare as many native methods in your Java code
     * as you want, their implementation is searched in the
     * currently loaded native libraries only the first time
     * you call them.
     *
     * Trying to call this function will result in a
     * java.lang.UnsatisfiedLinkError exception !
     */
    public native String  unimplementedStringFromJNI();

    /**
     * this is used to load the 'hello-jni' library on application
     * startup. The library has already been unpacked into
     * /data/data/com.example.HelloJni/lib/libhello-jni.so at
     * installation time by the package manager.
     */
    static {
        System.loadLibrary("hello-jni");
    }
}

jni 폴더를 만들고, Android.mk, hello-jni.c NDK Sample 폴더에서 복사하거나, 아래와 같이 입력 한다.

Android.mk 파일

# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)

hello-jni.c 파일

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
#include 
#include 

/* This is a trivial JNI example where we use a native method
 * to return a new VM String. See the corresponding Java source
 * file located at:
 *
 *   apps/samples/hello-jni/project/src/com/example/HelloJni/HelloJni.java
 */
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}

NDK 빌드

cd ~/dev/workspace/HelloJni/jni
ndk-build

HelloJni 프로젝트를 refresh 해보면 libs/armeabi/libhello-jni.so 파일이 생성 된것을 확인 할 수 있다. 

실행

신고

Ubuntu 12.04 - jdk, eclipse, android sdk 설치

OS/Linux 2012.05.18 17:14 Posted by 파란크리스마스

출처 : http://www.upubuntu.com/2012/03/how-to-install-oracle-java-7-jdk-jre.html
http://byeonely.tistory.com/19

JDK 설치

sudo add-apt-repository ppa:upubuntu-com/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

설치된 경로 확인

$ ls -al /usr/bin/java*
lrwxrwxrwx 1 root root 22  5월 18 17:17 /usr/bin/java -> /etc/alternatives/java
lrwxrwxrwx 1 root root 25  5월 18 17:17 /usr/bin/java_vm -> /etc/alternatives/java_vm
lrwxrwxrwx 1 root root 23  5월 18 17:17 /usr/bin/javac -> /etc/alternatives/javac
lrwxrwxrwx 1 root root 25  5월 18 17:17 /usr/bin/javadoc -> /etc/alternatives/javadoc
lrwxrwxrwx 1 root root 23  5월 18 17:17 /usr/bin/javah -> /etc/alternatives/javah
lrwxrwxrwx 1 root root 23  5월 18 17:17 /usr/bin/javap -> /etc/alternatives/javap
lrwxrwxrwx 1 root root 24  5월 18 17:17 /usr/bin/javaws -> /etc/alternatives/javaws

$ ls -al /etc/alternatives/java*
lrwxrwxrwx 1 root root 35  5월 18 17:17 /etc/alternatives/java -> /usr/lib/jvm/java-7-oracle/bin/java
lrwxrwxrwx 1 root root 42  5월 18 17:17 /etc/alternatives/java_vm -> /usr/lib/jvm/java-7-oracle/jre/bin/java_vm
lrwxrwxrwx 1 root root 36  5월 18 17:17 /etc/alternatives/javac -> /usr/lib/jvm/java-7-oracle/bin/javac
lrwxrwxrwx 1 root root 38  5월 18 17:17 /etc/alternatives/javadoc -> /usr/lib/jvm/java-7-oracle/bin/javadoc
lrwxrwxrwx 1 root root 36  5월 18 17:17 /etc/alternatives/javah -> /usr/lib/jvm/java-7-oracle/bin/javah
lrwxrwxrwx 1 root root 36  5월 18 17:17 /etc/alternatives/javap -> /usr/lib/jvm/java-7-oracle/bin/javap
lrwxrwxrwx 1 root root 37  5월 18 17:17 /etc/alternatives/javaws -> /usr/lib/jvm/java-7-oracle/bin/javaws

이클립스 설치

cd 다운로드
tar xvfx eclipse-java-indigo-SR2-linux-gtk.tar.gz
mkdir ~/dev
mv eclipse ~/dev
~/dev/eclipse/eclipse

ADT Plugin 설치

메뉴 [Help] -> [Install New Software...] 선택

Name : ADT Plugin (임의로 편집가능)
Location : https://dl-ssl.google.com/android/eclipse/

[Developer Tools] 선택 하고, [Next] 버튼 선택

[Next] 버튼 선택

라이센스 확인하고, [Finish] 버튼 선택

설치 진행 과정

설치 완료후 eclipse 제시작 

Android SDK 설치 

이전에는 SDK을 따로 받아서 설치 했지만,
최신 버전의 ADT Plugin을 설치하면 위에서 eclipse를 제시작 하면 아래와 같이 Android SDK를 다운 받아서 설치됨

Android SDK 다운 받아서 설치한 경로를 설정하고, [Next] 버튼을 선택

Google에 사용 통계 보내기

라이센스 확인하고, [Install] 버튼 선택

다운로드및 설치 과정

메뉴 [Help] -> [Android SDK Manager] 선택

설치하고 싶은 Package 선택하고, [Install] 버튼 선택

라이센스 수용하고, [Install] 버튼 선택

Android 애뮬레이터 생성

[New] 버튼 선택

아래와 같이 채우고 [Create AVD] 버튼 선택

Android 애뮬레이터 실행

실행하고 싶은 AVD Name을 선택하고 [Start...] 버튼 선택

[Launch] 버튼 선택

Android 애뮬레이터 실행 확인


신고

ubuntu 12.04 - runlevel 수정

OS/Linux 2012.05.17 18:36 Posted by 파란크리스마스

출처 : http://blog.naver.com/PostView.nhn?blogId=devplayer&logNo=114812735&parentCategoryNo=8&viewDate=&currentPage=1&listtype=0

[데비안/우분투 런레벨 구조]
* 0 - Halt
* 1 - Single
* 2 - Full multi-user with display manager (GUI) 현재 기본
* 3 - Full multi-user with display manager (GUI)
* 4 - Full multi-user with display manager (GUI)
* 5 - Full multi-user with display manager (GUI)
* 6 - Reboot

vi /etc/init/rc-sysinit.conf 파일 수정

env DEFAULT_RUNLEVEL=2  <-- 이부분을 수정

init6 재부팅

신고


 

티스토리 툴바