Trying to implement the chat from this example but I keep getting
java.lang.IllegalArgumentException: couldn't make a guess for PACKAGE.databinding.ActivityChatBindingImpl
(not mentioning the package name, not necessary I believe)
Activity is called ChatActivity and XML (layout) file is "activity_chat.xml", exactly the same as from example so I don't need to post code here. I enabled databinding inside gradle file and tried putting the
android.databinding.enableV2=false
but this doesn't resolve the issue. What can be the issue here?
Also, looking at the DataBindingUtil.java class, I see that "DataBinderMapperImpl" is not generated for some reason.
For anyone out there having this issue, the only thing that helped is I had to change the package name, since mine was for example: "com.example.Example" and I changed it to all lowercase and that fixed the issue. However I did not change the "applicationId" (only folder names) therefore app does not need to be uploaded under the different package name again.
I am trying to rename my eclipse android project. I have tried Android Tools -> Rename Application Package. It gave me an error occurred see log.
I can't find any logs and suddenly this happen my project structure shows some blank and garbage packages as shown in picture.I tried deleting it but deleting them deletes my source code too.Any idea will be very helpful..
You can rename classes, packages and projects by right clicking on the class/package/project and choose: Refactor -> Rename. Check the Update references box to make sure all references to the project/class are also changed.
This behavior is totally ok.
A java package corresponds with an folder.
When a package/folder is empty eclipse will show it as "white boxed" without content (no arrow).
Example:
The class "AClass" in "com.me.pckg" corrensponds with
com/me/pckg/AClass.java
This means folder "com" and "me" contains no files. Eclipse represents this a "white boxed" packages (com and com.me). Package "com.me.pckg" is not empty.
Aware eclipse does not show the package structure NOT as hierarchical as you expect it in a file system view.
Vice versa if you put some file/-structure in your project eclipse will show new folders a packages. This happens after a refresh or a restart of eclipse, the later may be perceived as a sudden action.
If you want to change the type in "com.demo.alaramdemo" use Pieter12345 answer(, or just change the name of the folder in the file system)
If you want a more file system like view within eclipse use the "Navigator"-View
Finally i got the answer to this, With the help of a post above by Stefan
and a solution mentioned here on below link http://www.coderanch.com/t/105581/vc/Eclipse-hide-empty-packages
actually i had to create filters available on a inverted triangle in package explorer header.
In that u have to check filter of empty package , empty parent package etc
it worked for me.
Thanks all for the help ... :)
I modify sipdroid for my voip app in android. Everything is ok but when i change package name "org.sipdroid.sipua", i cannot register for any server (rollback to name org.sipdroid.sipua and it work fine). Awww What wrong with this name???
i faced this situation and I have a solution which as follows
In this package name "org.sipdroid.sipua" right click on and select refactor =>Rename. And then go to manifest and edit this package name "org.sipdroid.sipua" as "XXX.YYYYY.ZZZ". Then the package name as changed as your wish. and one thing is it will affect all your other packages. you need to change based on your changed package name.
IT IS VERY SIMPLE,please change the package name in Settings.java. YES, that's it. I am success.
private final String sharedPrefsPath = "/data/data/org.sipdroid.sipua/shared_prefs/";
change to:
private final String sharedPrefsPath = "/data/data/org.yourpackage.sipua/shared_prefs/";
It has something to do with Preference Activity used in storing the settings. If you see the files which use Preference you will have to update them with the new package name.
well i did solve the problem of changing package name of sipdroid . and i am at success..
what you have to is . Change your package name in manifest file. and all other packages in src . with same as your package name in manifest file . after that also change path of shared prefs in settings.java file . after that you need also change the package name in sipdroid.xml and at last go to prefrences.xml there is also a reference given in this file for target package change it too .. after changing all packages there comes a time for jni file . the package which names like org.sipdroid.net.impl change it too it will effect osnetworksystem.cpp file change package names on methods with underscore . now everything will fix up . clean the project and run . it will connect to servers as well as package name also changed . cheers :-)
This question already has answers here:
Rename package in Android Studio
(55 answers)
Closed 5 years ago.
Pressing Shift+F6 seems only to rename the last directory.
For example, in the project com.example.test it will offer to rename test only. The same applies if I navigate to package name in .java or Manifest file and press Shift+F6.
So is there a way to rename the package?
You can do this:
Change the package name manually in the manifest file.
Click on your R.java class and the press F6 (Refactor->Move...). It will allow you to move the class to another package, and all references to that class will be updated.
The best way to solve this is going to the AndroidManifest.xml: package="com.foocomp.fooapp:
Set the cursor on "foocomp"
Press Shift+F6
Rename Package to whatever you want
Repeat for "fooapp".
Works for me.
Also, replace in Path in Whole Project as it didn't change everything. Then Clean, Rebuild and it works --> In Android Studio / IntelliJ you should unmark "Compact Empty Middle Packages"
Eclipse:
Right click on the project > Android tools > Rename application package.
As simple as that...
In Android Studio:
open the build.gradle file > rename the applicationId under defaultConfig > synchronize
Goto your AndroidManifest.xml.
place your cursor in the package name like shown below don't select it just place it.
Then press shift+F6 you will get a popup window as shown below select
Rename package.
Enter your new name and select Refactor.
(Note since my cursor is on "something" only something is renamed.)
That's it done.
I found another solution for renaming a package in the entire project:
Open a file in the package.
IntelliJ displays the breadcrumbs of the file, above the opened file.
On the package you want renamed: Right click > Refactor > Rename.
This renames the package/directory throughout the entire project.
Deselect Hide Empty Middle Packages in Project Explorer Windows settings menu than you will be able to refactor each directory
Lets address the two use cases
**Rename a package name or Trim a package **
com.mycompany.mystupidapplicationname to com.mycompany.brandname
or
com.someothercompany.mystupidapplicationname to com.someothercompany.mystupidapplicationname
or
com.someothercompany.mystupidapplicationname to
someothercompany.brandname
Select Package in the drop down in Android Studio
Right click on the package which contains your MainActivity and refractor it
Select Rename Package and everything will work like a charm
But this will only rename the last part of package name
To rename the first or second part of package name . Create a new dummy file in the part of package which you want to rename. the file will be created inside mycompany.com.myapplicationame. Then move the file inside mycompany(right click => move) to make mycompany appear in tree view. This will make that part part of the tree view and will you help you to do a right click and rename that part.
Delete the dummy file
To Trim a package , simply right click and move the package part inside its grand parent
I found a good work around for this problem. Taking the example mentioned in the question, following are the steps for changing the package name from com.example.test to com.example2.test :
create a temporary directory, say temp inside the directory example (alongside directory test).
Go back to the Intellij project, select the folder com.example and Click Shift + F6. Now it offers to rename the text example. Here you can enter the new text you want and IntelliJ will do the rest for you.
Delete the temporary directory temp from the file system.
This idea can be used to refactor any part of the package name.
Good luck!!
This modification needs three steps :
Change the package name in the manifest
Refactor the name of your package with right click -> refactor -> rename in the tree view, then Android studio will display a window, select "rename package"
Change manually the application Id in the build.gradle file :
android / defaultconfig / application ID
Then clean / rebuild the project
Unfortunately all above didn't work for me. After having lots of trials,
What worked for me in Android Studio:
do a 'move' on the package to a new package name you want.(right
click on package and select Refactor -> Move)
If Refactor -> Move didn't work for you, then create a package with the name you want and move manually in the existing package to the new one, and then delete the old empty package.
Change package name in manifest (manually)
Have a replace for the old package name with the new package name
globally (in the full path by going to Edit -> Find -> Replace In
Path)
What I did was the following :
I simply created the package with the desired name , in the src folder , next to the current package with current name.
I dragged all contents of current package to new package , intellij popped a dialog box asking me if I want to refactor inside package references and project references to new package , I clicked 'yes' and TA-DAAA , worked like a charm.
In Android Studio 1.1, the simplest way is to open your project manifest file, then point to each part of the package name that you want to change it and press
SHIFT + F6 , then choose rename package and write the new name in the dialog box. That's all.
Most of the answers even the most voted answers didn't do the job properly, they seem to work and the builds work however, a closer look at the file structure and references will show you that not much was done. IntelliJ actually does this whole process automatically.
1) Go to Project Tab and make sure Packages is the active Tab in the drop down like so:
find your com.example package (note test as in com.example.test is not there) right-click and choose Refactor->Rename...
It will issue a warning that multiple directories... (which is actually the desired effect), click on Rename package.
Input the new package name and Refactor...
It will do searches and show you refactoring results.
Click on the Do Refactor button and it will do everything and even rename the folders and files involved... every reference is corrected to this new name.
2) Then Finally change the AndroidManifest.xml file
:)
Most of the answers even the most voted answers didn't do the job properly, they seem to work and the builds work however, a closer look at the file structure and references will show you that not much was done. IntelliJ actually does this whole process automatically.
I solved this issue by changing the directory name manually from the command line. Intellij then recognized the new package name automatically. I then had to do a search and replace for the package name in each file that imported it. This seems like an ugly workaround, but Intellij seemed unwilling to change the package name otherwise.
What I did was the following
Change manifest.
Close androidStudio
Open folder with Windows Explorer. Change folder names.
Open androidStudio, and do a search and replace.
Done!
If you want to rename full android package, this is the best way to do that:
Mark as checked - Comapct Emty Middle Packages
Right click on the packcage you want to change, and then
Refactor->Rename->Rename all
You can find video tutorial on this link:
https://www.youtube.com/watch?v=A-rITYZQj0A
In addition to #Cristian's answer above, I had to do two more steps to get it working correctly. I will sum all of it here:
Change the package name manually in the manifest file.
Click on your R.java class and the press F6 (Refactor->Move...). It will allow you to move the class to another package, and all references to that class will be updated.
Change manually the application Id in the build.gradle file : android / defaultconfig / application ID [source].
Create a new package with the desired name by right clicking on the java folder -> new -> package and select and drag all your classes to the new package. Android Studio will refactor the package name everywhere [source].
Solution 1: I changed src subfolder names, manifest file, activity headers and run/debug configuration. And still got building errors. If your project is not so big, just create a new project, copy-paste old files and change package names in headers of .java files and android manifest.
Solution 2: Inside IntelliJ 12, goto someFile.java and find your old package name
package com.myself.project2
click to which word that you want to change. Press Shift+F6.
Dialog comes, type new name.
Then goto Run/Edit configurations. Inside Launch radio button change package name to new one. It should work.
Other renaming options of IntelliJ are: http://www.jetbrains.com/idea/webhelp/rename-refactorings.html
Super simple approach:
Find R.java in the build/generated directory
Create new package directories, again under build/generated/etc
Move R.java to the newly created package.
A dialog will appear. Choose to refactor the existing code with the new package name.
Clean and Rebuild
Done!