Since 2-3 hours my project does not allow me anymore to export a signed APK because of that error.
I have set a package name (I'm working on this project since a week) and suddenly stopped working after I created a new emulator device, I've done nothing apart creating a new device.
If I run the app in debug mode works as expected
[EDIT]
I've found the issue, looks like the problem is related to the project path name being too long, seriously?!
I don't want to change my default folder where I save all my projects based on which type of tool I'm developing.
Anyway, I've tested it, I created a new solution in the root folder of my D: partition and inserted all the files from my original solution, tried to use 'Archive all' and worked
This error helped me to understand the problem:
Failed to generate Java type for class: Google.Android.Material.BottomNavigation.BottomNavigationView/IOnNavigationItemReselectedListenerImplementor due to System.IO.PathTooLongException
Now the question is: How I can keep my original folder?
[ORIGINAL]
I've also created a new project but the problem persists... I'm out of idea about what could be
This is the log generated when manually using MSBuild
_ResolveAndroidSigningKey:
Creating "obj\Release\100\android_debug_keystore.flag" because "AlwaysCreate" was specified.
_Sign:
D:\Android\android-sdk\build-tools\29.0.2\zipalign.exe -p 4 "D:\Software Development\Visual Studio\C#\Mobile\Android\
CGSJDSportsNotification\CGSJDSportsNotification.Android\obj\Release\100\android\bin\com.mutu_adi_marian.cgs_jdsportsn
otification.apk" "bin\Release\\com.mutu_adi_marian.cgs_jdsportsnotification-Signed.apk"
C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar D:\Android\android-sdk\build-tools\29.
0.2\lib\apksigner.jar sign --ks "C:\Users\mutua\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass
:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 25 --max-sdk-version 29 "D:\Softwa
re Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification.Android\bin\Release\co
m.mutu_adi_marian.cgs_jdsportsnotification-Signed.apk"
Signed android package 'bin\Release\com.mutu_adi_marian.cgs_jdsportsnotification-Signed.apk'
Done Building Project "D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotif
ication.Android\CGSJDSportsNotification.Android.csproj" (SignAndroidPackage target(s)).
Project "D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification.sln" (
1:2) is building "D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotificati
on\CGSJDSportsNotification.csproj" (3:11) on node 1 (SignAndroidPackage target(s)).
D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification\CGSJDSportsNoti
fication.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.
Done Building Project "D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotif
ication\CGSJDSportsNotification.csproj" (SignAndroidPackage target(s)) -- FAILED.
Done Building Project "D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotif
ication.sln" (SignAndroidPackage target(s)) -- FAILED.
Build FAILED.
"D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification.sln" (SignAndr
oidPackage target) (1:2) ->
"D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification\CGSJDSportsNot
ification.csproj" (SignAndroidPackage target) (3:11) ->
D:\Software Development\Visual Studio\C#\Mobile\Android\CGSJDSportsNotification\CGSJDSportsNotification\CGSJDSportsNo
tification.csproj : error MSB4057: The target "SignAndroidPackage" does not exist in the project.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:09.02
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.mutu_adi_marian.cgs_jdsportsnotification" android:installLocation="auto">
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="29" />
<application android:label="CGSJDSportsNotification.Android" android:icon="@drawable/appIcon"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
</manifest>
Below the solution:
First of all be sure to have EnableLongPaths set to 1 into the
registry (I already had this to 1)
Open your <project_name>.csproj and <project_name>.Android.csproj file with Notepad++ or even Windows Notepad and firstly try only with this line
<PropertyGroup>
<UseShortFileNames>True</UseShortFileNames>
</PropertyGroup>
Delete the bin and obj folder from <project_name>.csproj and <project_name>.Android.csproj, open the solution and try to use 'Archive all', if still does not work close the solution, reopen the files and add also this line
<PropertyGroup>
<IntermediateOutputPath>SHORTEN_FOLDER: I still used my main prject folder but in the root I created a .in folder</IntermediateOutputPath>
</PropertyGroup>
Delete the bin and obj folder from <project_name>.csproj and <project_name>.Android.csproj, open the solution and try to use 'Archive all'.
At this point Visual Studio still complained about the Archive Path being too long, so I just moved my Archive folder to a shorten path and this fixed the issue.
(To change the Archive path go to Tools>Options>Xamarin>Archives location)
I hope this will help you as well, maybe a second option that can solve this issue (because before creating a new device everything was working fine) is to reinstall Visual Studio (definitely not a valid option for me)