Let's refactor code!With this package, you can rename the name of variables and functions easily.
Language Support
Sep 22, 2014 Android Studio would only let me refactor the last part of the package name (blogreader). At this point I think I'm going to try opening up the source code from the second to last step (I dont really need to support andy v2.3.3 for my use) in sublime text, change all package names and SDK versions. This short tutorial will show you how to change the package name in Android Studio. Here are the steps you need to follow: 1) Make sure you have Android sele. Another good method is: First create a new package with the desired name by right clicking on the Java folder → New → Package. Then, select and drag all your classes to the new package. Android Studio will refactor the package name everywhere. Finally, delete the old package.
This package works with these language plugins.You can install using the preferences pane.
- JavaScript: js-refactor with ES6+ support
- CoffeeScript: coffee-refactor
Usage
- Set cursor to a symbol.
- Start renaming by using
ctrl-alt-r
. - Type new name.
- Finish renaming by using
enter
or removing cursor from the focused symbol.
User Setting
- Override keymap by using
Atom > Open Your Keymap
.
For example, you can override the shortcut to ctrl-alt-e
- Override stylesheet by using
Atom > Open Your Stylesheet
.
API Documentation (for plugin developer)
package.json
Add refactor
as engines
in package.json
.
Interface
You should implement Ripper
class in main module.
Ripper.scopeNames []String
: [Required] Array of scope name, like 'source.coffee', 'source.js' and all that.Ripper#parse(code String, callback Function)
: [Required] Parse code, and you should callback when the parsing process is done. Callback specify the params as an array of errorObject
. The errorObject
should have paramsrange
andmessage
.Ripper#find(point Point) []Range
: [Required] Return an array of found symbols'Range
at the passedPoint
.
Examples
See
There are things one may need to change in the release build for Android. Things like App Name
are a case here. Suppose you start developing by initialising to a generic App Name
and at the time of release one need to change to the actual App Name
. Same goes for package name
, which is visible in Google Play Store
and as well in the App details
of the Android phone.
Before we move forward and change things in the final version of the app. There is a way to fix this from the beginning. Generate a react native
app with a proper package name with the commandbelow.
But however if at all you have initialised the appas
then the option remains to hack things in theend.
So read on.
App Name
Lets start with App Name
. This is the name thats visible in users screen. To change this name, you have to change it in strings.xml
.
Full path is
and the entryis
Package name
This is shown in the Play Store
and the details in About App
of your Android device. This should say something like com.myapp
or com.company.appname
or somethingsimilar.
To change this, you have to edit fourfiles.
- android/app/src/main/java/com/reactNativeSampleApp/MainActivity.java
- android/app/src/main/java/com/reactNativeSampleApp/MainApplication.java
- android/app/src/main/AndroidManifest.xml ( optional as per my experience)
- android/app/build.gradle
The first two Java files have the package name as something likebelow.
Change it to your desired packagename.
At this point it should be required to make the physical changes to the Java files in the proper package. But somehow it does not work! Rather it breaks the build. Just keep in mind, that we have changed the package
names and that should reflect in the actual package. Incase the builds break, you know where tofind.
Version Code
Android Studio Refactor Change Package Name
This is a number which Google Playstore recognises and does not allow to upload another APK having the same value. Just think of this as build number. The same build can not be uploaded twice. So the point is everytime, you make a build or release-apk, you must have a different number or more specifically incremental number. If your first version of the application has a version code of 5, then the second version must have a version code which is more than5.
Along with version code, you might need to update the version name
also. Which is the version number of your application and visible in Google PlayStore.
While version code
is used by Play Store
to manage your APK, version name
is used by Play Store
to notify user that an update to your app isavailable.
To change these two values, you need toedit
- android/app/build.gradle
- android/app/src/main/AndroidManifest.xml ( optional as per my experience)
These settings are taken from build.gradle
while making a build with gradle
but for the purpose of sanity, its better to change in both of the filesabove.
Here is a referencechange.
Making the releasebuild
Android Studio Refactor Whole Package Name
Finally making a release build is done from inside the android
folder of the React Native
application. The commands are asbelow.
Android Refactor Package Name Tags
Cheers