0

if we create new package com.example.app and move our files to this package by drag and drop and delete old files then still wrong R file imports exists in project and i have to replace R file imports from all activities and classes manually to fix bugs.... so i want to ask how can i change package name without this old package name R file import issue?

i already check and followed these all steps but this did not solve that issue

Android Studio Rename Package

SymbolixAU
  • 25,502
  • 4
  • 67
  • 139
Muhammad Natiq
  • 213
  • 5
  • 14

2 Answers2

0

In order to change package name in android studio you need to follow several steps to do it without any errors

Look at this post hope you achieve your goal successfully

Android Studio Rename Package

behroozhj
  • 11
  • 2
  • this is not the answer i already checked that and included that post link in my question, i already go through all steps but the way in which i want to change the package name is different than explained in that answer/post – Muhammad Natiq Jun 24 '17 at 12:39
  • but I did it several times without any problems! did you try to rebuild your project? – behroozhj Jun 24 '17 at 12:55
  • yes i tried to rebuild and also tried Clean my situation is little different i want to change “com.example.new.app” to “com.example.app" how to remove directory named "new" from previous package name, if we create new package com.example.app and move our files to this package by drag and drop and delete old files then still wrong R file imports exists – Muhammad Natiq Jun 24 '17 at 13:00
  • I think you should rename 'new' to 'app', in your case you should have com.example.app.app – behroozhj Jun 24 '17 at 13:00
  • then move all your files to the folder you just renamed and remove the last empty folder I mean the empty 'app' – behroozhj Jun 24 '17 at 13:02
  • in this way package name will be changed but old package name R file imports will never removed automatically i have to change manually otherwise there will be compile time bugs – Muhammad Natiq Jun 24 '17 at 13:18
  • i want to auto change that imports also – Muhammad Natiq Jun 24 '17 at 13:18
0

I'm guessing that your approach still retains some folders of the old package name, not deleting them completely.

To solve the problem of changing the package name safely and effectively. You can use the plugin "Android Package Renamer". It is quite possible to change your package name from "com.example.new.app" to "com.example.app".

What you need to do is install and use:

Usage

  • Open Your Project.
  • Click -> File -> Rename Package
  • Input the Package you want to change.
  • Click Ok.
  • Sync Project with Gradle Files or Invalidate Caches

You can see his detailed answer here

Phuc VR
  • 111
  • 1
  • 3