페이지

2014년 9월 26일 금요일

언리얼 4 자바 라이브러리 추가하는 방법

언리얼 4 자바 라이브러리 추가하는 방법

참조 https://forums.unrealengine.com/showthread.php?3504-Android-Java-Libraries-in-UE4-Game-(OUYA-SDK-Google-Play-Game-Services-etc-)


I just put all jar, libraries under C:\Program Files\Unreal Engine\4.1\Engine\Build\Android\Java

Full directory structure:
Engine\Build\Android\Java\jni\libmylib.so
Engine\Build\Android\Java\libs\mylib.jar
Engine\Build\Android\Java\libs\mylib.jar.properties (if you have)

[EDIT]
Also modified jni\Android.mk
-------------------
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := UE4
LOCAL_SRC_FILES := libUE4.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := mylib
LOCAL_SRC_FILES := libmylib.so
include $(PREBUILT_SHARED_LIBRARY)
-------------------
[/EDIT]

So they are always copied to Intermediate directory during build time.
I also edited GameActivity.java there to load my library.

I'm afraid this is not a recommended way because I edited default installation.
Please let me know better and recommended way.





NDK C++
https://github.com/aajiwani/EasyNDK-for-cocos2dx

2014년 9월 11일 목요일

Mac SVNX 서버 경로 변경 방법 (svn relocate)


작업환경 : OSX 10.8.5
Xcode 5.1.1


맥에서 SVNX 를 사용하다가 SVN서버 IP가 변경되어 해당 SVN경로를 바꿔줘야할 문제가 발생하였습니다. SVNX 에서 아무리 찾아봐도 해당 기능이 없어.맥 순수 SVN 을 사용하려했지만 OSX 10.8.5 버젼에는 SVN 이 설치되어있지 않아 여러 방면으로 찾아본 결과 Xcode 에서 SVN을 다운로드,설치를 할 수 있다하여 해결방법을 정리해봅니다.


Xcode - Preferences - Downloads - Command Line Tools 








터미널에서 svn 디렉토리변경 
- 해당폴더로 이동하여 - XXX.XXX.X.44(이전경로) YYY.YYY.YY.24(변경할경로))
(대소문자 구분합니다!!)

$svn switch --username yourusername --password yourpassword --relocate https://XXX.XXX.X.44/svn/BatyyyyyyVN100/trunk https://YYY.YYY.YY.24/svn/Batyyyyyyy00/trunk






참고로 윈도우 거북이SVN 은 relocate 이라는 것으로 디렉토리 변경가능합니다.

2014년 9월 1일 월요일

Exponential Backoff 자바(안드로이드)소스

import com.google.api.client.http.HttpResponseException;

import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;

import java.io.IOException;
import java.util.Random;
// ...

public class MyClass {
  // ...

  /**
    * Print a file's metadata with exponential backoff.
    *
    * @param service Drive API service instance.
    * @param fileId ID of the file to print metadata for.
    * @return The file's metadata.
    */
  static File printFileWithExponentialBackoff(Drive service, String fileId) throws IOException, InterruptedException {
    Random randomGenerator = new Random();
    for (int n = 0; n < 5; ++n) {
      try {
        File file = service.files().get(fileId).execute();

        System.out.println("Title: " + file.getTitle());
        System.out.println("Description: " + file.getDescription());
        System.out.println("MIME type: " + file.getMimeType());
        return file;
      } catch (GoogleJsonResponseException e) {
        if (e.getCode() == 403
            && (e.getErrors().get(0).getReason().equals("rateLimitExceeded")
                || e.getErrors().get(0).getReason().equals("userRateLimitExceeded"))) {
          // Apply exponential backoff.
          Thread.sleep((1 << n) * 1000 + randomGenerator.nextInt(1001));
        } else {
          // Other error, re-throw.
          throw e;
        }
      }
    }
    System.err.println("There has been an error, the request never succeeded.");
    return null;
  }

  // ...
}
https://developers.google.com/drive/web/handle-errors#implementing_exponential_backoff
public enum Results {
    SUCCESS, 
    NOT_READY, 
    THROTTLED, 
    SERVER_ERROR
}

/*
 * Performs an asynchronous operation, then polls for the result of the
 * operation using an incremental delay.
 */
public static void doOperationAndWaitForResult() {

    try {
        // Do some asynchronous operation.
        long token = asyncOperation();

        int retries = 0;
        boolean retry = false;

        do {
            long waitTime = Math.min(getWaitTimeExp(retries), MAX_WAIT_INTERVAL);

            System.out.print(waitTime + "\n");

            // Wait for the result.
            Thread.sleep(waitTime);

            // Get the result of the asynchronous operation.
            Results result = getAsyncOperationResult(token);

            if (Results.SUCCESS == result) {
                retry = false;
            } else if (Results.NOT_READY == result) {
                retry = true;
            } else if (Results.THROTTLED == result) {
                retry = true;
            } else if (Results.SERVER_ERROR == result) {
                retry = true;
            }
            else {
                // Some other error occurred, so stop calling the API.
                retry = false;
            }

        } while (retry && (retries++ < MAX_RETRIES));
    }

    catch (Exception ex) {
    }
}

/*
 * Returns the next wait interval, in milliseconds, using an exponential
 * backoff algorithm.
 */
public static long getWaitTimeExp(int retryCount) {

    long waitTime = ((long) Math.pow(2, retryCount) * 100L);

    return waitTime;
}


http://docs.aws.amazon.com/general/latest/gr/api-retries.html