Change default package from com.example for Eclipse Android projects - android

I am using Eclipse 4.2 with Android SDK.
I am wondering if it is possible to change the default package ID com.example that shows in the "New Android Application" wizard as you type the application name?
I would like it to default to my own package ID so that I don't need to correct the Package Name field each time.
Is this possible to do? Please explain how.

No, you cannot change the default; it's hardcoded in the plugin sources.
(For the curious, it's in com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectPage#SAMPLE_PACKAGE_PREFIX in the ADT code base). We should consider persisting the most recently set package prefix and inserting the parent package next time. Feel free to file an issue for that at http://b.android.com category Component-Tools.
-- Tor

With Android Studio not running, edit the file: C:\Users\MyAccount\.AndroidStudio\config\options\options.xml (replace C: with the installation drive and MyAccount with your account name).
Within the xml file look for "property name="SAVED_COMPANY_DOMAIN" value=" and change the value to what you want.

Following user2232952's guidance, for new versions of Android Studio change the value of:
<property name = "SAVED_ANDROID_PACKAGE" value = "com.example" />

I'm not sure why so many people have right answers with wrong file location...
I've installed android studio 2020.3 with all default settings and the file others.xml is in folder
C:\Users\MYUSER\AppData\Roaming\Google\AndroidStudio2020.3\options

For anyone coming here in 2020, the file you are looking for is other.xml
It can be found in your AndroidStudio library under config/options/other.xml
(For mac this is probably ~/Library/Application Support/Google/AndroidStudio4.1/options)
Then you can follow the instructions by #Murillo Comino
<property name = "SAVED_ANDROID_PACKAGE" value = "com.example" />
EDIT:
As per #Douglas Kazumi 's comment, it is important that AS will be closed while editing this.

If you've already created your project, you could go to your AndroidManifest.xml file and update the attribute in the Manifest (root) tag
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name"
android:versionCode="1"
android:versionName="1.0" >
Just make sure the rest of your code also reflects this change.

Click the package name and hit Alt+Shift+R and Rename, it will update everything!

Related

App on Play store. Changed package name in Java. What part of Manifest needs old package name?

I released an app on Play store a few years ago.
The package name was com.X.Y.appName
This week, I found the old source code and got it all working in Android Studio 14.
I did not like the package name for my Java code to be com.X.Y.appName
So, I changed the Java code to com.Z.appName
The Java code was fine with that, and everything runs fine in the emulator testing.
However, I now want to release the new version in the Play store.
So, how do I release this new project that is recoded as package com.Z.appName to be released as an update to com.X.Y.appName ?
The manifest.xml file references the package twice
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Z.appName">
and
<activity android:name="com.Z.appName.MainActivity">
Which of these needs to remain in the original package name to keep this App release to be considered an update, and not a brand new app ?
I tried to revert the first package name under the manifest tag back to com.X.Y.appName, and my code would no longer compile. I am now getting "error: package R does not exist". So, I put it back to com.Z.appName.
If I change the 2nd one in the activity tag, the code turns red, and I get "Class not found" error.
So, how do I release this new project that is recoded as package com.Z.appName to be released as an update to com.X.Y.appName ?
Do I leave the 2 entries above in manifest.XML to retain the new package name of com.Z.appName, but revert to the original com.X.Y.appName somewhere else entirely?
Build. Gradle?
I think I found a way. Does this seem correct?
I changed the manifest to the original package name
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.X.Y.appName">
Then I added this in MainActivity.java
import com.X.Y.appName.R;
The project now compiles and works, and the manifest has the old project name.
Do I need to edit build.gradle as well ?
Currently, it shows the new package name
defaultConfig {
applicationId "com.Z.appName"

How can I change the app display name build with Flutter?

I have created the app using Flutter create testapp.
Now, I want to change the app name from "testapp" to "My Trips Tracker". How can I do that?
I have tried changing from the AndroidManifest.xml, and it got changed, but is there a way that Flutter provides to do that?
Android
Open AndroidManifest.xml (located at android/app/src/main)
<application
android:label="App Name" ...> // Your app name here
iOS
Open info.plist (located at ios/Runner)
<key>CFBundleDisplayName</key>
<string>App Name</string> // Your app name here
and/or
Don't forget to stop and run the app again.
UPDATE: From the comments this answer seems to be out of date
The Flutter documentation points out where you can change the display name of your application for both Android and iOS. This may be what you are looking for:
Preparing an Android App for Release
Preparing an iOS App for Release
For Android
It seems you have already found this in the AndroidManifest.xml as the application entry.
Review the default App Manifest file AndroidManifest.xml located in
/android/app/src/main/ and verify the values are correct,
especially:
application: Edit the android:label in the application tag to reflect the final name of the
app.
For iOS
See the Review Xcode project settings section:
Navigate to your target’s settings in Xcode:
In Xcode, open Runner.xcworkspace in your app’s ios folder.
To view your app’s settings, select the Runner project in the Xcode project
navigator. Then, in the main view sidebar, select the Runner target.
Select the General tab. Next, you’ll verify the most important
settings:
Display Name: the name of the app to be displayed on the home screen
and elsewhere.
There is a plugin called flutter_launcher_name.
Write file pubspec.yaml:
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
And run:
flutter pub get
flutter pub run flutter_launcher_name:main
You can get the same result as editing AndroidManifest.xml and Info.plist.
You can change it in iOS without opening Xcode by editing the project/ios/Runner/info.plist <key>CFBundleDisplayName</key> to the String that you want as your name.
FWIW - I was getting frustrated with making changes in Xcode and Flutter, so I started committing all changes before opening Xcode, so I could see where the changes show up in the Flutter project.
Review the default app manifest file, AndroidManifest.xml, located in <app dir>/android/app/src/main
Edit the android:label to your desired display name
There are several possibilities:
1- The use of a package:
I suggest you to use flutter_launcher_name because of the command-line tool which simplifies the task of updating your Flutter app's launcher name.
Usage:
Add your Flutter Launcher name configuration to your pubspec.yaml file:
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
After setting up the configuration, all that is left to do is run the package.
flutter pub get
flutter pub run flutter_launcher_name:main
If you use this package, you don't need modify file AndroidManifest.xml or Info.plist.
2- Edit AndroidManifest.xml for Android and info.plist for iOS
For Android, edit only android:label value in the application tag in file AndroidManifest.xml located in the folder: android/app/src/main
Code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Your Application Name" //here
android:icon="#mipmap/ic_launcher">
<activity>
<!-- -->
</activity>
</application>
</manifest>
Screenshot:
For iOS, edit only the value inside the String tag in file Info.plist located in the folder ios/Runner .
Code:
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Your Application Name </string> //here
</dict>
</plist>
Screenshot:
Do a flutter clean and restart your application if you have a problem.
A few of the answers here suggest using the package flutter_launcher_name, but this package is no longer being maintained and will result in dependency issues within new Flutter 2.0 projects.
The plugin flutter_app_name (https://pub.dev/packages/flutter_app_name) is a nearly identical package that has sound null safety and will work with Flutter 2.0.
Set your dev dependencies and your app's name
dev_dependencies:
flutter_app_name: ^0.1.1
flutter_app_name:
name: "My Cool App"
Run flutter_app_name in your project's directory
flutter pub get
flutter pub run flutter_app_name
Your launcher will now have the name of "My Cool App".
You can change it in iOS without opening Xcode by editing file *project/ios/Runner/info.plist. Set <key>CFBundleDisplayName</key> to the string that you want as your name.
For Android, change the app name from the Android folder, in the AndroidManifest.xml file, android/app/src/main. Let the android label refer to the name you prefer, for example,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
android:label="test"
// The rest of the code
</application>
</manifest>
You can change the Application name, by updating the name for both Android and iOS
for Android
just open AndroidManifest.xml file by,
go to inside android>app>src>main>AndroidManifest.xml
like this:-
so my application name is a "demo" so, I will update the label value.
same as for iOS
just open Info.plist file by,
go to inside ios>Runner>Info.plist
like this:-
And change this string value.
One problem is that in iOS Settings (iOS 12.x) if you change the Display Name, it leaves the app name and icon in iOS Settings as the old version.
For Android, change the app name from the Android folder. In the AndroidManifest.xml file, in folder android/app/src/main, let the android label refer to the name you prefer, for example,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<application
`android:label="myappname"`
// The rest of the code
</application>
</manifest>
You can easily do this with rename package, It helps you to change your Flutter project's AppName and BundleId for different platforms, currently available for IOS, Android, macOS and Web
To install the package run the following command:
pub global activate rename
To rename the App, use the following command:
pub global run rename --appname "Your App Name"
That's It!
You can check the documentation of the package for full details because it has some nice features to choose the target platform and more.
As of 2019-12-21, you need to change the name [NameOfYourApp] in file pubspec.yaml. Then go to menu Edit → Find → Replace in Path, and replace all occurrences of your previous name.
Also, just for good measure, change the folder names in your android directory, e.g. android/app/src/main/java/com/example/yourappname.
Then in the console, in your app's root directory, run
flutter clean
in case you are releasing for multi-localizations (languages).
for Android:
in your app folder at
[appname]\android\app\src\main\res
add locale folders for example:
values-ar
valuse-en
then inside each folder add a new strings.xml that contains the app name in that language.
for ar
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">ادارة الديون</string>
</resources>
for en
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">debt management</string>
</resources>
The last thing you can do is go to your AndroidManifest.xml file
and set the android:label to the new files you have created.
android:label="#string/app_name"
I saw indeed the manual solution (to go to IOS and Android). But I found out a plugin which enables changing name from one single location:
https://pub.dev/packages/flutter_launcher_name
Just do the following:
Add to pubspec.yaml
dev_dependencies:
flutter_launcher_name: "^0.0.1"
flutter_launcher_name:
name: "yourNewAppLauncherName"
Run in Terminal:
flutter pub get
flutter pub run flutter_launcher_name:main
Done.
First
Rename your AndroidManifest.xml file
android:label="Your App Name"
Second
Rename Your Application Name in Pubspec.yaml file
name: Your Application Name
Third
Change Your Application logo
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/path/your Application logo.formate"
Fourth
Run
flutter pub pub run flutter_launcher_icons:main
If you like to automate stuff from command line like me, you can use this
appName="TestApp"
declare -a androidAppTypes=(
"main"
"debug"
"profile"
)
# Change app name for Android
for appType in ${androidAppTypes[#]}
do
xmlstarlet ed -L -u '/manifest/application/#android:label' -v "$appName" android/app/src/$appType/AndroidManifest.xml
done
# Change app name for Android
plutil -replace CFBundleDisplayName -string "$appName" ios/Runner/Info.plist
The way of changing the name for iOS and Android is clearly mentioned in the documentation as follows:
Build and release an Android app
Build and release an iOS app
But, the case of iOS after you change the Display Name from Xcode, you are not able to run the application in the Flutter way, like flutter run.
Because the Flutter run expects the app name as Runner. Even if you change the name in Xcode, it doesn't work.
So, I fixed this as follows:
Move to the location on your Flutter project, ios/Runner.xcodeproj/project.pbxproj, and find and replace all instances of your new name with Runner.
Then everything should work in the flutter run way.
But don't forget to change the name display name on your next release time. Otherwise, the App Store rejects your name.

cordova_plugin_file_chooser not working in same device for two different apps

I am using cordova cli for creating android app.
I have user cordova_plugin_file_chooser
Where it given that below
Note that like a ContentProvider, the DocumentProvider authority must be unique. You should change com.ianhanniballake.localstorage.documents in your Manifest, as well as the LocalStorageProvider.AUTHORITY field.
By above I have update in my AndroidManifest by changing android:authorities="com.crypho.localstorage.documents" to com.12345.localstorate.documents but when I build app using cordova build android it added new instance in manifest file with existing name android:authorities="com.crypho.localstorage.documents"
Can anybody know where should I changed in the code exactly?
UPDATE:
Still not resolved the issue of provider name confict.
I resolved issue by replacing provider authorities by ${applicationID}.Provider in <provider> of that specific plugin in android.json file.
Thanks

Application is not Registered in react native

I have a react native application and I changed the package name of the application using https://www.npmjs.com/package/react-native-rename. After that I tried to run the project but its saying that the application is not registered. I have tried the following steps also.
Opened the project in android studio and make sure that the package name is changed and all the files are also in the same package name.
Tried cleaning the old gradle files.
Uninstalled the previously installed version of the app (The one which have the original package name.
Any help would be appreciated. Thanks in advance
You need to check 2 files to make sure you have equal names there:
index.js -> application name in the last line:
AppRegistry.registerComponent('YourAppName', () => App);
app.json -> name property
In both places names should be equal (case sensitive).
Have you changed the values ​​in the index.ios.js, index.android.js and app.json files?
There are some instructions here.
android\app\src\main\java\com{someFolderName}\MainActivity.java
you landed up on this answer because still you are not able to solve the issue
open the file mentioned in above in title
this used for
Returns the name of the main component registered from JavaScript.
This is used to schedule rendering of the component.
look for method
#Override
protected String getMainComponentName() {
return "AddYourNewNameHere";
}
which might be returning a hard coded string replace it to desired name!!
EXTENDED TIP
ensure you clean your gradle demon as the project does not compile sometimes
for that use following
cd android
gradlew clean

new blackberry app world error "bar manifest file package version must be greater than ..."

I've started getting a weird error message when trying to upload a playbook app update to BlackBerry world. I think this problem started after installing version 1.6.1 of their eclipse plugin.
The error message:
"The package version in your .bar manifest file for signals_playbook must be greater than the previous version, but lower than any the next release version added to the vendor portal. . Your .bar manifest file package version must be greater than 3.0. Correct your .bar manifest file and try again to continue."
My AndroidManifest.xml contains:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ca.rcp.mobile.cror.signals"
android:versionCode="7"
android:versionName="3.1" >
The Manifest file contained within the BAR shows this info:
Archive-Manifest-Version: 1.1
Archive-Created-By: Apk2Bar version 1.6.1
Package-Author: xxxxxxxx
Package-Author-Id: some hash xxxxxxxxx
Package-Name: xxxxx.cror.signals
Package-Id: some hash xxxxxxxxx
Package-Version: 1.0.7.1
Package-Version-Id: some hash xxxxxxxx
Package-Type: application
Package-Architecture: armle-v7
Package-Author-Certificate-Hash: some hash xxxxx
Application-Name: Railway Signals
Application-Id: some hash xxxxxxxx
Application-Version: 1.0.7.1
Application-Version-Id: some hash xxxxxxxxxxx
Application-Requires-System: Tablet OS/2.0.0.7109
My system:
Windows 7 x64 using Eclipse 3.7.2 with latest ADT and updates.
I can see why BlackBerry world is complaining, it thinks the version number is 1.0.7.1. How do I get it to show 3.1.0.0??
I tried editing the manifest file contained within the bar, saving it and resubmitting. But that didn't work (didn't think it would but was worth a try).
Does anyone know where is the 1.0.7.1 coming from?
Can I override it?
Thanks
Rob
We suddenly started having the same problem with our builds. Evidently something changed in the BlackBerry build tools. Try setting the application's android:versionName attribute to a 4-part value (such as 3.1.0.1). BlackBerry has always used this format (major.minor.micro.build) for native apps. It seems that unless your Android manifest has the same format, the BlackBerry build tools fail to parse the versionName attribute and use a fall-back. From what I can tell, the fall-back is to use the value of android:versionCode as the micro version in a default application version code; that is it sets the app version in the .bar file manifest to
1.0.<android:versionCode value>.1
(I sure wouldn't want to be the engineer that had to defend implementing this behavior.)
An alternative approach is to create a custom manifest file that has the app version you want. Create a file named MANIFEST.MF in the same directory as AndroidManifest.xml. Then add the specific .bar manifest entries you want. For instance, it might be:
Archive-Manifest-Version: 1.1
Package-Version: 3.1.0.0
Application-Version: 3.1.0.0
Then open the project properties in Eclipse, navigate to BlackBerry, and for the "Custom BAR Manifest" drop-down, select "Add custom values (merge)".
Thank you, Ted!
There is another link on this topic;
http://supportforums.blackberry.com/t5/BlackBerry-World-Development/The-package-version-in-your-bar-manifest-file-for-New-Bundle/td-p/2754567
We started to notice problem after move to Gradle:
Before
AndroidManifest.xml:
android:versionCode="1312310309" android:versionName="2.28.4"
MANIFEST.MF:
Application-Version: 14.1231.309.0
After
AndroidManifest.xml:
android:versionCode="134" android:versionName="2.30.31402271059"
MANIFEST.MF
Application-Version: 1.0.134.0
I also had the same problem but I fixed it by adding this line in my Android Manifest file android:versionCode="30" previously I had android:versionCode="29" so upgraded it by one .And the problem got fixed for me.

Categories

Resources