Blog

반응형

01

* 개발자 모드 활성화 하기

 1. 먼저 "설정 - 휴대전화 정보"로 들어갑니다.

 2. "MIUI 버전"을 7번 눌러 주면, 개발자 모드가 활성화 됩니다.



01234

* USB 디버깅 및 설치 활성화 하기

 1. "설정 - 추가 설정-개발자 옵션"으로 들어갑니다.

 2. 상단에 있는 "개발자 옵션"은 활성화가 되어 있어야 합니다.

 3. "USB 디버깅", "USB로 설치", "USB 디버깅(보안 설정)"을 차례로 활성화 시켜줍니다.

4. "MIUI 최적화 켜기"를 끄고 재부팅을 하면 됩니다.

- 이를 끄지 않을 경우 아래 오류와 같이 USB로 앱 설치가 되지 않는 문제가 생깁니다.

- 아래 오류는 react native 에서 빌드한 오류이며, Android Studio에서도 동일한 오류가 발생합니다.


Execution failed for task ':app:installDebug'.

> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session




반응형

'Programing > Android' 카테고리의 다른 글

구글 플레이스토어 계정 등록  (0) 2018.01.15

반응형

한동안 손을 안 댄 프로젝트를 수정할 일이 생겼다.

수정을 다하고 빌드를 해서 실행을 할려고 하니 아래와 같은 에러가 발생 하였다.


JS server already running.

Running /Users/asata/Library/Android/sdk/platform-tools/adb -s LGF460L17e67912 reverse tcp:8081 tcp:8081

Building and installing the app on the device (cd android && ./gradlew installDebug...

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.

please apply google-services plugin at the bottom of the build file.


FAILURE: Build failed with an exception.


* What went wrong:

A problem occurred configuring project ':app'.

> A problem occurred configuring project ':react-native-picker'.

   > Could not resolve all dependencies for configuration ':react-native-picker:_debugCompile'.

      > Could not find com.android.support:appcompat-v7:25.3.1.

        Searched in the following locations:

            file:/Users/asata/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom

            file:/Users/asata/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

            https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom

            https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

        Required by:

            MyGumiMap:react-native-picker:unspecified > com.facebook.react:react-native:0.42.3-atlassian-1

      > Could not find com.android.support:recyclerview-v7:25.3.1.

        Searched in the following locations:

            file:/Users/asata/.m2/repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.pom

            file:/Users/asata/.m2/repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.jar

            https://jcenter.bintray.com/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.pom

            https://jcenter.bintray.com/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.jar

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.pom

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.jar

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.pom

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.jar

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.pom

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/android/support/recyclerview-v7/25.3.1/recyclerview-v7-25.3.1.jar

        Required by:

            MyGumiMap:react-native-picker:unspecified > com.facebook.react:react-native:0.42.3-atlassian-1

      > Could not find com.atlassian.mobile.video:okhttp-ws-compat:3.7.0-atlassian1.

        Searched in the following locations:

            file:/Users/asata/.m2/repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.pom

            file:/Users/asata/.m2/repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.jar

            https://jcenter.bintray.com/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.pom

            https://jcenter.bintray.com/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.jar

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.pom

            file:/Users/asata/Project/ReactNative/MyGumiMap/node_modules/react-native/android/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.jar

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.pom

            file:/Users/asata/Library/Android/sdk/extras/android/m2repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.jar

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.pom

            file:/Users/asata/Library/Android/sdk/extras/google/m2repository/com/atlassian/mobile/video/okhttp-ws-compat/3.7.0-atlassian1/okhttp-ws-compat-3.7.0-atlassian1.jar

        Required by:

            MyGumiMap:react-native-picker:unspecified > com.facebook.react:react-native:0.42.3-atlassian-1


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


BUILD FAILED


Total time: 11.786 secs

Could not install the app on the device, read the error above for details.

Make sure you have an Android emulator running or a device connected and have

set up your Android development environment:

https://facebook.github.io/react-native/docs/android-setup.html


오류가 났다는 노드 모듈에도 별 문제가 없는데도 이런 에러가 발생한다.

react native 버전을 올려도 별 차이가 없었고,

찾다찾다보니 android/build.gradle  파일을 수정을 하면 된다고 한다.


allprojects {

    configurations.all {

        resolutionStrategy {

            eachDependency { DependencyResolveDetails details ->

                if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {

                    details.useVersion "0.36.0" // Your real React Native version here

                }

            }

        }

    }

}


굵게 표시한 부분에 현재 react native 버전을 기재를 해 주고

다시 빌드를 진행을 하면 정상적으로 설치되는 것을 확인 할 수 있다.

반응형

반응형

* React-Native 개발 도중 npm에서 필요한 모듈을 설치 중 pod 하여서 빌드를 하는데 오류가 발생


ld: framework not found React 

clang: error: linker command failed with exit code 1 (use -v to see invocation)




0. xCode에서 오류가 발생한 프로젝트 열기

 - Pod 사용시, ~~~.xcworkspace를 열기

1. 프로젝트 설정 화면을 선택

2. 수정할 Targets 선택

3. Build Settings 선택

4. Other Linker Flags 내용 수정

 -lc++, -ObjC 를 추가

반응형

반응형

Android SDK를 업데이트를 한 뒤 아래와 같은 에러가 발생 할 수 있습니다.


저는 Google Play Service를 업데이트를 하다보니 발생하였네요;


:app:preDexDebug

:app:dexDebug

Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:

Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzqf;

Unknown source file : at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

Unknown source file : at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)

Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)

Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)

Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)

Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)

Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)

Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:277)

Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:245)

Unknown source file : at com.android.dx.command.Main.main(Main.java:106)


:app:dexDebug FAILED


FAILURE: Build failed with an exception.


* What went wrong:

Execution failed for task ':app:dexDebug'.

> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


BUILD FAILED


동일한 이름의 라이브러리를 중복으로 불러와 발생하는 문제입니다. 


저는 com.google.firebase:firebase-core를 사용하는 node module이 여러 개가 있었는데, 각각 필요한 버전이 달라서 오류가 발생하였습니다.


해결 방법은 문제가 발생하는 node module를 지우고 다시 설치를 하도록 합니다.


rnpm unlink 

npm cache clean

npm install

rnpm link


이 때 각 node module의 android/build.gradle 에서 dependencies 버전을 수정을 해 주셔야 합니다.


가급적 동일한 버전을 사용하도록 수정을 하시고 다시 빌드를 진행을 하면 됩니다.


반응형

반응형

react-native init를 하여 프로젝트를 초기화를 할 경우 항상 최신 버전으로 프로젝트가 세팅이 된다.


하지만 구 버전으로 프로젝트를 초기화를 해야 할 경우 아래 방법을 이용한다.


먼저 아래 package를 설치하도록 한다.


npm i -g rninit


설치가 완료가 되면 바로 사용이 가능하다.


Project Name에 원하는 이름을 넣고 실행하면 원하는 버전으로 react native project가 세팅된다.


rninit init [Project Name] --source react-native@0.28


반응형

반응형

React Native 에서 GIF 이미지를 출력할때 일반 이미지 출력과 동일하게 Image를 이용하여 출력을 하면 됩니다.


<Image source={require('이미지 경로(local)')} />


<Image source={{url : '이미지 경로(web)'}} />


이렇게 넣었는데 화면에 공간만 차지하고 이미지가 나오지 않는 문제가 있습니다.


이 때 android/app/src/build.gradle 파일에 아래 내용을 추가 해주어야 합니다.


dependencies {

..................


compile "com.facebook.fresco:animated-gif:0.10.0"


..................

}



그리고 다시 build를 하면 정상적으로 출력되는 이미지를 확인 할 수 있습니다.



반응형

반응형

React Native에서 Android에서 Wifi AP를 검색하고자 아래 모듈을 활용하였습니다.


https://github.com/devstepbcn/react-native-android-wifi


설치 방법 및 기타 사용법은 위 페이지에서 확인을 하면 되는데,


안드로이드 6.0부터 현재 AP List를 가져오도록 했는데도 불구하고 아무것도 나오지 않는 경우가 있는데


AndroidManifest.xml에 아래 항목을 추가를 합니다.


<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


둘 중 하나만 넣어도 된다고 함


그래도 검색 결과를 가져오지 못하는데, 별도로 권한을 요청해서 승인을 받도록 해야 합니다.


앱 권한 확인 및 요청하는 부분은 https://github.com/lucasferreira/react-native-android-permissions를 이용하였습니다.


requestPermission("android.permission.ACCESS_COARSE_LOCATION").then((result) => {

console.log("Granted!", result);

}, (result) => {

console.log("Not Granted!");

console.log(result);

});


앱 실행시 권한을 요청하고 이를 승인 받도록 합니다.


해당 부분을 승인하지 않을 경우 Wifi 검색 결과를 가져오지 못하고, 승인을 해야 Wifi 검색 결과를 가져올 수 있는것으로 파악되고 있습니다.


* 참고 : http://stackoverflow.com/questions/32151603/scan-results-available-action-return-empty-list-in-android-6-0

반응형

반응형

1. 아두이노에 연결하기

 아두이노에서 IR 송수신 센서를 이용하여 리모컨 제어를 할 수 있습니다. IR 수신 센서는 TSOP38238(Datasheet 보기)를 이용 하였고, IR 송신 센서는 IR333C(Datasheet 보기)를 사용 하였습니다. 연결은 각 센서 데이터시트를 참고하여 연결을 하면 됩니다. 아래 그림에서 왼쪽 검은색의 센서가 IR 수신 센서이고, 오른쪽 투명한 센서가 IR 송신 센서입니다.




2. IR 라이브러리 설치하기

 먼저 IR 관련 처리를 하기 위해 IR 관련 라이브러리를 설치를 해야 합니다. 물론 기본적으로 존재는 하지만 송신이 되지 않고, 수신만 되는 상태라 아래 주소에서 받아서 라이브러리 폴더에 넣어 주시면 됩니다.

 

IR Library Download : https://github.com/z3t0/Arduino-IRremote


받으신 후에 기존에 있던 IRremote폴더 내에 있는 파일들은 모두 지우고 넣어 주셔야 합니다. 그냥 새로 추가할 경우 충돌이 일어나 제대로 동작하지 않을 수 있습니다. 



3. 리모컨 송수신 테스트

#include <IRremote.h> // Include the IRremote library


/* Connect the output of the IR receiver diode to pin 11. */

int RECV_PIN = 11;

/* Initialize the irrecv part of the IRremote  library */

IRrecv irrecv(RECV_PIN);

decode_results results; // This will store our IR received codes


IRsend irsend; // Enables IR transmit on pin 3


/* Storage variables for the received IR code: */

unsigned int irLen = 0; // The length of the code

unsigned int irBuffer[RAWBUF]; // Storage for raw (UNKNOWN) codes

int codeType; // The type of code (NEC, SONY, UNKNOWN, etc.)

unsigned int codeValue; // The value of a known code

boolean codeReceived = false; // A boolean to keep track of if a code was received


const int buttonPin = 12; // Button pin. Pulled up. Triggered when connected to ground.


// setup() initializes serial and the Infrared receiver.

void setup() {

  Serial.begin(9600);

  irrecv.enableIRIn(); // Start the receiver

  pinMode(buttonPin, INPUT_PULLUP);

}


// loop() checks for either a button press or a received IR code.

void loop() {

  if (irrecv.decode(&results)) {

    updateIRReceive(); // Sort out the received code

    codeReceived = true; // Enables code transmit on button press

    irrecv.resume(); // re-enable receive

  }


  if ((digitalRead(buttonPin) == LOW) && (codeReceived == true)) {

    sendCode(); // Sends out our code. (See bottom of sketch).

    irrecv.enableIRIn(); // Re-enable receiver

    codeReceived = false;

  }

}


void updateIRReceive() {

  codeType = results.decode_type;

  irLen = results.rawlen;

  codeValue = results.value;


  Serial.println(irLen);

  Serial.print("receive code type : 0x");

  Serial.println(results.decode_type, HEX);

  Serial.print("receive code value : 0x");

  Serial.println(results.value, HEX);

  

  if (codeType == UNKNOWN) {

    // We need to convert from ticks to microseconds

    for (int i = 1; i <= irLen; i++) {

      if (i % 2) {

        // Mark

        irBuffer[i-1] = results.rawbuf[i]*USECPERTICK - MARK_EXCESS;

        Serial.print(" m");

      } else {

        // Space

        irBuffer[i-1] = results.rawbuf[i]*USECPERTICK + MARK_EXCESS;

        Serial.print(" s");

      }

      Serial.print(irBuffer[i-1], DEC);

    }

    Serial.println();

  } else {

    if (codeType == NEC) {

      Serial.print("Received NEC: ");

      if (results.value == REPEAT) {

        // Don't record a NEC repeat value as that's useless.

        Serial.println("repeat; ignoring.");

        return;  

      }

    } else if (codeType == SAMSUNG) {

      Serial.print("Received SAMSUNG: ");

    } else if (codeType == RC5) {

      Serial.print("Received RC5: ");

    } else if (codeType == RC6) {

      Serial.print("Received RC6: ");

    } else {

      Serial.print("Unexpected codeType ");

      Serial.print(codeType, DEC);

      Serial.println("");

    }

    Serial.println(results.value, HEX);

    codeValue = results.value;

    irLen = results.bits;

    

    Serial.print("code type : ");

    Serial.println(codeType);

    Serial.print("code value : ");

    Serial.println(codeValue);

    Serial.print("code value hex : 0x");

    Serial.println(codeValue, HEX);

    Serial.print("ir length : ");

    Serial.println(irLen);

    Serial.println();

  }

}


void sendCode() {

  if (codeType == NEC) {

      //irsend.sendNEC(codeValue, irLen);

      irsend.sendNEC(0x20DF22DD, irLen);

    

    Serial.print("Sent NEC 0x");

    Serial.println(codeValue, HEX);

    Serial.println();

  }  else if (codeType == SAMSUNG)  {

      irsend.sendSAMSUNG(codeValue, irLen);

    

    Serial.print("Sent NEC 0x");

    Serial.println(0xEACEFB13, HEX);

    Serial.println();

  } else if (codeType == UNKNOWN /* i.e. raw */) {

    // Assume 38 KHz

    irsend.sendRaw(irBuffer, irLen, 38);

    Serial.println("Sent raw");

    for (int i = 0; i < irLen; i++) {

      Serial.print(irBuffer[i]);

      Serial.print(" ");

    }

    Serial.println();

    Serial.println(codeValue, HEX);

  }

}

 위 코드는 리모컨으로부터 IR 수신을 받은 값을 사용자가 아두이노에 연결된 버튼을 누를 경우 수신된 값을 전송해 주도록 작성된 코드입니다. 위 회로도에서 버튼은 포함되지 않았기에 추가를 해 주셔야 합니다. 

 정상적으로 수신이 동작이 됩니다. 다만, 송신시 수신된 codeValue값을 그대로 보냈음에도 불구하고 제대로 전송이 되지 않는 문제가 있어서 Hex값을 보내도록 수정을 하였습니다. 리모컨 Hex값은 위와 같은 회로로 눌러가며 입력을 받아도 되지만, 아래 사이트에 있을 경우 그 값을 그대로 이용을 하여도 무방할 것 같습니다. 찾으실 때 제품명이 아닌 리모컨에 기재된 리모컨 제품번호를 검색 하셔야 합니다. 물론 모든 리모컨 값이 있는게 아니라 없을 경우 일일이 입력하여야 합니다.


http://lirc.sourceforge.net/remotes/



4. 테스트 영상 보기

 먼저 리모컨 버튼을 누른 후 입력값 확인 후 아두이노에서 버튼을 눌러 리모컨 값을 전달하는 영상입니다.


반응형

반응형

SCP 아이디@주소:원격지경로 다운로드경로


scp pi@192.168.0.68:/home/pi/hs_err.log ~/error.log

반응형

반응형

안드로이드에서 소프트키를 보여주지 않아야 할 경우가 있을 때 아래 코드로 파일을 하나 생성 해 줍니다.


using UnityEngine;

public class DisableSystemUI {
	#if UNITY_ANDROID
	static AndroidJavaObject activityInstance;
	static AndroidJavaObject windowInstance;
	static AndroidJavaObject viewInstance;
	
	const int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2;
	const int SYSTEM_UI_FLAG_LAYOUT_STABLE = 256;
	const int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512;
	const int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024;
	const int SYSTEM_UI_FLAG_IMMERSIVE = 2048;
	const int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 4096;
	const int SYSTEM_UI_FLAG_FULLSCREEN = 4;
	
	public delegate void RunPtr();
	
	public static void Run() {
		if (viewInstance != null) {
			viewInstance.Call("setSystemUiVisibility", 
			                  SYSTEM_UI_FLAG_LAYOUT_STABLE
			                  | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
			                  | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
			                  | SYSTEM_UI_FLAG_HIDE_NAVIGATION
			                  | SYSTEM_UI_FLAG_FULLSCREEN
			                  | SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
		}
		
	}
	#endif  

	public static void DisableNavUI() {
		if (Application.platform != RuntimePlatform.Android)
			return;
		#if UNITY_ANDROID
		using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
			activityInstance = unityPlayerClass.GetStatic("currentActivity");
			windowInstance = activityInstance.Call("getWindow");
			viewInstance = windowInstance.Call("getDecorView");
			
			AndroidJavaRunnable RunThis;
			RunThis = new AndroidJavaRunnable(new RunPtr(Run));
			activityInstance.Call("runOnUiThread", RunThis);
		}
		#endif
	}
}


그리고 처음 호출하는 부분에서 

DisableSystemUI.DisableNavUI();

를 불러주면 소프트키를 숨겨줍니다.

해당 폰에서 소프트키를 다시 볼려면 화면 상단을 아래로 스와이프를 해 주면 됩니다.

반응형