I want to rename package name from com.abb.acc to com.abb.acc.add (Android Studio).
Right click ----> New -----> Package, it create folder out side the file
expecting get result like - package com.abb.acc.add
If you mean, you want to change file from package com.abb.acc to com.abb.acc.add, then just change the package line on top(in the file) to package com.abb.acc.add. Then press alt-enter and select move to package 'com.abb.acc.add'.
If you want to rename your entire package, then right-click on your package, select Refactor -> Rename...
Right click com ----> new ----> package, enter new package name without com
Right click previous package name > Refactor > move to new package
Move package com.app to another package
Then delete the old package
I have solved by this way
Related
As summarised from the title, I am trying to change the package name to include one more subdirectory.
I went through the regular process of deselecting Compact Middle Packages and attempting to refactor.
What I have: "com.example"
What I want: "com.something.else"
Here are some things I have tried that have not worked.
I tried to rename "example" to "something.else" but the resulting package name was "com.else" instead of "com.something.else" (This was dumb but I tried it anyway)
Since the "." in a package name simply denotes a sub-package, I renamed example and called it something, after which I created a new package within "something" and called that "else", within which I moved all my code.
Now this gave the illusion of the package name I wanted since I actually had "com.something.else" but the problem here is, that new package I added obviously will not affect the androidTest and test packages...
I also went into my gradle to change the applicationId to match my new package... But that didnt work either... Its throwing build errors now..
Error log.
Process 'command '/Home/directory/Library/Android/sdk/build-tools/28.0.3/aidl'' finished with non-zero exit value 1
Don't know what is supposed to mean.
android studio bugged with this scenario. any way you use to rename whole app package will need to change something by hands.
And do not forget to invalidate caches in main menu
I had an error while uploading the APP to google developers console as I created the packages as com.example. ...
While trying to upload it to google play, this error comes up
SPANISH: "Debes utilizar otro nombre de paquete porque "com.example" está restringido."
ENGLISH: "You need to choose a different package name because "com.example is already chosen."
Do you know what may be causing this issue?
Thanks,
Marc
For example, if you want to change com.example.app to com.minigolf.app, then
1)In your Project pane, click on the little gear icon ( Gears icon )
2)Uncheck / De-select the Compact Empty Middle Packages option
3)Your package directory will now be broken up in individual directories
4)Individually select each directory you want to rename, and
Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Allow a minute to let Android Studio update all changes
7.Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All
5)Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:
6)Done! Anyways, Android Studio needs to make this process a little simpler.
I am new to Android Studio.
Right now, my android Studio project only has a single package, the application package. How do I create a subpackage ?
Currently, the package for the MainActivity.java is:
package com.davidgassner.plainolnotes.;
I want the directory for the subpackage to be: packagecom.davidgassner.plainolnotes.data;
When I created the subpackage using your's and Android Studio's instruction
I got the following:
package com.davidgassner.plainolnotes.com.davidgassner.plainolnotes.data;
I am getting an indication from Android Studio that the above path is not correct.
Right click in your main package -> New -> Package -> Give a name to your package and there you go.
If your main package is com.davidgassner.plainolnotes and you want to create com.davidgassner.plainolnotes.data , follow the steps above and when asked to input the package name, supply only "data". It will be created like this:
+ com.davidgassner.plainolnotes
+ data
In the top left corner you can switch your perspective from Android to Project to see all your project structure:
Is it possible to specify the package path for R.class ?
The R class package is using the package path specified in the AndroidManifest.xml
The reason I ask that because I am trying to deploy the same codebase to different application.
The difference between the apps will be the image and text. while code logic remain the same.
To deploy the same code to multiple apps require unique package name for each app in the AndroidManifest.xml.
The problem is when the package name change, R is regenerated. All java file import for R is invalid with the outdated package. And I have to modify each java file for the R.class import. If I can specify a common path for R. This problem will be solved.
You no need to go every screen to change import com.packagename.R.
1) press ctrl+h
2) Select "File Search" tab and enter your old packagename to search
3) Press "Replace" button
4) Give your new package name to replace with.
5) Clean build and enjoy.
If your using Linux machine single command do a trick
find yourprojectpath -type f -exec sed -i 's/com.oldpackage.name/com.new.packagename/g' {} \\;
I have started working on android just 1 month back (so please consider my question even if it looks simple). I have my Bluetooth code running on Android 2.2. So I am working on using backport-android-bluetooth to migrate it to Android 1.6 (as I have some old pads with 1.6).
I came across foll. link: http://code.google.com/p/backport-android-bluetooth/
I have queries regarding point no. 1 and 2 under 'Install' which are as follows:
1. download backport-android-bluetooth2.jar, and put into your projects's reference libraries. - Where is exactly 'projects' reference library'? How to put .jar file in that 'reference library
2. put backport_android_bluetooth.properties in to your src directory. -Is this file to be put in 'src' folder or '*Project_Name*' folder like project.properties file?
Thanks in advance.
Put a new file into your src dir,named backport_android_bluetooth.properties
and then put the code below in it:
#permission_name = ${your package name).PERMISSION_BLUETOOTH
permission_name = com.example.bluetooth.PERMISSION_BLUETOOTH
#request_enable = ${your package name}.action.REQUEST_ENABLE
request_enable = com.example.bluetooth.action.REQUEST_ENABLE
#request_discoverable = ${your package name}.action.REQUEST_DISCOVERABLE
request_discoverable = com.example.bluetooth.action.REQUEST_DISCOVERABLE
if u r using eclipse than right click on ur project New/Folder,
give folder name as libs and copy & paste android-bluetooth2.jar in libs folder.
than right click on libs folder go to Build Path/ Configure Build Path
Click on Add Jar, select your project/libs/android-bluetooth2.jar
press ok