IT박스

Eclipse에서 Android 프로젝트의 패키지 이름을 변경하는 방법은 무엇입니까?

itboxs 2020. 6. 28. 19:23
반응형

Eclipse에서 Android 프로젝트의 패키지 이름을 변경하는 방법은 무엇입니까?


Eclipse 에서 작성된 Android 프로젝트가 있습니다. 프로젝트의 패키지 이름과 응용 프로그램을 수정하고 싶습니다. Eclipse에서 어떻게합니까?


평소와 같이 F2패키지 이름 을 누르면 패키지 이름을 바꾸거나 패키지 이름을 변경할 수 있으며 마우스 오른쪽 단추를 클릭 한 다음 Rename옵션 을 선택 하여 패키지 이름을 변경하거나 이름을 바꿀 수 있습니다.

를 누르면 F2대화 상자가 다음과 같이 표시됩니다.

대체 텍스트

이 대화 상자에서이 확인란을 "확인"하면 프로젝트의 다른 구성 요소가 참조하는 패키지의 모든 참조가 변경되므로 "참조 업데이트"확인란을 선택하는 것을 잊지 마십시오.


이것은 Eclipse Android 도구의 버그입니다 .

수정하려면 : 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 Android 도구-> 응용 프로그램 패키지 이름 바꾸기로 이동하십시오.

또한 AndroidManifest.xml올바르게 업데이트되었는지 확인하십시오 . 내 경우에는 그렇지 않아서이 문제를 해결해야합니다.


이 중 어느 것도 나를 위해 일하지 않았으며 모두 오류가 발생했습니다.

다음은 나를 위해 일했습니다.

  • 프로젝트를 마우스 오른쪽 단추로 클릭하고 Android 도구 >> 애플리케이션 패키지 이름 바꾸기를 선택하십시오.
  • 새 패키지 이름을 입력하십시오
  • 변경하려는 모든 자동 변경 사항을 수락하십시오.
  • 시작 구성을 업데이트하려면 예라고 말하십시오.

하나의 매우 중요한 통지 :

패키지 이름이 포함 된 문자열 값을 전달하는 것과 유사한 방식으로 직접 패키지 이름을 사용하지 마십시오 . getPackageName () 메소드를 사용하십시오. 이것은 이름 변경을 동적으로 만듭니다. getPackageName () 메소드에 도달하려면 무엇이든하십시오.

Eclipse Juno에서 올바른 이름을 바꾸는 방법은 다음과 같습니다.

  1. 가서 매니페스트를 편집하십시오.
  2. 매니페스트에서 모든 이전 패키지 이름을 제거하십시오.
  3. 기존 패키지 이름 대신 매니페스트 내의 모든 위치에 새 패키지 이름을 넣습니다. 직접 패키지 이름 참조가 필요한 클래스 (활동)가있을 수 있습니다.
  4. 매니페스트를 저장하십시오.
  5. 그런 다음 프로젝트 내에서 패키지 이름을 마우스 오른쪽 단추로 클릭하십시오.
  6. "리 팩터"를 선택하십시오.
  7. "이름 바꾸기"를 선택하십시오.
  8. 새 패키지 이름을 입력하십시오.
  9. "업데이트 참조"를 선택하십시오.
  10. OK를 누르면 새로운 이름을 대체하기 위해 수행해야 할 작업도 감시합니다.
  11. 새 패키지 이름으로 레이아웃 XML 파일도 업데이트하는 것을 잊지 마십시오 . 사용자 정의보기가있을 수 있습니다. 그들을 찾으십시오.

 Right click on your project name and select Android Tools , then click 
 Rename Application Package, then change your project name click OK and 
 click Finish.

여기에 이미지 설명을 입력하십시오

여기에 이미지 설명을 입력하십시오

여기에 이미지 설명을 입력하십시오


Android에서 앱 이름을 변경하려면 원하는 항목으로 이동하여 res/values/strings.xml변경하십시오 app_name.


프로젝트 이름을 마우스 오른쪽 버튼으로 클릭하고 Android 도구를 선택 하고 애플리케이션 패키지 이름 바꾸기를 클릭 하고 이름을 바꾸십시오. Android 프로젝트 전용입니다.


를 누른 F2다음 이름을 바꾸십시오 (또는 프로젝트를 마우스 오른쪽 버튼으로 클릭하고을 선택하십시오 Rename). 패키지가 프로젝트에서 선언 된 곳마다 변경됩니다. 자동으로 모든 이름이 바뀝니다.


Android 프로젝트 Src 폴더로 이동하여 Java 파일을여십시오.

패키지 OldName.android.widget를로 변경하십시오 newName.android.widget.

그것은 당신에게 이런 오류를줍니다

선언 된 "newName.android.widget"패키지가 예상 된 "OLDName.android.widget 패키지와 일치하지 않습니다.

To fix this problem, select Move filename.Java to Newname.android.widget and delete the old package folder.

Next step: Go to AndroidManifest.xml and change package="OldName.android.widget" to package="newName.android.widget".


This worked perfectly for me (simple text replace):

Go to search -> file

Containing text: old pakage name

File name pattern: *

Scope: workspace

Press Replace

Replace: new package name

Now your project is full of errors.

Click your package in project explorer and press F2 (rename).

Fill in the new package name and check all checkmarks.

Press Preview.

Click OK.

Wait for Eclipse to refresh. If there are still errors, clean all projects in the workspace:

Project -> Clean


None of this worked for me until I combined the two answers mentioned in this post.

Step 1: Right click on the project -> Select Android Tools -> Rename application Package. (This will change all the files in the gen folder and in AndroidManifest but will not change the package name in the src folder so I followed Step 2)

Step 2: Inside src folder Right Click your package name -> Refactor -> Rename -> Enter the new name that you entered in Step 1.

Just to make sure Check AndroidManifest if there is still the old package name and replace with the new one (in my case inside the "uses-permission" tag).

Then close the Eclipse and Reopen it. Uninstall the app from your device and install it again and everything should be working fine.

Hope this helps and saves your time.


OK here's what I had to do:

Problem: I had a base project that I wanted to use as a starting point for several other projects that would be in the same workspace as the base project. The base project was already under GiT control in my own local repo. It was time to duplicate the base project, "MyBaseApp", to become the starting point for "MyKillerApp."

Solution:

  1. I just duplicated the overall MyBaseApp directory as MyKillerApp and had the two directories side-by-side.
  2. I edited file MyKillerApp->.project and changed the name from MyBaseApp to MyKillerApp. (This was necessary for step 3 to work.)
  3. I opened Eclipse and did a File->Import of MyKillerApp (I left out some details about how to use the Import menu, but click around, you'll figure it out.)
  4. I right clicked on MyKillerApp in the package manager and chose Android Tools->Rename Application Package to MyKillerApp. I checked all the options for renaming except the last checkbox about non-java files.
  5. I highlighted src->com.myname.MyBaseApp in the package manager and did an F2 to MyKillerApp. Then I did the same to a few classes including my opening activity class thing that goes into your AndroidManifest.xml file.
  6. I had to update a few function call names but the compiler pointed them out to me handily.

Thus I had a new project derived from a base project with no nomenclature left over from the base project and it was in its own local GiT repo.


Following worked for me in eclipse:

Go to AndroidManifest, search and replace old package name with new one and update everything when saving. Go to your root project package then press F2, write new name, and check Update References and Rename subpackages check boxes. After this everything was red in project (complaining about R import for every java file) because it wasn't changing closing tag of my custom view-s in layout xmls. After I changed these manually, everything was back to normal. That is it.


Renaming an Application- The Complete Guide

**A) for changing Just the application name
   (App name which is displayed below icon)
    in the Manifest.xml file, in <application tag, 
    android:label="YourAppName"
    then do the same in All the <activity Tags        

  B) For changing EVERYTHING 
   (folder names, Package names, Refrences,app name, etc.)
  *1) Renaming package names in gen folder and manifest.xml
      Right Click on Your project
      Android tools- Rename Application Package

  *2) Renaming package names in src folder 
      Expand src folder, Click on package (Single click) 
      Press Alt+Shift+R
      Check Update references and Rename subpackages      
   3) Renaming the app's main Folder (Optional)
      click on the application's folder (Single click)
      then Press Alt+Shift+R 

   4) Renaming application name- Refer "A)"**

Just get Far Manager and search through for the old name. Then manually (in Far Manager) replace everywhere. Sadly, this is the only method that works in 100% of the possible cases.


I had big trouble with this too.

리팩토링을 통해 프로젝트와 패키지의 이름을 바꾸었지만 앱을 쓸모 없게 만들었습니다. 원래 이름으로 바꾸고 Android 도구를 사용하여 패키지의 이름을 바 꾸었습니다. 그러나 패키지 폴더와 클래스의 이름은 이전과 같습니다.

그런 다음 패키지 폴더를 리팩터링했습니다. 이제 앱이 실행되지 않습니다. 내 매니페스트는 엉망이었다. 예를 들어 런처 이름을 두 배로 늘 렸습니다 com.ronguilmet.app/com.ronguilmet.com.class. 나는 그것을 고쳤고 모든 활동을 수동으로 편집해야했습니다.

참고 URL : https://stackoverflow.com/questions/3697899/how-to-change-package-name-of-android-project-in-eclipse

반응형