T01.01-Exercise-CreateLayout 프로젝트를 열면

맨 아래 TODO 탭을 클릭해 보면 다음과 같이 보인다.

먼저

layout > activity_main.xml 을 수정한다

TODO(1)부터 순서대로 고쳐가면 되기 때문에


exercise code

solution code 

 

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<!--TODO (1) Change the ConstraintLayout to a FrameLayout.
Note that you don't need to use the fully qualified name for FrameLayout. Replace
"android.support.constraint.ConstraintLayout" with "FrameLayout"-->
<!--TODO (6) Remove the line that declares the id, we don't need it-->
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!--TODO (2) Remove all attributes with the word constraint in them-->
<!--TODO (3) Remove the default text-->
<!--TODO (4) Give the TextView 16dp of padding-->
<!--TODO (5) Set the text size to 20sp-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="@+id/activity_main"
app:layout_constraintLeft_toLeftOf="@+id/activity_main"
app:layout_constraintRight_toRightOf="@+id/activity_main"
app:layout_constraintTop_toTopOf="@+id/activity_main" />

</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<!--COMPLETED (1) Change the ConstraintLayout to a FrameLayout-->
<!--COMPLETED (6) Remove the line that declares the id, we don't need it-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="match_parent">

<!--COMPLETED (2) Remove all attributes with the word constraint in them-->
<!--COMPLETED (3) Remove the default text-->
<!--COMPLETED (4) Give the TextView 16dp of padding-->
<!--COMPLETED (5) Set the text size to 20sp-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="20sp" />
</FrameLayout>

 

주석으로 된 TODO를 완료하면 COMPLETED로 바꿔주면 확인이 된다.


build.gradle 파일

: constraint-layout을 사용하지 않으므로 모듈을 사용한다는 정의는 제거(제거안해도 되지만 깔끔하게)

exercise

 solution

 

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "com.android.example.favoritetoys"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'

// TODO (7) Remove the ConstraintLayout dependency
// as we aren't using it for these simple projects
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
}
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "com.android.example.favoritetoys"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
}

 


TODO를 모두 처리하고 App Build를 하면

다음과 같이 프로젝트 화면이 나온다. 별다른 특이점은 없다.

기본 layout을 framelayout으로 바꾼 것 뿐


Project Setup으로 나오는 것은 string.xml 에 app_name이 그리 되어있어서 임.


728x90
$ adb push app-debug.apk /data/local/tmp/com.beanandyu.myapplication

com.android.ddmlib.AdbCommandRejectedException: device unauthorized.

This adb server's $ADB_VENDOR_KEYS is not set

Try 'adb kill-server' if that seems wrong.

Otherwise check for a confirmation dialog on your device.

Error while Installing APK



위의 에러는 Android Device에서 USB Debugging을 허용하지 않았을 때에 발생한다.

해결방법은
Android device의 usb 연결을 뺏다가 다시 연결하면 pop up menu가 뜨면서
usb debugging 허용을 물어본다.

이 때, YES 를 선택하면 된다.

--
최초 debuggin 모드 설정 방법

- Settings 앱을 엽니다.
(Android 8.0 이상에만 해당) System을 선택합니다.
-아래로 스크롤하여 About phone을 선택합니다.
-아래로 스크롤하여 Build number를 7번 탭합니다.
-이전 화면으로 돌아가서 아래쪽의 Developer options를 찾습니다.
 Developer options 화면 상단에서 옵션 켜기와 끄기를 전환할 수 있습니다(그림 1). 이 기능을 계속 켜두고 싶을 수도 있습니다. 꺼진 경우에는, 기기와 개발용 컴퓨터 간에 통신이 필요없는 옵션을 제외한 대부분의 옵션이 비활성화됩니다.

그 다음 아래로 약간 스크롤하여 USB debugging을 활성화해야 합니다. 이렇게 하면 기기가 USB를 통해 연결될 때 Android Studio와 기타 SDK 도구들이 이 기기를 인식할 수 있기 때문에 개발자가 디버거와 기타 도구를 사용할 수 있습니다.

참고 : 개발자모드 활성
https://developer.android.com/studio/debug/dev-options?hl=ko

참고 : 위치서비스
https://developer.android.com/guide/topics/location/strategies#MockData

참고 : 에뮬레이터에 기본위치 설정
https://developer.android.com/studio/run/emulator#console




728x90

KAKAO Navi를 이용한 Application을 만드는 준비편


참조 : https://developers.kakao.com/docs/android/kakaonavi-api


카카오내비 앱을 호출하여 목적지까지 길안내를 할 예정인데

설정할 것듯이 좀 있다.


-- KAKAO Developer 에서 앱추가를 하여 application_key를 생성해야 한다.

-- open ssl 설치 필요

http://code.google.com/p/openssl-for-windows/downloads/list 접속
자신에 윈도우 비트에 맞는 최신버전 zip 파일 다운로드 (예: openssl-0.9.8k_X64.zip )
압축해제

openssl-0.9.8k_X64 폴더를 C:\로 이동

path설정: 내컴퓨터 오른쪽 버튼 > 속성 > 고급 시스템 설정 > 환경변수

 - JAVA_HOME

 - OPENSSL_HOME


커맨드창 open : 윈도우키 +R -> cmd 엔터

release_key_alias : myTestApp

release_keystore_path : C:\Users\내컴퓨터\.android\debug.keystore

keytool -exportcert -alias <release_key_alias> -keystore <release_keystore_path> | openssl sha1 -binary | openssl base64


keytool -exportcert -alias myTestApp -keystore C:\Users\내컴퓨터\.android\debug.keystore | openssl sha1 -binary | openssl base64

위 명령을 실행시키면

키저장소 비밀번호를 입력하라고 나오고

입력하면 해쉬키가 생성된다.

이것을 kakao developer의 해당 어플내 플랫폼을 클릭하면

키해쉬에 붙여넣고 저장.


위에서 생성한 것은 개발용이므로 배포할 때에는 release용으로 생성하여 추가하면 된다.




1. kakao_strings.xml 추가

app\src\main\res\values\kakao_strings.xml

내용

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="kakao_app_key">카카오 api에서 생성한 app_key</string>
</resources>


2. Gradle Scripts

gredle.properties

KAKAO_SDK_GROUP=com.kakao.sdk
KAKAO_SDK_VERSION=1.15.1


build.gradle(Project:app이름)에 추가

subprojects {
repositories {
mavenCentral()
maven { url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/' }
}
}


build.gradle(Module:app)에 추가 - 필요한 kakao 서비스 추가

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha08'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

// 카카오 로그인 sdk를 사용하기 위해 필요.
compile group: 'com.kakao.sdk', name: 'usermgmt', version: KAKAO_SDK_VERSION
//compile group: 'com.kakao.sdk', name: 'usermgmt', version: 1.15.1

// 카카오내비 sdk를 사용하기 위해 필요.
compile group: 'com.kakao.sdk', name: 'kakaonavi', version: KAKAO_SDK_VERSION
//compile group: 'com.kakao.sdk', name: 'kakaonavi', version: 1.15.1

}

 


준비는 끝남.

이후로는 Kakao developer의 가이드 대로 manifest.xml 추가 및 activity 추가해서 만들면 됨.


728x90

https://www.udacity.com 에서 제공하는 안드로이드 강좌 중

DevelopingAndroidApps라는 공짜(free) 강좌를 이곳에 옮긴다.


회원가입도 무료이고 구글개발자들이 강좌를 진행하며

문제제공 -> 풀이 형태로 다른 강좌와는 형태가 달라

따라하기가 그나마 쉽다.

다만 자바지식이 없으면 따라오기 조금 어려울 수도...


1. Android Studio를 다운받는다.

2. Udacity에서 해당강좌의 source 파일을 다운받는다.

   source는 각 강좌별 Excersise(연습: 파란색)와 Solution(완료 : 빨간색) 두개씩 있으므로

   연습 프로젝트를 import하여 강좌를 따라하면서 막히는 부분은 Solution 소스와 비교해가면 된다.


3. Udacity에서 제공되는 동영상강좌를 보면서 각 연습프로젝트를 따라한다.

  동영상에는 자막을 선택할 수 있다.

  영어지막은 물론 대부분의 강좌에 한글자막도 선택이 가능

  하지만 자막을 보면서 이해가 잘 안갈 수도 있어서(나같이)

   따라해 가는 강좌를 다시 만드는 것이다


--들어가기 전에 강좌를 따라하는 방법

프로젝트 import를 하고 나서 Todo Tab에서 해야할 일들을 확인한다.(빨간색 tab 클릭)

프로젝트아래 변경할 파일 및 작업할 내용(TODO)가 있다.

TODO의 순서대로 작업하면 되며 해당 TODO를 더블 클릭하면 바로 이동이 된다.


강좌를 듣고 하라는 대로 하면서 안되는 것들이나 완료 후에 Solution 소스랑 비교하면 된다.

비교는 Beyond Compare 4라는 소스비교 툴로 폴더 채 비교하거나 파일별로 비교한다.

(폴더 비료 추천)



이 영상과 코드가 일치하지 않는다면
GitHub에 있는 코드가 옳은것이므로

Solution 을 import하여 build 해보면 된다.


Udacity 강좌에서 5. Coding, Githyb and Flow 에서 강좌의 예제파일 다운로드를 방법이 나온다.

Sunshine : https://github.com/udacity/ud851-Sunshine

Toy : https://github.com/udacity/ud851-Exercises

링크에서 Clone or download 를 눌러 소스를 다운받는다.


Udacity 강좌를 따라하면서 제공되는 것이므로

해당 강좌보면서 따라하는 것을 추천!!

(나는 단지 도울 뿐 ㅎ)


여기까지 구성이 되면 강좌 5가 끝난것이고 강좌 6에서 제대로 이해했는지 퀴즈가 나온다.

답을 하고 밑에 제출버튼을 누르면 되고 내키지 않으면 그냥 다음 강좌로 넘어가면된다.

원하는 강좌를 좌측메뉴에서 선택하면 됨.


자 이제 시작해 볼까?





728x90

강좌를 공부할 때 완성본 또는 샘플과 내가 만든것의 차이가 어떤게 있는지 비교가 필요하다.


안드로이드는(자바포함) 버전이 다양해서 android studio 버전별로 동작이 될 수도 있고 안될 수도 있기 때문에 내가 오타를 친 것인지 원본과 비교가 필요할 때 가 많다


이 때 소스비교 툴을 사용하여 원본과 비교하면서 틀린점을 비교하면 좋다.


Beyond Compare 를 다운받는다.

Beyond 1,2,3을 거쳐 현재는 4다. 이전버전도 받을 수 있으므로 아래 링크를 통해 다운

https://www.scootersoftware.com/download.php


안드로이드 소스비교 예

1. 실행화면
- 두 소스를 폴더 채로 비교 가능하므로 폴더비교(folder compare)선택

2. 비교할 폴더1(빨간색), 비교할 폴더2(파란색) 영역이 나옴.
나의 경우는 왼쪽을 원본으로 하고 내가 작성한 것은 오른쪽에 놓는다.

3. 소스 폴더 찾기.
빨간색으로 표시된 폴더 표시를 클릭하여 원본이 있는 위치를 선택
동일한 방식으로 오른쪽에 내 폴더도 불러온다.

4. 비교파일 선택
원본(왼쪽)과 같은 프로젝트이지만 나는 package명이 다르므로 동일하다고 나오지는 않음.
그래도 MainActivity를 비교할 것이므로 두 파일을 선택한 다음 오른쪽 버튼 클릭

5. Quick Compare 를 선택

6. Text Compare 선택 후 Open View를 클릭.

7. 두 개의 파일이 비교 됨.

다른 부분은 빨간색으로 표시됨.



728x90

Android studio Genymotion Plugin 을 쓰려고 봤더니

현재 3.1 버전에는 검색이 되나 3.2, 3.3버전에서는 검색이 안된다 ㅜ.ㅜ



File > Setting > Plugin 에서 genymotion을 검색

- 3.1버전


검색이 되어 install 버튼으로 바로 설치했는데...

3.2랑 3.3에서 똑같이 검색했는데.. 검색 안됨 쩝....


걍 있는 AVD 써야겠당.

728x90

이상하다..

Internet Permission도 다 줬는데

왜 webView에서 이동이 안될까?


주소는 맞는데...
ERR CLEARTEXT NOT PERMITTED라며 화면이 로드가 안되네...
(이미지가 작으면 클릭하세요. 커집니다.)


보안설정 어쩌구 하는데

안드로이드에서 막은 듯.

http는 그냥 접속이 안되고 https 는 그냥 접속이 된다.


푸는 방법이 2가지 있으나

간단히 푸는 방법은


application 안에 구문을 추가하면 된다.

android:usesCleartextTraffic="true"



정상적으로 홈페이지 접속이 된다.


WebView 이용시에는

접속 url을 https://로 시작하는 주소이거나

application보안설정을 변경(android:usesCleartextTraffic="true" 추가)하면 된다

참조 : stackoverflow

https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted

728x90

method의 첫글자는 소문자가 습관이 되어


button.setOnLongClickListener(
new Button.onLongClickListener(){
public boolean onLongClick(View v){
TextView statusText = (TextView)findViewById(R.id.statusText);
statusText.setText("Button Long clicked");
return true;
}
}
);

 

버튼의 롱~클릭 이벤트를 정의했는데... 문제가 있다고 한다.



button.setOnLongClickListener(
new Button.OnLongClickListener() {
public boolean onLongClick(View v) {
TextView statusText =
(TextView)findViewById(R.id.statusText);
statusText.setText("Long button click");
return false;
}
}
);

자세히 보면 Button의 Long Click EventListener의 On 은 대문자다 ㅡㅡ;

Listener 내 method는 onLongClick 로 소문자인데...


ㅋㅋ 알보고면 Listener는 Class이고 기본생성자인 것이다...

괄호가 있다고 method라고 착각했던...


728x90

간만에 android 쪽에 왔더니 많은것이 바뀌어 있네.

eclipse -> android studio로...

 

다시 시작 ㅋ


이미지뷰(ImageView)를 드래그 해 놨는데 미리보기가 안된다... 쩝

메세지 항목에 알 수 없는 에러라고 뜨고 'Refresh' 하라고 되어있지만 해결이 안된다.


간단히 해결하려면


app > res > values > styles.xml 파일의 설정을 수정한다


원본 :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">


수정 :

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">


변경한 뒤 저장하면 정상적으로 나옴.





728x90
소스에는 이상이 없음

Linearlauout 다음에 ,scrollview 가 들어오면
Linearlayout 안에 버튼의 클릭이벤트가 발생안함

그래서 scrollview 아래로 위치시키면이면 정상적으로 클릭이벤트 발생함
728x90
BLOG main image
"그게 뭐 어쨌다는 거냐?" 늘 누가 나에게 나에대한 말을할 때면 이말을 기억해라. by nobang

카테고리

nobang이야기 (1933)
Life With Gopro (7)
Life With Mini (79)
Diary (971)
너 그거 아니(do you know) (162)
난 그래 (159)
Study (290)
Cloud (26)
Go lang (30)
Front-end (27)
Device (3)
MAC (1)
Spring framework (49)
Java (13)
English (39)
SOA (0)
Idioms (7)
모르는거 (5)
WriteEnglish (10)
Android (56)
속지말자 (10)
Project (34)
Poem (15)
Song (0)
Photo (113)
낙서장 (45)
일정 (0)
C.A.P.i (2)
PodCast (0)
nobang (27)
고한친구들 (4)
recieve (0)
History (0)
android_app (2)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :