Thursday, September 2, 2021

인텔리J 프로퍼티 UTF-8로 보기

 


Editor > File Encodings 에서


Transparent native-to-ascii conversion 체크하고 저장하면 끝


Sunday, August 29, 2021

Eclipse 2021-06 이상 lombok 설정

 1. lombok 설정 

lombok은 VO에 자동으로 Setter, Getter를 생성해주는 것이다.

 

의존성 추가

https://mvnrepository.com 에서 lombok을 검색 후 원하는 버전을 선택한다. 

메이븐 프로젝트의 경우엔 pom.xml에, gradle일 경우엔 build.gradle에 소스를 복사하여 붙여넣는다.

https://projectlombok.org/  => download에서 프로그램을 설치한다.

java -jar lombok.jar

lombok.jar를 실행시켜서 Specify location을 클릭하여 eclipse.exe 를 찾아 추가 후 install을 클릭하여 설치한다.

eclipse.ini에 아래가 추가된 것을 알 수 있다.

-javaagent:D:\eclipse-jee-2021-06\lombok.jar



2. Eclipse 2021-06 에서 lombok 사용시 Unable to make protected... 에러 해결



Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) 

throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4eb63dc8

일단 이클립스를 종료 하고 eclipse 설치폴더의 eclipse.ini 파일을 찾아갑니다.

그러고 제일 아래 -javaagent:D:\eclipse-jee-2021-06\lombok.jar 밑에 두줄의 내용을 붙이고 저장합니다.

--illegal-access=warn

--add-opens java.base/java.lang=ALL-UNNAMED

https://shanepark.tistory.com/205 참조



Thursday, May 27, 2021

Maven - 이클립스 Maven 연동 시 plug in 에러 날 경우

 

Maven - 이클립스 Maven 연동 시 plug in 에러 날 경우

Multiple annotations found at this line:
- Execution default-testResources of goal org.apache.maven.plugins:maven-resources-          plugin:2.4.3:testResources failed: 
 Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect 
 dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
 plugin:2.4.3:testResources:default-testResources:process-test-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile 
 (execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: 
 PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be 
 resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): 
 ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6: 
 ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
 maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or 
 updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
 repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
 api-2.0.6.pom
- CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: 
 PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be 
 resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): 
 ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6: 
 ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
 maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or 
 updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
 repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
 api-2.0.6.pom
- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources failed: Plugin 
 org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect 
 dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
 plugin:2.4.3:resources:default-resources:process-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
 2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
대략 이런 에러가 발생했을 경우.
POM.xml을 확인해보면
<project xmlns="http://maven.apache.org/POM/4.0.0"                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.lala.sarasa</groupId>
   <artifactId>msrdecision</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>msrdecision Maven Webapp</name>
  <url>http://maven.apache.org</url>
 <dependencies>
   <dependency>
     <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>hello</finalName>
   </build>
 </project>
이렇게 되어 있을 것이고, 해결방법은 POM.xml에
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
</dependency>
이런식으로 디펜던시를 추가해주면 된다.(현재 날짜 기준으로 최신버전인 3.2.1은 되지 않는다.)
이렇게 작성해준 뒤에, 
1. 프로젝트 우클릭 > Run As > Maven Install
2. 이클립스 프로젝트 탐색기에서 해당 프로젝트 클릭 후 F5(새로고침)
3. 프로젝트 우클릭 > Maven > Update Project 
끝!
출처:http://jin-study.blogspot.com/2014/03/maven-maven-plug-in.html

Tuesday, May 18, 2021

Argument 'getContext()' might be null

 https://developer.android.com/guide/components/fragments.html?hl=ko#java

 

프래그먼트  |  Android 개발자  |  Android Developers

A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section…

developer.android.com

Fragment 생명주기에 보면, 다음과 같이 주의사항이 표시.

따라서 안전하게 

다음과 같이 onAttach에서 context 와 activity를 복사해두자.

    @Override
    public void onAttach(Context context) {
        mContext = context;
        if (context instanceof Activity) {
            mActivity = (Activity)context;
        }
        super.onAttach(context);
    }
    
    
    // detach에서는 변수 clearing 해주기 leak방지
    @Override
    public void onDetach() {
        mActivity = null;
        mContext = null;
        super.onDetach();
    }

 



출처: https://ciwhiz.tistory.com/282 [ciwhiz's garret]

Monday, May 17, 2021

Suspicious 'List.remove()' in the loop

 Suspicious 'List.remove()' in the loop


List<GPUImageFilter> imageFilterList = imageFilterGroup.getFilters();
for (int i = 0; i < imageFilterList.size(); i++) {
if (imageFilterList.get(i) instanceof GPUImageGaussianBlurFilter) {
imageFilterList.remove(i);
}
}

루프 도중에 삭제할 경우 사이즈와 인덱스 불일치 등이 일어나서 문제의 여지가 있다. 
그럴땐 아래와 같이 Iterator를 이용하여 처리하자

List<GPUImageFilter> imageFilterList = imageFilterGroup.getFilters();
Iterator iter = imageFilterList.iterator();
while(iter.hasNext()) {
if(iter.next() instanceof GPUImageGaussianBlurFilter) {
iter.remove();
}
}

Wednesday, May 5, 2021

Resource IDs will be non-final in Android Gradle Plugin version 7.0, avoid using them in switch case statements

AndroidStudio를 4.2로 업데이트했더니 아래 문구가 Probleams에 뜬다.


 Resource IDs will be non-final in Android Gradle Plugin version 7.0, avoid using them in switch case statements


현재 gradle 정식 최신 버전은 

Android Gradle Plugin Version 4.2.0

Gradle Version 6.7.1

인데 Project Structure의 Project 탭의 버전 셀렉트버튼을 클릭해보니 7.0이 있다.

gradle version은 이미 7.0이 있었고 Gradle Plugin Version은 7.0.0-alpha 버전들이 쭈욱 있었다.


4.2.0에서 7.0이라니...


곧 둘다 버전을 7로 맞출려나 보다. 



7.0에서 final이 빠진다니 미리 switch문을 if문으로 바꿔주자.



우선 AndroidStudio 에서 swith문을 if문으로 바꿀려면 


swith문 위에서  Alt+Enter를 치면 나온다.


또는 

Solution is simple:

  • File > Settings > Editor > Intentions - Search: "replace switch"

or

  • File > Settings - Search: "replace switch" > Editor > Intentions

and check the blank checkbox




https://stackoverflow.com/questions/28259009/how-to-automatically-convert-if-else-if-statement-to-switch

Thursday, April 22, 2021

ios와 android Exif orientation 차이

 내 코드가 EXIF ​​데이터를 설정할 수 있었지만 Android가이 데이터를 해석하는 방법과 Mac의 iOS 및 Chrome (결과 파일을 확인하는 위치)에서 데이터를 해석하는 방법 사이에 불일치가 있습니다.

이것은 EXIF ​​방향을 설정하는 데 필요한 유일한 코드입니다.

ExifInterface exif = new ExifInterface(pictureFile.toString());
exif.setAttribute(ExifInterface.TAG_ORIENTATION, "3");
exif.saveAttributes();

그러나 설정 3은 0iOS에서와 같이 표시 되며 Chrome에서는 이미지가 옆으로 표시됩니다.

설정 6은 3iOS에서와 같이 표시되고 이미지는 Chrome에서 올바르게 보입니다.


Monday, March 15, 2021

이미지 로고 타이틀 Toolbar 센터에 위치 시키기

 



Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);


<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.Temp.AppBarOverlay">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/Theme.Temp.PopupOverlay" >
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="165dp"
android:layout_height="wrap_content"
android:src="@drawable/toolbar_title"
android:layout_gravity="center"/>
</androidx.appcompat.widget.Toolbar>

</com.google.android.material.appbar.AppBarLayout>