如何在Xamarin Form中复制项目并构建新项目避免覆盖旧应用?
Hey there! I totally get this frustration—when you’re just starting out with Xamarin, it’s easy to run into this "app overwrite" issue. The root cause is super simple: Android uses the Application ID (also called Package Name) to tell apps apart. If your new project has the same ID as the old one, your phone thinks it’s an update and replaces the original. Let’s walk through the correct steps to copy and modify your project without this problem:
1. Copy the Entire Project Folder First
- Locate your original project’s folder on your computer. Right-click it, select "Copy", then paste it into a new location. Give this new folder a distinct name (e.g., if your old app was
PetTracker, name the new oneFitnessLogger). - Open Visual Studio, go to
File > Open > Project/Solution, and select the.slnfile inside your new project folder.
2. Rename the Project (Optional but Recommended)
- In the Solution Explorer, right-click your project name and choose
Rename. Type in your new app’s name. When Visual Studio asks if you want to rename all references, click Yes—this updates all internal links to match the new name.
3. Fix the Core Issue: Change the Android Application ID
This is the most important step to prevent overwriting:
- Right-click your Android project and select
Properties. - Switch to the Android Manifest tab.
- Find the
Package namefield (it looks likecom.yourcompany.youroldapp). Edit this to a unique value for your new app (e.g.,com.yourcompany.yournewapp). - Pro tip: You can also verify this in the Android Options > Packaging tab—look for the
Application IDfield, it should match what you set in the manifest.
4. Update Other App Identifiers (For Full Distinction)
- Still in the
Android Manifesttab, update theApplication nameto your new app’s display name (this is what shows up on your phone’s home screen). - Replace the app icons in the
Resources/drawable(and other density folders likedrawable-hdpi) with new ones—this makes it easy to tell the two apps apart at a glance.
5. Clean & Rebuild the Solution
- Head to the top menu:
Build > Clean Solution, thenBuild > Rebuild Solution. This ensures all your changes are applied and there are no leftover cached files from the old project.
6. Deploy & Test
Now when you deploy the new app to your Android phone, it’ll install as a separate app instead of replacing the old one!
Quick Troubleshooting Tip
If you still run into issues, check your Properties/AssemblyInfo.cs file. Update the AssemblyName and AssemblyTitle fields to match your new app’s name—this ensures every part of your project is uniquely identified.
内容的提问来源于stack exchange,提问作者King Tin

