지식메모

반응형


Android API 23 에서 바뀐 부분이 있나보다

코드에서 getDrawable 부분에서

  'getDrawable(int)' is deprecated more...

이게 발생했다.

수정 방법은 다음과 같았다

기존 코드

img_season = (BitmapDrawable)context.getResources().getDrawable(getMap().get(str_season));


수정 코드

img_season = (BitmapDrawable) ContextCompat.getDrawable(context, getMap().get(str_season));



ContextCompat 를 추가하고 나서 아래 사진처럼 뜨는데 Alt + Enter를 해주면 정상적으로 적용된다.




반응형
반응형



서명된 apk를 생성하고 기존 마켓버전에서 업데이트 되나 설치해보는데 자꾸 설치가 실패했다.


versionCode, versionName 모두 +1씩 해주었는데도 말이다.


알고보니 안드로이드 스튜디오는 AndroidManifest.xml 에서 버전코드와 네임을 관리하는게 아니었다..



기존 이클립스에서 AndroidManifest.xml 을 살펴보면



이렇게 되어있는데 안드로이드 스튜디오는 build.gradle 에서 변경해주어야 한다.


들어가보니 프로젝트를 처음 생성해서 versionCode 와 versionName이 모두 1로 되어있었다.




그래서 AndroidManifest.xml 에 있는 버전보다 +1 변경해주었다




그리고 다시 apk를 생성하고 업데이트 설치를 해보니 정상적으로 되었다!






반응형
반응형



Android Studio 에서 서명된 apk를 생성하려고 했더니 이런 에러가 떴다.


Error:(24) Error: "none" is not translated in "en" [MissingTranslation]

(*어느 언어냐에 따라 "en" "vi" "th" 등등 다르게 나타남)


보니까 다국어에서 문제가 생겼는데 프로젝트는 이클립스에서는 문제가 없었던 거였다.



그래서 찾아보니 안드로이드 스튜디오에서는 string.xml 이 모두 같아야 한다고 한다.


즉 위 에러를 보면


<string name="none">none</string>


이 코드가 "vi"에서 번역되지 않았다고 뜬다. 베트남어에서 none 항목이 없다는 것이다.


현재 다국어 구조가



이렇게 한국,영어,대만,베트남 4개로 되어있는데


베트남의 string.xml 에만


<string name="none">none</string>


이 항목이 번역되지 않았다는 것이다.



이 문제를 해결하려면


values-vi 의 strings.xml 로 들어가


<string name="none">none</string>


이걸 추가해준 뒤 다시 서명된 apk를 생성하면 해결된다.



반응형
반응형

 

Eclipse 에서 maven 프로젝트를 불러온 후 이상한 에러가 발생됐다.

바로 pom.xml 에서 문제 발생

코드 내부에는 다음과 같은 부분에서 에러발생

에러메시지는 다음과 같았다

DescriptionResourcePathLocationType

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)pom.xml/CloudAppAutomationline 99Maven Project Build Lifecycle Mapping Problem

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile)pom.xml/CloudAppAutomationline 99Maven Project Build Lifecycle Mapping Problem

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.6:resources (execution: default-resources, phase: process-resources)pom.xml/CloudAppAutomationline 8Maven Project Build Lifecycle Mapping Problem

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.6:testResources (execution: default-testResources, phase: process-test-resources)pom.xml/CloudAppAutomationline 8Maven Project Build Lifecycle Mapping Problem

 

근데 프로젝트는 이상없이 돌아가긴 했지만 거슬리는 건 가차없이 없애버려야 한다.

구글링해서 있는데로 시도 해봤지만 fail...

pom.xml에 무슨 디펜던시, 플러그인 코드를 삽입하라고 하는데 난 되지 않았다.

왜 항상 다수의 해결책은 나에게 해당되지 않는 것인가

 혹시 몰라 첨부.. 이전에 eclipse marketplace 에서 maven intergration for eclipse 를 설치 했었습니다.

 

그래도 해결되지 않아 다음 방법을 수행..

그러다 이분의 해결책을 발견 시도해보았다.

 

http://stackoverflow.com/questions/11448298/plugin-execution-not-covered-by-lifecycle-configuration-maven-error

 

설치된 뭔가가 잘못된 것 같았다.

 

우선 help > install new software 로 진입 후 

이 주소를 붙여넣는다.

http://dist.springsource.org/release/GRECLIPSE/e4.2/

 

그럼 아래 사진처럼 뜨는데 거기서 m2e 라고 된걸 체크 후 설치 수행

 

반응형

 

 

설치 ㄱㄱ

 

 

 

 

설치 진행 중 나는 TestNG 때문에 이런 창이 떴는데 어쨌든 그냥 있는 그대로 계속 킵고잉

 

 

 

 

설치가 끝난 후 이클립스 재시작을 했더니만 아래와 같은 화면이 발생

상단 Overview 빨간 문구를 클릭하니 다음과 같은 메시지 발생

그래서 Discover new m2e connectors 를 클릭했다.

 

 

그랬더니 이런 화면이 뜬다 

난 아무것도 몰라요 그냥 피니쉬

 

 

 

그럼 이런게 뜨는데 그냥 별 탈 없이 넥스트

 

그럼 설치가 좀 걸리긴 한데 설치 완료 후 이클립스 재시작 후

프로젝트를 다시 보니 

에러가 사라졌다!!!!!!

 

 

바람직한 현상이다.

 

물론 이번 문제는 다수의 문제가 아닌 소수의 문제일 수 있으므로 100% 해결책이라 말할 수 없다..

 

어쨌든 해결됐으면 장땡

 

반응형
반응형



프로젝트 내에 libs 폴더를 만들고 안에 라이브러리 파일은 넣은 후 우클릭

Add as Library 클릭





나오는 창에서 app을 선택 후 ok 하면 추가된다.





반응형
반응형


고난의 연속.. Eclipse에서 Android Studio로 넘어오려고 애쓰는데 스트레스만 받고 있었다.

이클립스에 있던 프로젝트를 import 해도 계속 에러에러에러... 

결국 그냥 안드로이드 스튜디오에서 새 프로젝트만들고 거기다 붙여넣어 보는 식으로 어찌어찌 해결하다가 갑자기 왠 아웃오브메모리???


대략 이런 에러가 발생


Error:UNEXPECTED TOP-LEVEL ERROR:


Error:java.lang.OutOfMemoryError: GC overhead limit exceeded


:app:transformClassesWithDexForDebug FAILED


Error:Execution failed for task ':app:transformClassesWithDexForDebug'.


> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 3


버틸 수가 없었다. 내 한계에 부딪히는듯 했다.

찾아보니 build.gradle 파일에서 defaultConfig 에 multiDexEnabled true를 추가해주래서 했는데 해결이 되지 않았고

질문 게시판에 올려보았는다 친철한 분께서 다음과 같은 제안을 해주셨다.

build.gradle 파일에 android 내부에 다음 코드를 넣어보세요


dexOptions {

  jumboMode true

  javaMaxHeapSize "4g"



바로 적용해보았더니 오오오오 아웃오브메모리 에러가 사라졌다.

감동적인 순간이었다. 앱이 실행이 되다니..

아래와 같이 적용했다.


 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
apply plugin: 'com.android.application'
 
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
 
    defaultConfig {
        applicationId "패키지네임"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
//dexOptions 추가
    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
}
cs




물론 이게 100% 해결책이 아닐 수 있다. 언제나 그랬듯이 남의 해결책이 나의 해결책이 되진 않기 때문에..


여기까지 오기에 많은 에러가 있었는데 그 에러들이 어떻게 해결되었는지는 모르고 어찌어찌 넘어왔다.

 

그 에러들 해결방법도 다시 찾아봐야겠다.





반응형

Android Studio auto import

2016. 6. 1. 18:18
반응형

http://answerofgod.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%8A%A4%ED%8A%9C%EB%94%94%EC%98%A4-Auto-import

반응형
반응형




구현해보려고 한 swipe 영역



위 움짤 처럼 폴더 별 우측 슬라이드 메뉴를 제어해보려고 함






우선 우측 슬라이드 메뉴 버튼의 요소를 파악해봄


위치를 파악할 수 있는 정보가 index정보 밖에 없는 걸로 판단

index로 특정 위치를 지정해보기로 함



그래서 xpath로 버튼 위치를 가져와봄


String xpath = "//android.widget.RelativeLayout[contains(@resource-id,'item') and @index='0']" 

 + "//android.widget.ImageView[contains(@resource-id,'open_edit_menu')]";


부가설명


RelativeLayout의 0번째 idex내

//android.widget.RelativeLayout[contains(@resource-id,'item') and @index='0']


open_edit_menu id를 가진 ImageView 버튼을 가져옴

//android.widget.ImageView[contains(@resource-id,'open_edit_menu')]




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    //  특정위치에 있는 요소의 xpath 값
        String xpath = "//android.widget.RelativeLayout[contains(@resource-id,'item') and @index='0']"
                + "//android.widget.ImageView[contains(@resource-id,'open_edit_menu')]";
        
        //해당 위치의 슬라이드 메뉴 왼쪽으로 swipe
        driver.swipeSlide(xpath);
 
    /**
     * 슬라이드 메뉴 swipe 하기
     * @param xpath : 특정 슬라이드 메뉴의 위치 xpath
     * @throws Exception - Exception
     */
    public void swipeSlide (String xpath) throws Exception {
        
        WebElement webElement = driver.findElement(By.xpath(xpath));

        int starty = (int) (webElement.getLocation().getY());
        int startx = (int) (webElement.getLocation().getX());

        webElement.click();
        
        driver.swipe(startx+(int)(width*0.1), starty, startx-(int)(width*0.15), starty, 0);
    }
cs




이제 xpath 값을 swipeSlide 메소드에 넣어 버튼으르 클릭한 뒤

버튼의 위치를 추출해낸다.


        int starty = (int) (webElement.getLocation().getY());
        int startx = (int) (webElement.getLocation().getX());


 y와 x좌표를 얻어온뒤 swipe 메소드에 값을 넣어줌

swipe 메소드는 다음과 같이 되어있다


void io.appium.java_client.AppiumDriver.swipe(int startx, int starty, int endx, int endy, int duration)

우측 startx+(int)(width*0.1) 지점에서 좌측 startx-(int)(width*0.15) 까지 swipe

(*width는 동작 초기에 폰 가로사이즈를 가져온 값)


반대 방향으로 swipe하고자 한다면 이 두값을 바꿔주면 된다.


동작시켜보면


swipe가 된다.


만약 xpath에서


//android.widget.RelativeLayout[contains(@resource-id,'item') and @index='2']

로 바꿔주면 3번째 슬라이드 메뉴가 오픈된다.


index 2 일 때 동작



3번째 폴더가 열리게 된다.




반응형

+ Recent posts