Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug How do you set a namespace in build.gradle?

Discussion in 'Android' started by HologramMaster, Nov 29, 2023.

  1. HologramMaster

    HologramMaster

    Joined:
    Jul 5, 2020
    Posts:
    3
    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?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,708
    You specify this by either having package attribute in the manifest, or by setting namespace inside android block

    android {
    namespace 'com.example.m'
    ...
    }
     
  3. HologramMaster

    HologramMaster

    Joined:
    Jul 5, 2020
    Posts:
    3
    I put namespace "com.unity3d.player" at the top of the android block, but it is still giving me the same error. Is there anything i have to change in the manifest file?
     
    Last edited: Nov 30, 2023
  4. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,135
    What is the name of the namespace we should specified? I don't understand the purpose of it. And we can't just spacified the same name as our package name