How to generate an .apk file from Xamarin.Forms Project
Issue in generating .APK file in Xmarin forms
OS:Windows 10
Tools:Microsoft Visual Studio Enterprise 2022 (64 位) 版本 17.0.2
Step 1:Create a new Xamarin.Forms project with default project template
Try The Following Steps:
Go to Solution Explorer -> Android project (right click) --> Archive --> Distribute -- AdHoc --> Sign & Add Details --> Save As
Step 2:Prepare you application before generate an .apk file
Three Condition like below:
Compile-Rebuild your project.-Select Build > Rebuild Solution to verify that it builds successfully in Release mode. this step does not yet produce an APK.
Step 3:generate an .apk file
Step 3.1:Archive
Archive -Go to Solution Explorer -> Android project (right click) --> Archive --> Distribute -- AdHoc --> Sign & Add Details --> Save As
this step produce an com.companyname.androidappformassharetarget.apk. in path:
this step produce an APK.( sign not included)
Step 3.2: Distribute
this step produce an APK(sign not included)
Archive -Go to Solution Explorer -> Android project (right click) --> Archive --> Distribute -- AdHoc --> Sign & Add Details --> Save As
3.2.1 file apk on disk:
this step produce an APK(sign included)
Archive -Go to Solution Explorer -> Android project (right click) --> Archive --> Distribute -- AdHoc --> Sign & Add Details --> Save As
or
3.2.1 play store:
The APK is Ready To Publish in Play Store
Detail
step 1:Change Your Project Mode from debug to release.
To change the build configuration, either:
From the Build menu, select Configuration Manager, then select Debug or Release.
or
On the toolbar, choose either Debug or Release from the Solution Configurations list.
AndroidAppFormAsShareTarget.csproj
Office doc:How to Set debug and release configurations in Visual Studio 22 Step by Step?
step 2: Archive
this step produce an APK.
right click your Android project and select "Archive..."
Step 3:Distribute
Step 4:AdHoc
Step 5:Sign
要执行这一步,是因为:
Android 系统要求安装的每个应用都必须使用应用开发者拥有的证书(即开发者用于存放私钥的证书)进行数字签名。
Android 系统利用该证书来识别应用作者并在应用之间建立信任关系。您用于签名的的证书无需由证书授权机构签名;
Android 系统允许您使用自签名证书为您的应用签名。
Step 6:Save As
F:\stock\ReadDZHRealTime\src\WinForm\AndroidApp\bin\Release
Issue in generating .APK file in Xmarin forms
Archive error
1.obj\Release\110\android\assets contains Java.Interop.dll but no debug symbols file was found.
s:
vs 2022 Right click on Project>Properties
Go to Android Options > Debugging Options. UNCKECK the Enable Developer Instrumentation box.
old
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
</PropertyGroup>
new
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>