adobe/aepsdk-react-native

Build fails on gradle@8 - missing namespace

Closed this issue · 17 comments

Expected Behaviour

App should build.

Actual Behaviour

Build fails.

Reproduce Scenario (including but not limited to)

Build android app

Steps to Reproduce

  • use react-native 0.72.7
  • build android

Platform and Version

  • Mac M1
  • react-native@0.72.7
  • gradle@8.0.1

Sample Code that illustrates the problem

// react-native-assurance-aepassurance/android/build.gradle
android {
    compileSdkVersion safeExtGet('compileSdkVersion', 33)
    // namespace "com.adobe.marketing.mobile.reactnative.assurance" must be added to support gradle@8
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 19)
        targetSdkVersion safeExtGet('targetSdkVersion', 33)
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

Logs taken while reproducing problem

> Configure project :adobe_react-native-aepassurance
WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.
5 actionable tasks: 5 executed

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':adobe_react-native-aepassurance'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > 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.

@binarybaba Thanks for reporting. We will take a look.

Thanks,
Calise Cheung
Mobile SDK Engineer

@binarybaba
React Native version 0.73 will have a dependency on AGP 8.x, and namespace will be required. The current React Native latest version is 0.72 at the moment. Could you provide information on how you obtained AGP 8.x? Our intention is to implement the namespace change in an update following the release of React Native 0.73 next year.

Thanks,
Calise

We are looking into the namespace support. We will communicate when we have more info.

HI @cacheung, this is how I specify which AGP version:

// android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        ...
        
         dependencies {
             classpath("com.android.tools.build:gradle:8.0.1")
// android/gradle/wrapper/gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip

This is based off of Android plugin gradle release notes

@binarybaba
Could you log a customer ticket for this issue, so we can review it within the team.

Sure. I see #315 is closed. Is it going to be implemented?

@binarybaba
Not right now. The current apesdk-react-native supports React Native (0.60.0 - 0.72.x) legacy architecture. Android namespace is the requirement for 0.73. We would like you to log a ticket into our issue system and we will review and prioritize.

This is super strange. I am on 0.72.7 and still get the error. Could you give me a link where I can open a ticket?

May I ask why the namespace support pull request was not be accepted?

Couldn't create a ticket in the website, I imagine because I need to be one of the accounts responsible for the Adobe Experience Core? I'm part of the developer team implementing this into our app, but don't have access to an account with Adobe support access.

Hope adding this comment helps prioritize that as well.

@felimenta970
The PR contains more changes than just the namespace update. We need to simplify that for a new PR.
We have several other priorities currently, for release all the packages for namespace changes we need to allocate the time for it.

@binarybaba
AFAIK, React Native 0.72.x doesn't depends on AGP 8.x, only starting from 0.73.
For a new app, the dependencies class path is classpath("com.android.tools.build:gradle")

You can try to use dependency classpath("com.android.tools.build:gradle:7.4.2") for now.

@felimenta970 The PR contains more changes than just the namespace update. We need to simplify that for a new PR. We have several other priorities currently, for release all the packages for namespace changes we need to allocate the time for it.

Thanks for the reply! Is there any expected timeline for that? (Totally understand if not, just trying to fully understand the situation)

@felimenta970 We don't have a timeline yet, but the team is aware of the issue.

Hi,

I'm experiencing this same error. Is there a workaround or fix yet?

Mac M1
react-native 0.72.7
gradle 8.0.1

Screenshot 2024-03-07 at 1 52 27 PM

@holumyn Namespace not specified issue happens on AGP 8.0.0 and above. AFAIK, React Native 0.73 requires AGP 8.x. You are using 0.72.7 which should use the version lower than AGP 8.0.0 if you use the default React Native settings.

For a new app, the dependencies class path is classpath("com.android.tools.build:gradle") which will use the AGP required by the 0.72.7.

Did you customize your AGP version in the build.gradle file under dependencies?

Hi @binarybaba @felimenta970 @holumyn , the namespace support for Android has been released with aepsdk-react-native libraries version 6.0.1.
We are closing this ticket. You can open a new one if you have more questions.