Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of namespace property to support Android Gradle Plugin (AGP) 8 #839

Closed
Skyost opened this issue May 10, 2023 · 16 comments · Fixed by #843
Closed

Add support of namespace property to support Android Gradle Plugin (AGP) 8 #839

Skyost opened this issue May 10, 2023 · 16 comments · Fixed by #843
Assignees
Labels
e2-days Effort: < 5 days fixed Issue has been resolved and pull request linked p2-medium platform-android Android applications specifically

Comments

@Skyost
Copy link
Contributor

Skyost commented May 10, 2023

Plugin Version

Latest (3.0.0).

Steps to Reproduce

Upgrade your Android project to use AGP 8. In your build.gradle :

buildscript {
  // ...

  dependencies {
    classpath 'com.android.tools.build:gradle:8.0.1'
    // ...
  }
}

Also don't forget to add a namespace in the android section of app/build.gradle :

android {
  // ...
  namespace 'your.namespace'
}

Then flutter run to an Android device (or even flutter build appbundle).

Expected results:

My app to compile fine.

Actual results:

Stacktrace
FAILURE: Build failed with an exception.

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

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Running Gradle task 'bundleRelease'...                           2 150ms
Gradle task bundleRelease failed with exit code 1

More info

See flutter/flutter#125181. It shouldn't be too hard to fix (see the PR I've sent here : https://github.com/bluefireteam/audioplayers/pull/1503/files), but since this project seems to use a custom build.gradle, I'm not sure if we can "just" copy and paste it.

@huycozy huycozy added the in triage Issue currently being evaluated label May 12, 2023
@huycozy
Copy link
Collaborator

huycozy commented May 12, 2023

Thanks for the report. This issue is reproduced on the latest ads plugin version google_mobile_ads: ^3.0.0 and Flutter stable channel 3.10.0.

flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.10.0 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (35 hours ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.62.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

[✓] Network resources
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.11.0-5.0.pre.47, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.11.0-5.0.pre.47 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 43b2b658a0 (2 hours ago), 2023-05-11 21:14:09 -0400
    • Engine revision 748ef964b9
    • Dart version 3.1.0 (build 3.1.0-94.0.dev)
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.78.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@huycozy huycozy added p2-medium e2-days Effort: < 5 days platform-android Android applications specifically and removed in triage Issue currently being evaluated labels May 12, 2023
@Skyost
Copy link
Contributor Author

Skyost commented May 13, 2023

Just submitted a PR that should close this issue.

@nemanja-nisic
Copy link

Is there a workaround for this until this PR is merged?

@Skyost
Copy link
Contributor Author

Skyost commented May 31, 2023

@nemanja-nisic Feel free to use the fork if you don't want to wait. In your pubspec.yaml :

google_mobile_ads:
  git:
    url: https://github.com/Skyost/googleads-mobile-flutter
    path: packages/google_mobile_ads

@huycozy
Copy link
Collaborator

huycozy commented Jul 21, 2023

We’re closing this issue due to inactivity. If you’re still impacted, please create a new issue via the Developer Forum.

@huycozy huycozy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
@under3415
Copy link

Why would you think we are no longer impacted? Anyone who has this in their project cannot upgrade Gradle to version 8+.
There is a fix, it just need to be merged.

@huycozy
Copy link
Collaborator

huycozy commented Aug 7, 2023

@under3415 Thanks for the update. Re-opening the issue since there is a similar report recently.

cc: @malandr2

@huycozy huycozy reopened this Aug 7, 2023
@under3415
Copy link

under3415 commented Aug 7, 2023 via email

@ps6067966
Copy link

I'm also facing same issue.

@therjtkumar
Copy link

therjtkumar commented Aug 14, 2023

facing the same issue with AGP 8...

@MarsadMaqsood
Copy link

facing the same issue

google_mobile_ads: 3.0.0
flutter: 3.13.0
AGP: 8.0.2

Stacktrace
FAILURE: Build failed with an exception.

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

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

@rajcrack
Copy link

rajcrack commented Sep 1, 2023

facing the same issue but does not get any solution. please help in solving this problem...

@under3415
Copy link

under3415 commented Sep 1, 2023

Workaround is to reference solution by Skyost in your pubspec.yaml.
And like the initial post, apparently this raises the profile of the issue with the google team. "Me too" posts are not helping.

google_mobile_ads:
  git:
    url: https://github.com/Skyost/googleads-mobile-flutter
    path: packages/google_mobile_ads

@malandr2
Copy link
Collaborator

malandr2 commented Oct 5, 2023

There is a PR addressing the issue, it has been approved but needs to pass all tests before it can be merge in. Thanks.

@under3415
Copy link

This is still NOT fixed in version 3.1.0

@malandr2
Copy link
Collaborator

Right, #843 has not yet been approved and merged in. It will be included in the next release.

@huycozy huycozy added the fixed Issue has been resolved and pull request linked label Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2-days Effort: < 5 days fixed Issue has been resolved and pull request linked p2-medium platform-android Android applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants