안드로이드 어플에서 전화수신 팝업 기능을 테스트 해보고자 검색해보니 http://gun0912.tistory.com/46 에 자료가 있다.
코드를 받아서 보니 Butter Knife 라이브러리를 사용했더라.
한번도 사용을 해보지 않은 거라 그런지 소스코드를 붙여넣기 하니 에러가 발생한다.
검색으로 찾아보니 이 분 블로그에 방법이 나온다.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.google.firebase:firebase-messaging:9.6.1'
// butterknife 추가해주는 것만으로 알아서 import 해 줌
compile 'com.jakewharton:butterknife:7.0.1'
}
이렇게 하고 나면 Sync Now 를 눌러줘야 한다.
CallingService.java 파일내에 코드에서 에러가 해결되지 않는 곳이 있다.
@InjectView(R.id.tv_call_number) TextView tv_call_number;
ButterKnife.inject(this, rootView);
import butterknife.InjectView;
부분을 인식할 수 없다고 나온다.
문제 해결을 위해서 구글링을 해보니 http://jakewharton.github.io/butterknife/ 에서 확인하라고 나온다.
버전이 높아지면서 기능이 변경되었다는 걸 알 수 있었다.
compile 'com.jakewharton:butterknife:8.5.1'
기 존 |
수 정 |
@InjectView(R.id.tv_call_number) TextView tv_call_number; | @BindView(R.id.tv_call_number) TextView tv_call_number; |
ButterKnife.inject(this, rootView); |
ButterKnife.bind(this, rootView); |
Gradle 에 버전을 수정해주고 코드를 수정하고나서 에러 메시지가 없어졌다.
이제 컴파일하여 코드를 테스트하는데 코드가 비정상적으로 동작하면서 죽는다.
원인이 정확하게 해결되지 않았나 보다..
원인 해결되면 수정 정리해야겠다.
'안드로이드 > 버그탈출' 카테고리의 다른 글
setlatesteventinfo() is deprecated (0) | 2017.04.05 |
---|---|
Android Studio ITelephony.aidl (not .java) (0) | 2017.04.03 |
LG G5 개발자 모드 설정(USB 디버깅) (4) | 2017.03.29 |
Android 6.0 이상 권한 오류 해결방법 (0) | 2017.03.24 |
단체문자(동보) 발송한도 (0) | 2017.03.01 |
보통 deprecate 되어도 이전 코드를 지우는 건 아니기 때문에, 전처럼 동작하기는 할 것이다.
향후, 유지보수단계에서 deprecate 코드에 대해서 안정성을 보장하지 않는다는 얘기이기 때문에, 안드로이드 차기 버전 에서는 비정상 동작을 할 가능성이 높아진다.
대체코드를 찾아서 새롭게 구현하는게 현명한 판단이다.
메모리 누수를 일으키는 현상에 대한 정리가 잘된 자료이다.
http://sjava.net/2016/05/%EB%B2%88%EC%97%AD-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%95%B1%EC%9D%B4-%EB%A9%94%EB%AA%A8%EB%A6%AC-%EB%88%84%EC%88%98leak%EB%A5%BC-%EB%A7%8C%EB%93%9C%EB%8A%94-8%EA%B0%80%EC%A7%80/
depricated 로 나온 걸 하나 하나 해결하기 위해 찾은 걸 적어나갈 것이다.
URLDecoder.decode(getIntent().getExtras().getString("url"), "UTF-8");
getSettings().setUserAgent(0); => getSettings().setUserAgentString("Android");
URLEncoder.encode("","UTF-8")
Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead NetworkCheck.java
url = url.toLowerCase(); ==> url = url.toLowerCase(Locale.getDefault());
// http://beginnersbook.com/2013/12/java-string-tolowercase-method-example/
The method decode(String) from the type URLDecoder is deprecated
URLEncoder.encode(String s, String enc);
import java.net.URLEncoder;
URLEncoder.encode("This text must be encoded!", "UTF-8");
AlertDialog: BUTTON_POSITIVE, BUTTON_NEUTRAL and BUTTON_NEGATIVE.
AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
alertDialog.setTitle(" [ 알림 ]");
alertDialog.setMessage("등록된 휴대폰 번호가 없습니다.");
alertDialog.setButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
alertDialog.setTitle(" [ 알림 ]")
.setMessage("등록된 휴대폰 번호가 없습니다.")
.setCancelable(false)
.setNegativeButton("확인",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = alertDialog.create();
alert.show();
alertDialog.setButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,"확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
// http://www.technotalkative.com/issue-using-setjavascriptenabled-can-introduce-xss-vulnerabilities-application-review-carefully/
@SuppressLint("SetJavaScriptEnabled")
public class MyActivity extends Activity
{
...
}
// 내용 파악이 필요한 부분
showDialog(DIALOG_DOWNLOAD_PROGRESS);
The method showDialog(int) from the type Activity is deprecated
https://developer.android.com/reference/android/app/Activity.html#showDialog%28int%29
This method was deprecated in API level 13.
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null,Charset.forName("UTF-8"));