you already have an app with that package name - flutter

I need help with flutter and firebase package name
I’m trying to add 3 android apps that are using the same backend server to firebase, I have managed to add 1 app and when I try to add the second one I’m getting this notification “ you already have an app with that package name” that is in firebase.
how do i go about it?
with the solutions I have found, I have to rename the 2nd and 3rd package name, but I don't seem to understand why I should that or the concept behind it.

You need to use a different package name "com...XXX" in every project it's like your app's unique id.
you can change app name by following this steps
Step 1
Go to file android/app/buil.gradle in your flutter project
android{
//make sure every project has different application ID
defaultConfig {
applicationId "com.example.xyz" //change here
}
}
Step 2:
run commands
flutter clean
flutter pub get
flutter run
Step 3
Remove your old project from firebase and reconnect your new name project

Related

Android Studio not creating main.dart file

I'm new to programming so please be genetle. I'm handy with computers though and I've been sitting on this problem for a few weeks while learning flutter and dart
When I create a new flutter application in android studio, it does not create a main.dart file - the libs foder is empty, and I also see no IOS folder. In fact, what I see looks VERY different from any tutorials I've seen !!
What I do see is a bunh of .xml files, including one called activity main which runs a main activity function which almost seems like it is there instead of the main.dart file I'm looking for.
I have run flutter doctor, apparently everything is good.I have the dart and futter plugins installed. It is not a case of selecting "project" from the drop down menu instead of "Android" which is a common answer online. Not sure what I'm missing !!
Any help would be really really appreciated as I'm learning to code to open my next business and I am struggling to get over the first hurdle.... at leasr I am proficient wit dartpad now though :P
EDIT:
When I click on 'file > new > new flutter project', I don't see an option for "flutter application". This is what I see...
enter image description here
If I create a flutter project at this point, this is what Android Studio looks like for me...
enter image description here
If you have properly created a Flutter project in Android studio, main.dart file should be very easy to locate. It is located in project_name -> lib -> main.dart, as follows:
I am sharing steps to create flutter project in android studio :
Step 1: Open the IDE and select Start a new Flutter project.
Step 2: Select the Flutter Application as the project type. Then click Next.
Step 3: Verify the Flutter SDK path specifies the SDK’s location (select Install SDK… if the text field is blank).
Step 4: Enter a project name (for example, myapp). Then click Next.
Step 5: Click Finish.
Step 6: Wait for Android Studio to install the SDK and create the project.
Note: When creating a new Flutter app, some Flutter IDE plugins ask for a company domain name in reverse order, something like com.example. The company domain name and project name are used together as the package name for Android (the Bundle ID for iOS) when the app is released. If you think that the app might be released, it’s better to specify the package name now. The package name can’t be changed once the app is released, so make the name unique.
The above steps create a Flutter project directory called flutter_app that contains a simple demo app that uses Material Components.
Running the application:
Follow the below steps to run the flutter application that was structured above:
Step 1: Locate the main Android Studio toolbar:
Step 2: In the target selector, select an Android device for running the app. If none are listed as available, select Tools> Android > AVD Manager and create one there. For details, see Managing AVDs.
Step 3: Click the run icon in the toolbar, or invoke the menu item Run > Run.
After the app build completes, you’ll see the starter app on your device.
as per screen shot shared by you click on flutter , hopefully this will create a new flutter project.

flutter build web doesn't create flutter.js

I recently made a flutter application and now I want to get a web release, but when I run flutter build web and upload stored files in {root}/build/web on the host, everything is showing on chrome and firefox with that URL is an empty page with 2 console errors:
_flutter is not defined
GET https://web.pushers.ir/flutter.js 404
I took a look at my released files and didn't see any file named flutter.js, I tried flutter build web many times but nothing, also I tried to create another flutter project as a sample and ran flutter web build, on that sample everything was ok and flutter.js created with other released files
What should I do?
notice: it's working with Microsoft Edge, even while there is no file named flutter.js
Had the same issue.
Long story short: run flutter clean instead of manually deleting the /build/web folder or its content. The next build that follows will properly generate all files, including flutter.js.
More info why that is happening
I just copied flutter.js from a sample project release into my app release and it works

Why app overriding after installing in android?

I build an app using flutter. For example name is ForSaudi. I wanted to copy the same app and which name should be ForJordon.
So ForSaudi is already installed in my mobile. Everything is good. Now I changed the name to ForJordon from AndroidManifest.xml file. After changing name and launcher icon, I installed the app into mobile, which is actually replaced with my previous app. It should not be replaced. Can someone guide me how can I do that? I would really appreciate.
Only changing name doesn't create new package. You also need to make changes in build.gradle and in your MainActivity.kt.
If you want a simple solution. Directly use this package
and run this command
flutter pub run change_app_package_name:main com.new.package.name

How to change uploader of flutter package

I have uploaded a package with an email and then I changed to another email. So in order to replace email I've added by using pub uploader add yyyy#gmail.com. and when I try to remove old email it displays the following error
pub uploader remove xxxxxxxxxxx#gmail.com
Self-removal is not allowed. Use another account to remove this email address.
for this issue I searched to fix and found deleted .pub_cache/credentials.json will resolve but I cannot found that file in .pub-cache directory. I want to how to remove old email.
I found answer by myself. Since there is no options like select uploader or logout pub authentication, we need revoke authentication in google. So that while publishing the package it will ask for authentication and that time we can provide new email. Let me explain all these.
First I uploaded a package to pub.dev by using xxxxx#gmail.com but I want to change to yyyyy#gmail.com. So inorder to do this, we have to add yyyyy#gmail.com to the package first. To do that
pub uploader add yyyyy#gmail.com
After adding in web browser go to my
account.google.com -> security -> manage third party access -> remove pub.dartlang.org.
after revoking access to old account in terminal publish the package again and it will ask for authentication, now login with yyyyy#gmail.com and then type
pub uploader remove xxxxx#gmail.com
Now changed the publisher successfully.
Right now the steps you mention above are generating the following error: {"code":"MissingAuthentication","message":"authenication is required, please add authorization header."}
For an updated approach do the following:
Add the new uploader with flutter pub uploader add <new_email#email.com>
Remove the previous uploader with flutter pub uploader remove <previous_email#email.com>
Remove saved credentials using flutter pub logout or rm ~/Library/Application Support/dart/pub-credentials.json.
Finally type flutter pub publish and allow access from your navigator.
Source:
"flutter packages pub publish" fails #3037

How to reset a Hive Database in Flutter

I am playing around with the Hive Database for Flutter, and when I am trying to save an object, the documentations says about Adapters clearly:
As you can see, each field has a unique number (unique per class). These field numbers are used to identify the fields in the Hive binary format, and should not be changed once your class is in use.
So, after some refactoring, I need to change the classes and some attributes, including his numeration. After doing that obviously the database gives me error (was working perfectly before), and given that all the data from the database is dum data for testing purposes, I would like to Reser and restart a new Database form 0. I did try several things, like box.clear() or Hive.deleteFromDisk() after opening the boxes, but I am still getting an error about the Adapter attribute type does not match with another in the normal class (referencing the one before refactoring and changing the index).
How can I successfully remove all information and clean the database to start from Zero as a new install??
Thanks a lot!
Okkey, I found the answer:
The way to start the app as a new installation in the emulator is to desvnstall the app from the emulator and install it again.
Of course, if new changes to the index number in the Adapter, I would need to recreate these steps:
-Delete the adapters created
-Run flutter clean
-Delete the app from the emulator
-Create the new adapters with flutter packages pub run build_runner build
-Run the app again
Hope is useful for someone in the future :)
Ok, I see I had the same problem and I solved it in the following way:
First of all, delete the .hive and .lock files generated by hive when you first launch your application in the parent directory of your project.
Come back to modify it is what you want in your model and launch the following command:
flutter packages pub run build_runner build