HologramMaster
HologramMaster

Reputation: 1

How do you set a namespace in build.gradle for Unity?

I am trying to build my mobile game, but I keep getting an error that says gradle build failed. When I click on the error and scroll, I see the following info:

A problem occurred configuring project ':launcher'. Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl. Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

I have the build.gradle file open in VS, how do I set a namespace?

I have upgraded to Java version 17 and Gradle version 8.1.4. I assumed this would fix all the gradle errors, but it didn't.

Upvotes: 0

Views: 1790

Answers (1)

PiApiAir
PiApiAir

Reputation: 1

I had this problem with flutter_unity_widget but works the same (using Groovy here):

browse <unity_package> > android > src > main > AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.unity_package.name">
</manifest>

line 2 : package="com.example.unity_package.namet"

cut the "com.example.unity_package.name" and erase the line so

AndroidManifest.xml would be

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

then in your package build.gradle, update the android section so it would be

android {
  namespace "com.example.unity_package.name"
  ...
}

Rebuild and it should work. All the informations are in this section

Upvotes: 0

Related Questions