javaandroid-studionamespacesbuild.gradlesamsung

Samsung IAP build.gradle in Android Studio Flamingo


I am building an application, that is going to use Samsung IAP. I started with empty activity in Java and as the first thing I wanted to integrate Samsung IAP. I follow the instructions from Samsung Developer's Page and I have failed actually on the 1st step, just after downloading SDK - installing the module IAP6Helper. Namely build.gradle fails with error:

Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

android {
    namespace 'com.example.namespace'
}

If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

The problem is module's build.gradle already contains:

android { namespace 'com.example.namespace' }

I am not an expert in gradle, so I am stuck here.


Solution

  • I think I found finally solution, or rather workaround myself. It probably can be achieved by properly setting the gradle directly, but I am not an expert in this domain, as I said.

    What finally worked for me was to downgrade gradle (plugin and gradle) to the 7.* highest versions (Flamingo uses 8.0 of the gradle by default) by going File -> Project Structure, and then choose from the lists versions 7.* - the highest version available (for me it was 7.4.2 and 7.6.1, as you see):

    enter image description here

    Then use Upgrade Assistant, which appears immediately: enter image description here

    to upgrade it back to version 8.0 of the gradle. Just press Start AGP Upgrade Assistant and the Run Selected Actions (Upgrade to version 8) in the following window.

    Please remove the whole post if this is bad practice to answer myself. I wasn't sure if I should remove the post or rather answer it. Then I said to myself, it might be useful to others, and I decided to answer it.