quickstart-unity icon indicating copy to clipboard operation
quickstart-unity copied to clipboard

[Android] Cannot read packageName / The setTestClassesDir(File) method has been deprecated

Open E-Reg opened this issue 8 years ago • 25 comments

Hello,

I tried building your quickstart example (Firebase Messaging), since my project rejects to use firebase and I wanted to make sure it basically works - however it doesn't. It's not the same error as in my main project, but I really don't know whats happening anyways. I installed NDK Unity 2018.1.0f2 Firebase SDK 5.0.0


> CommandInvokationFailure: Gradle build failed. 
> C:/Program Files/Java/jdk1.8.0_121\bin\java.exe -classpath "E:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
> 
> stderr[
> 
> FAILURE: Build failed with an exception.
> 
> * What went wrong:
> Cannot read packageName from E:\path\messaging\testapp\Temp\gradleOut\src\main\AndroidManifest.xml
> 
> * Try:
> Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
> 
> BUILD FAILED in 2s
> ]
> stdout[
> The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
> The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
> The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.
> :preBuild UP-TO-DATE
> :preReleaseBuild UP-TO-DATE
> :checkReleaseManifest
> :preDebugBuild UP-TO-DATE
> :prepareAndroidArchLifecycleRuntime100Library
> :prepareComAndroidSupportSupportCompat2610Library
> :prepareComAndroidSupportSupportCoreUi2610Library
> :prepareComAndroidSupportSupportCoreUtils2610Library
> :prepareComAndroidSupportSupportFragment2610Library
> :prepareComAndroidSupportSupportMediaCompat2610Library
> :prepareComAndroidSupportSupportV42610Library
> :prepareComGoogleAndroidGmsPlayServicesAdsIdentifier1501Library
> :prepareComGoogleAndroidGmsPlayServicesBase1501Library
> :prepareComGoogleAndroidGmsPlayServicesBasement1501Library
> :prepareComGoogleAndroidGmsPlayServicesMeasurementBase1504Library
> :prepareComGoogleAndroidGmsPlayServicesStats1501Library
> :prepareComGoogleAndroidGmsPlayServicesTasks1501Library
> :prepareComGoogleFirebaseFirebaseAnalytics1600Library
> :prepareComGoogleFirebaseFirebaseAnalyticsImpl1600Library
> :prepareComGoogleFirebaseFirebaseAppUnity500Library
> :prepareComGoogleFirebaseFirebaseCommon1600Library
> :prepareComGoogleFirebaseFirebaseCore1600Library
> :prepareComGoogleFirebaseFirebaseIid1600Library
> :prepareComGoogleFirebaseFirebaseIidInterop1600Library
> :prepareComGoogleFirebaseFirebaseMeasurementConnector1600Library
> :prepareComGoogleFirebaseFirebaseMeasurementConnectorImpl1600Library
> :prepareComGoogleFirebaseFirebaseMessaging1700Library
> :prepareComGoogleFirebaseFirebaseMessagingUnity500Library
> :Firebase:preBuild UP-TO-DATE
> :Firebase:preReleaseBuild UP-TO-DATE
> :Firebase:checkReleaseManifest
> :Firebase:prepareReleaseDependencies
> :Firebase:compileReleaseAidl
> :Firebase:compileReleaseNdk NO-SOURCE
> :Firebase:compileLint
> :Firebase:copyReleaseLint NO-SOURCE
> :Firebase:mergeReleaseShaders
> :Firebase:compileReleaseShaders
> :Firebase:generateReleaseAssets
> :Firebase:mergeReleaseAssets
> :Firebase:mergeReleaseProguardFiles
> :Firebase:packageReleaseRenderscript NO-SOURCE
> :Firebase:compileReleaseRenderscript
> :Firebase:generateReleaseResValues
> :Firebase:generateReleaseResources
> :Firebase:packageReleaseResources
> :Firebase:processReleaseManifest
> :Firebase:generateReleaseBuildConfig
> :Firebase:processReleaseResources
> :Firebase:generateReleaseSources
> :Firebase:incrementalReleaseJavaCompilationSafeguard
> :Firebase:javaPreCompileRelease
> :Firebase:compileReleaseJavaWithJavac
> :Firebase:processReleaseJavaRes NO-SOURCE
> :Firebase:transformResourcesWithMergeJavaResForRelease
> :Firebase:transformClassesAndResourcesWithSyncLibJarsForRelease
> :Firebase:mergeReleaseJniLibFolders
> :Firebase:transformNativeLibsWithMergeJniLibsForRelease
> :Firebase:transformNativeLibsWithStripDebugSymbolForRelease
> :Firebase:transformNativeLibsWithSyncJniLibsForRelease
> :Firebase:bundleRelease
> :prepareReleaseDependencies
> :compileReleaseAidl
> :compileReleaseRenderscript
> :generateReleaseBuildConfig FAILED
> 53 actionable tasks: 53 executed
> ]
> exit code: 1
> UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
> UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
> UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
> UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
> Rethrow as GradleInvokationException: Gradle build failed
> UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
> UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
> UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
> UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

Can you help me with this error?

E-Reg avatar Jun 13 '18 14:06 E-Reg

Temporary fix for this issue (Source click me)

In file Assets\Plugins\Android\AndroidManifest.xml rename line 4

package="${applicationId}"

with

package="com.google.FirebaseUnityMessagingTestApp.dev"

E-Reg avatar Jun 13 '18 14:06 E-Reg

@E-Reg typically "${applicationId}" in AndroidManifest.xml files is replaced by the project ID when using the Internal / Legacy or Gradle (internal) build systems in Unity. It sounds like you're perhaps using a different build process or have tripped across a bug in a new Unity release.

Could you share:

  • Unity version
  • Host operating system
  • Build settings

?

stewartmiles avatar Jun 13 '18 15:06 stewartmiles

Unity 2018.1.0f2 Personal Windows 10 64bit

buildsettings

E-Reg avatar Jun 13 '18 16:06 E-Reg

Your test app runs with the fix above, however my main project refuses to work

https://stackoverflow.com/questions/50841255/multiple-componentdiscoveryservice-in-androidmanifest-merge-conflict

Maybe the problems are related, if you know a fix for that I would be really thankful!

Edit: Actually the project works now as well, seems like I just forgot about hard-writing the package name again

E-Reg avatar Jun 13 '18 16:06 E-Reg

@E-Reg if you switch the build system to Gradle (has been recommended since 2013) variable replacement should work.

stewartmiles avatar Jun 13 '18 17:06 stewartmiles

@stewartmiles this does not change the error. The only fix that helps for now is hard-writing the package name into the assets/plugins/android/androidmanifest.xml instead of the variable

E-Reg avatar Jun 13 '18 21:06 E-Reg

Ok I've reproduced this problem, it does look like a regression with Unity 2018, I'll dust off the workaround gloves :)

stewartmiles avatar Jun 19 '18 17:06 stewartmiles

@Temka193 FYI

stewartmiles avatar Jun 20 '18 20:06 stewartmiles

@stewartmiles replace ${applicationId} on com.google.FirebaseUnityMessagingTestApp.dev ? or my package name?

breineng avatar Jun 21 '18 07:06 breineng

The 5.1.0 release of the Firebase Unity SDK resolves this issue: Release notes: https://firebase.google.com/support/release-notes/unity#5.1.0 Download: https://firebase.google.com/docs/unity/setup

stewartmiles avatar Jun 22 '18 16:06 stewartmiles

This is also handled by the latest release of https://github.com/googlesamples/unity-jar-resolver

stewartmiles avatar Jun 22 '18 16:06 stewartmiles

I still get the same error with unity 2018.1.6f1 (with 4.x runtime Version) and firebase sdk 5.1.1

jnroesch avatar Jun 28 '18 14:06 jnroesch

I still get the same error with unity 2018.1.6f1 (with 4.x runtime Version) and firebase sdk 5.1.1

@stewartmiles Me too, still get the same error. (unity 2017.4.5f1 and firebase sdk 5.1.1) When will it be fixed?

prog-mitsu avatar Jun 30 '18 02:06 prog-mitsu

I also have the problem with Unity 2018.1.5f1 and Firebase SDK 5.1.1

DeanNonatomic avatar Jul 02 '18 14:07 DeanNonatomic

I also get the same error with unity 5.6.4f1 and firebase sdk 5.1.1 when used internal build system.

daoxuantinh avatar Jul 04 '18 09:07 daoxuantinh

Hi everyone, I've taken a look at this and I would love to know the exact steps you're taking which result in this build error. I just took a look at https://github.com/firebase/quickstart-unity/issues/175 which appears to the a duplicate of the most recent set of comments in here and everything is working fine in Unity 2018.1.2p3.

stewartmiles avatar Jul 11 '18 23:07 stewartmiles

I just pulled Unity 5.6.5f1 (it's what I happened to have installed) grabbed the messaging sample:

  • Imported FirebaseMessaging.unitypackage
  • Added google-services.json
  • Switched target platform to Android
  • Selected Internal build system (it was already selected)
  • Built APK
  • Deployed to device

Everything worked out of the box.

I then switched the scripting backend to IL2CPP switched my NDK to the ancient r10e, ran through build step again. Still works.

To see whether this is related to the installed Android SDK, I upgraded it to latest (starting with command line tools 4333796 and using the sdkmanager to download components). I then rebuilt again using both IL2CPP and using the Mono backend, everything still works.

stewartmiles avatar Jul 11 '18 23:07 stewartmiles

Ok I think I've found what may be causing this, though I can't reproduce it reliably.

https://github.com/googlesamples/unity-jar-resolver/blob/master/play-services-resolver-1.2.75.0.unitypackage (we use it in Firebase) changed variable expansion in Android manifests to workaround an Android build problem with Unity 2018. While looking at how this is modifying manifests in some components it appears to be going wrong some of the time.

Could you try deleting everything under Assets/PlayServicesResolver then importing https://github.com/googlesamples/unity-jar-resolver/blob/49653f10f751728819451ac4a190f1bdc648a7f7/play-services-resolver-1.2.74.0.unitypackage , you'll need to Force Resolve and try building again.

stewartmiles avatar Jul 13 '18 01:07 stewartmiles

Doing this did get our project back up and running.

EvilNeru avatar Jul 13 '18 17:07 EvilNeru

The Firebase Unity 5.2.0 SDK integrates Play Services Resolver 1.2.79 which fixes this issue.

Please let us know if there are any more issues.

stewartmiles avatar Jul 23 '18 21:07 stewartmiles