OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

"java.exe" exited with code 1 #266

Closed benOnside closed 2 years ago

benOnside commented 2 years ago

Description: I followed the migration guide, cleared out all the errors, then get "java.exe" exited with code 1, when building android. I had the same issue when updating our azure push notifications, which was what caused us to switch to onesignal - so hopefully it can be resolved here, but I'm guessing it's something wrong with our packages. I tried enabling r8 code shrinker (proguard not supported for d8 compiler) which changed nothing. I'm guessing it's some conflict with another library, since it works fine in a sample app. Also OneSignal worked fine until the beta.

Environment Xamarin Forms 5.0.0.2244 OneSignal 4.0.0-beta1

All our packages: android project references.txt

Steps to Reproduce Issue: Add all above packages Fix all the errors created by doing so Try to build the app

jkasten2 commented 2 years ago

@benOnside Thanks for trying out the beta and reporting however we will need more details about the error to investigate. Could you share the full error message before and after ""java.exe" exited with code 1"?

benOnside commented 2 years ago

""java.exe" exited with code 1" is the beginning and end of all output and errors: image

benOnside commented 2 years ago

Xamarin.Android.txt Here's the file it is referring to. It's part of the package Xamarin.Android.CSharp.targets.

jkasten2 commented 2 years ago

@benOnside Line 79 points to this part of the file that you attached:

    <D8
        Condition=" '$(_UseR8)' != 'True' "
        ToolPath="$(JavaToolPath)"
        JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
        JavaOptions="$(JavaOptions)"
        JarPath="$(AndroidR8JarPath)"
        AndroidManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml"
        OutputDirectory="$(_AndroidIntermediateDexOutputDirectory)"
        Debug="$(AndroidIncludeDebugSymbols)"
        JavaPlatformJarPath="$(JavaPlatformJarPath)"
        ClassesZip="$(_AndroidIntermediateClassesZip)"
        JavaLibrariesToEmbed="@(_JavaLibrariesToCompileForApp);@(_InstantRunJavaReference)"
        AlternativeJarLibrariesToEmbed="@(_AlternativeJarForAppD8)"
        JavaLibrariesToReference="@(AndroidExternalJavaLibrary)"
        EnableDesugar="$(AndroidEnableDesugar)"
        ExtraArguments="$(AndroidD8ExtraArguments)"
    />

However this provide details about what the exact error is or the arguments used.

Can you copy the full log from the "Build Output". If you don't see it when the build fails check the bottom right of the visual studio window. Example: image Please copy the full text or attach as a file however instead of posting screenshot.

benOnside commented 2 years ago

@jkasten2 Sure. For reference, I've attached before and after updating to the beta (buildlog is before beta), so you know what warnings we usually have buildlog.txt oldbuildlog.txt .

jkasten2 commented 2 years ago

@benOnside Thanks but it still isn't showing us what the java error is exactly. Can you turning up build output verbosity? Example shown in this screenshot of how to do that: https://docs.microsoft.com/en-us/answers/questions/332949/error-msb6006-34javaexe34-exited-with-code-1.html

benOnside commented 2 years ago

@jkasten2 Oh I didn't know about that! Thanks, that will probably help a lot. I've attached with detailed and diagnostic levels respectively. buildlogdiagnostic.txt

buildlogdetailed.txt s

jkasten2 commented 2 years ago

@benOnside Thanks, the following section points out the D8 Java error:

4>  C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin\java.exe -Xmx1G -classpath "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Android\r8.jar" com.android.tools.r8.D8 --debug --min-api 23 --output obj\Debug_Ben\110\android\bin\ --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-30\android.jar" --lib "C:\Program Files (x86)\Android\android-sdk\platforms\android-30\optional\org.apache.http.legacy.jar" obj\Debug_Ben\110\android\bin\classes.zip "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\mono.android.jar" "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Android\java_runtime_fastdev.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Annotation.1.2.0.3\build\monoandroid90\..\..\jar\androidx.annotation.annotation.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Arch.Core.Common.2.1.0.11\build\monoandroid90\..\..\jar\androidx.arch.core.core-common.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Collection.1.1.0.10\build\monoandroid90\..\..\jar\androidx.collection.collection.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Concurrent.Futures.1.1.0.5\build\monoandroid90\..\..\jar\androidx.concurrent.concurrent-futures.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.ConstraintLayout.Core.1.0.1.2\build\monoandroid90\..\..\jar\androidx.constraintlayout.constraintlayout-core.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Lifecycle.Common.2.3.1.3\build\monoandroid90\..\..\jar\androidx.lifecycle.lifecycle-common.jar" "C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.AndroidX.Room.Common.2.3.0.4\build\monoandroid90\..\..\jar\androidx.room.room-common.jar" obj\Debug_Ben\110\androidx\jl\10f4e4df-5cd6-4016-99cf-3177ebfb05db.jar obj\Debug_Ben\110\androidx\jl\993e8c00-966a-492f-b380-5cb7fee70dca.jar obj\Debug_Ben\110\androidx\jl\a8ba8f86-021e-44ca-9116-3c0cb7e927ec.jar obj\Debug_Ben\110\androidx\jl\c14c841a-f481-473f-b8bc-ac504b69fd79.jar obj\Debug_Ben\110\androidx\jl\c72280d1-de7a-4660-b723-721896f668f4.jar obj\Debug_Ben\110\lp\116\jl\bin\classes.jar obj\Debug_Ben\110\lp\117\jl\bin\classes.jar obj\Debug_Ben\110\lp\118\jl\bin\classes.jar obj\Debug_Ben\110\lp\119\jl\bin\classes.jar obj\Debug_Ben\110\lp\120\jl\bin\classes.jar obj\Debug_Ben\110\lp\121\jl\bin\classes.jar obj\Debug_Ben\110\lp\122\jl\bin\classes.jar obj\Debug_Ben\110\lp\123\jl\bin\classes.jar obj\Debug_Ben\110\lp\124\jl\bin\classes.jar obj\Debug_Ben\110\lp\126\jl\firebase-annotations.jar obj\Debug_Ben\110\lp\127\jl\bin\classes.jar obj\Debug_Ben\110\lp\128\jl\bin\classes.jar obj\Debug_Ben\110\lp\129\jl\bin\classes.jar obj\Debug_Ben\110\lp\130\jl\bin\classes.jar obj\Debug_Ben\110\lp\131\jl\bin\classes.jar obj\Debug_Ben\110\lp\132\jl\bin\classes.jar obj\Debug_Ben\110\lp\133\jl\bin\classes.jar obj\Debug_Ben\110\lp\134\jl\bin\classes.jar obj\Debug_Ben\110\lp\135\jl\bin\classes.jar obj\Debug_Ben\110\lp\136\jl\bin\classes.jar obj\Debug_Ben\110\lp\14\jl\formsviewgroup.jar obj\Debug_Ben\110\lp\140\jl\bin\classes.jar obj\Debug_Ben\110\lp\141\jl\bin\classes.jar obj\Debug_Ben\110\lp\142\jl\bin\classes.jar obj\Debug_Ben\110\lp\144\jl\auto-value-annotations.jar obj\Debug_Ben\110\lp\145\jl\dagger.jar obj\Debug_Ben\110\lp\147\jl\bin\classes.jar obj\Debug_Ben\110\lp\148\jl\bin\classes.jar obj\Debug_Ben\110\lp\149\jl\bin\classes.jar obj\Debug_Ben\110\lp\15\jl\zxing.core.jar obj\Debug_Ben\110\lp\150\jl\bin\classes.jar obj\Debug_Ben\110\lp\151\jl\bin\classes.jar obj\Debug_Ben\110\lp\152\jl\bin\classes.jar obj\Debug_Ben\110\lp\153\jl\bin\classes.jar obj\Debug_Ben\110\lp\154\jl\bin\classes.jar obj\Debug_Ben\110\lp\155\jl\bin\classes.jar obj\Debug_Ben\110\lp\156\jl\bin\classes.jar obj\Debug_Ben\110\lp\157\jl\bin\classes.jar obj\Debug_Ben\110\lp\158\jl\bin\classes.jar obj\Debug_Ben\110\lp\159\jl\bin\classes.jar obj\Debug_Ben\110\lp\16\jl\bin\classes.jar obj\Debug_Ben\110\lp\160\jl\bin\classes.jar obj\Debug_Ben\110\lp\161\jl\bin\classes.jar obj\Debug_Ben\110\lp\162\jl\bin\classes.jar obj\Debug_Ben\110\lp\163\jl\bin\classes.jar obj\Debug_Ben\110\lp\164\jl\bin\classes.jar obj\Debug_Ben\110\lp\165\jl\bin\classes.jar obj\Debug_Ben\110\lp\166\jl\bin\classes.jar obj\Debug_Ben\110\lp\167\jl\bin\classes.jar obj\Debug_Ben\110\lp\168\jl\bin\classes.jar obj\Debug_Ben\110\lp\169\jl\javax-inject.jar obj\Debug_Ben\110\lp\175\jl\classes.jar obj\Debug_Ben\110\lp\176\jl\classes.jar obj\Debug_Ben\110\lp\177\jl\classes.jar obj\Debug_Ben\110\lp\178\jl\classes.jar obj\Debug_Ben\110\lp\179\jl\classes.jar obj\Debug_Ben\110\lp\18\jl\bin\classes.jar obj\Debug_Ben\110\lp\180\jl\classes.jar obj\Debug_Ben\110\lp\181\jl\classes.jar obj\Debug_Ben\110\lp\182\jl\classes.jar obj\Debug_Ben\110\lp\183\jl\classes.jar obj\Debug_Ben\110\lp\184\jl\classes.jar obj\Debug_Ben\110\lp\185\jl\classes.jar obj\Debug_Ben\110\lp\186\jl\classes.jar obj\Debug_Ben\110\lp\187\jl\classes.jar obj\Debug_Ben\110\lp\188\jl\classes.jar obj\Debug_Ben\110\lp\189\jl\classes.jar obj\Debug_Ben\110\lp\19\jl\bin\classes.jar obj\Debug_Ben\110\lp\190\jl\classes.jar obj\Debug_Ben\110\lp\191\jl\classes.jar obj\Debug_Ben\110\lp\192\jl\classes.jar obj\Debug_Ben\110\lp\193\jl\classes.jar obj\Debug_Ben\110\lp\194\jl\classes.jar obj\Debug_Ben\110\lp\196\jl\classes.jar obj\Debug_Ben\110\lp\197\jl\classes.jar obj\Debug_Ben\110\lp\198\jl\classes.jar obj\Debug_Ben\110\lp\199\jl\classes.jar obj\Debug_Ben\110\lp\200\jl\classes.jar obj\Debug_Ben\110\lp\201\jl\classes.jar obj\Debug_Ben\110\lp\202\jl\classes.jar obj\Debug_Ben\110\lp\203\jl\classes.jar obj\Debug_Ben\110\lp\204\jl\classes.jar obj\Debug_Ben\110\lp\205\jl\classes.jar obj\Debug_Ben\110\lp\206\jl\classes.jar obj\Debug_Ben\110\lp\207\jl\classes.jar obj\Debug_Ben\110\lp\208\jl\classes.jar obj\Debug_Ben\110\lp\209\jl\classes.jar obj\Debug_Ben\110\lp\210\jl\classes.jar obj\Debug_Ben\110\lp\211\jl\classes.jar obj\Debug_Ben\110\lp\212\jl\classes.jar obj\Debug_Ben\110\lp\213\jl\classes.jar obj\Debug_Ben\110\lp\214\jl\classes.jar obj\Debug_Ben\110\lp\215\jl\classes.jar obj\Debug_Ben\110\lp\216\jl\classes.jar obj\Debug_Ben\110\lp\217\jl\classes.jar obj\Debug_Ben\110\lp\218\jl\classes.jar obj\Debug_Ben\110\lp\219\jl\classes.jar obj\Debug_Ben\110\lp\22\jl\bin\classes.jar obj\Debug_Ben\110\lp\220\jl\classes.jar obj\Debug_Ben\110\lp\221\jl\classes.jar obj\Debug_Ben\110\lp\222\jl\classes.jar obj\Debug_Ben\110\lp\223\jl\classes.jar obj\Debug_Ben\110\lp\224\jl\classes.jar obj\Debug_Ben\110\lp\225\jl\classes.jar obj\Debug_Ben\110\lp\226\jl\classes.jar obj\Debug_Ben\110\lp\227\jl\classes.jar obj\Debug_Ben\110\lp\228\jl\classes.jar obj\Debug_Ben\110\lp\3\jl\bin\classes.jar obj\Debug_Ben\110\lp\5\jl\bin\classes.jar obj\Debug_Ben\110\lp\52\jl\bin\classes.jar obj\Debug_Ben\110\lp\53\jl\bin\classes.jar obj\Debug_Ben\110\lp\6\jl\bolts-tasks.jar 
4>  Error in obj\Debug_Ben\110\lp\131\jl\bin\classes.jar:com/google/android/gms/internal/firebase_messaging/zza.class:
4>  Type com.google.android.gms.internal.firebase_messaging.zza is defined multiple times: obj\Debug_Ben\110\lp\131\jl\bin\classes.jar:com/google/android/gms/internal/firebase_messaging/zza.class, obj\Debug_Ben\110\lp\136\jl\bin\classes.jar:com/google/android/gms/internal/firebase_messaging/zza.class
4>  Compilation failed
4>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1.
4>Done executing task "D8" -- FAILED.
4>Done building target "_CompileToDalvik" in project "Onside.App.Droid.csproj" -- FAILED.

The exact failure is Type com.google.android.gms.internal.firebase_messaging.zza is defined multiple times:. A duplicated Firebase class like this can happen if you have a mixture of different versions in your project. If you update all your Firebase dependencies to the latest this normally solves the problem. If you have Xamarin.GooglePlayServices.CloudMessaging as a direct dependency in your project remove it or update it to the latest as well.

Update: Also seen this warning which you may have to address to fix the issue:

1>C:\Users\OnsideBen\Source\Repos\onside\Client\packages\Xamarin.Build.Download.0.10.0\build\Xamarin.Build.Download.targets(88,3): warning XBD100: ItemGroup `XamarinBuildDownloadRestoreAssemblyAar` is no longer supported.  If your build is failing, revert to an older Xamarin.Build.Download version, or migrate your packages to use the new `XamarinBuildDownloadAndroidAarLibrary` ItemGroup.  If your build is succeeding it is safe to ignore this warning.
benOnside commented 2 years ago

@jkasten2 Thanks, I checked all the firebase packages and one of them (Firebase.Iid) was on version 71.1710.0 when there was an available version 121.1.0.2. I think I've seen before that xxx.1.0.3 for all these firebase versions is not compatible unless targeting beta versions of android, so I'm ignoring those for now. It is building successfully now, but its crashing quite often - possibly whenever it receives a notification. I consider this issue resolved though, and I'm out of time to continue trying out the beta for now. Thanks for your help, that was good to learn

jkasten2 commented 2 years ago

@benOnside Good to hear that got you passed this specific issue. Please open a new issue with the crash stack trace and we can look into that one.