"java.exe" exited with code 1 Xamarin-forms

abanoub adly 41 Reputation points

I'm developing an app using xamarin-forms.

I faced this error lately after using the Google Play Services Plugin version = 116.0.1.

I know there is a thousand answers to my question but i've tried several thing before posting my own.

1- enabling multi-dex + dex compiler = d8 + code shrinker = r8

2- increasing java max heap size = 1G

3- downgrading GooglePlaySerivec to version 71.1610.4

4- updating the java JDK

6- adding this package reference into the Android.csproj

<!--New properties-->
7- i saw an answer to this error Xamarin.Forms "java.exe" exited with code 1 in debug mode , i don't know if it can be related to my problem but i tried it any way, adding this line in Android.csproj

<PackageReference Include="Xamarin.Google.Guava" ExcludeAssets="all">
8- removing the obj and bin folder and clean and rebuild

9- i made sure the encoding of Android.csproj file is utf-8

but all of this didn't help me to get rid of the error.

NOTE sometimes the project builds successfully, but I get another error,


i think it's due to the shrinker removing the FCM Methods

here is the log

[FirebaseApp] com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.  
[FirebaseApp] com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.  
[FirebaseApp] com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.  
[FirebaseInitProvider] FirebaseApp initialization successful  
[.realestatedem] Accessing hidden method Ljava/util/HashMap$HashIterator;->hasNext()Z (light greylist, JNI)  
**Java.Lang.NoSuchMethodError:** 'no static method "Lcom/google/firebase/messaging/FirebaseMessaging;.getInstance()Lcom/google/firebase/messaging/FirebaseMessaging;"'  

[.realestatedem] ProcessProfilingInfo new_methods=247 is saved saved_to_disk=1 resolve_classes_delay=8000  

I've been working on this error for a week now and I've tried many things desperately, and I don't even have a clue so if anyone can help me with this it'll be really appreciated.

thanks in advance.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,015 questions
{count} votes