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

AGP upgrading from 7.4.2 to 8.0.1 error "Namespace not specified. Please specify a namespace in the module's build.gradle file." #409

Closed
D7766 opened this issue May 17, 2023 · 11 comments
Assignees
Labels

Comments

@D7766
Copy link

D7766 commented May 17, 2023

Hello,

I have Android Studio Flamingo 2022.2.1 Patch 1, Gradle version 7.5, AGP 7.4. If I open Androidx media 1.0.1 project and run configuration Demo - it works correctly.
The Studio offered changes in namespace in effect and extractor libraries for androidTest. I deleted the namespace parameter in lib-effect - AndroidManifest.xml (androidTest) and writed text "namespace androidx.media3.effect" in android { ... } section into builde.gradle (Module :lib-effect). I did the same for extractor library. It works correctly too.

Now AGP Upgrade Assistant offeres upgrade project's Android Gradle Plugin from 7.4.2 to 8.0.1. But during upgrading there is the error Sync Failed. The error message from sync is:

`Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
namespace 'com.example.namespace'
}

How do I upgrade succesfully? Is there any bug in AGP 8.0.1? I would like use new Androidx Exoplayer 1.0.1, not older version ExoPlayer v 2.

Thank you for you replay.

@icbaker
Copy link
Collaborator

icbaker commented May 17, 2023

Can you provide a bit more context about why you need to upgrade this project to AGP 8.0.1? If you want to use media3 1.0.1, you can probably just use the artifacts from maven rather than building the library yourself?

@OxygenCobalt
Copy link
Contributor

Can you provide a bit more context about why you need to upgrade this project to AGP 8.0.1? If you want to use media3 1.0.1, you can probably just use the artifacts from maven rather than building the library yourself?

Personally, I have to vendor media3 to add some rejected changes like automatic FFMPEG decoder assembly, among other patches. Relying on the artifacts really isn't feasible for me.

@icbaker
Copy link
Collaborator

icbaker commented May 17, 2023

@OxygenCobalt Thanks for sharing - would your use-case be solved if you could build a local version of this project with its currently defined AGP version (7.2.2) and use something like PublishToMavenLocal to share those locally-built artifacts with your app development project?

(I'm cribbing from a similar comment from @bubenheimer in #346 (comment), who points out that PublishToMavenLocal doesn't currently work, but maybe we could fix that)

I'm aware our current instructions tell you to put everything in one Android Studio project, I'm just wondering if we should revisit those instructions.

@D7766
Copy link
Author

D7766 commented May 17, 2023

@icbaker
"Can you provide a bit more context about why you need to upgrade this project to AGP 8.0.1? If you want to use media3 1.0.1, you can probably just use the artifacts from maven rather than building the library yourself?"

Thank you for your replay. My context:
I would like to create and implement my own UI interface of media3 ExoPlayer. I think when I use maven I can not make changes in Exoplayer library, that yes? I must make my own library. As I am a new one in android programming I want to start from some project with UI of Exoplayer which works correctly. Then I would like to delete redundancy parts from it and change UI parts by me. I selected Media3 project as I want to use the newest version of ExoPlayer. Standalone ExoPlayer2 library will be deprecated in favour of the Media3 implementation.
I want to my downloaded Media3 project upgrade to AGP 8.0.1 because my Android Studio recommends it.

@OxygenCobalt
Copy link
Contributor

Thanks for sharing - would your use-case be solved if you could build a local version of this project with its currently defined AGP version (7.2.2) and use something like PublishToMavenLocal to share those locally-built artifacts with your app development project?

Can this be automated by gradle in some way @icbaker? One of the reasons I still vendor is that I can make all build steps be 100% executed by gradle with no extra scripting.

@icbaker
Copy link
Collaborator

icbaker commented May 19, 2023

@OxygenCobalt That's a good question. I did a bit of digging and it seems there isn't currently a good way with Gradle for one project to depend on another, with different Gradle/AGP versions, but with 'synchronized' re-building. Given that, I think we will stick with our current recommendation of putting everything into a single AS project (and unfortunately therefore requiring the same AGP version).

I'm also looking into upgrading us to AGP 8.0.1, but it requires quite a lot of changes.

@D7766 if you just want to experiment then I would not try and upgrade to AGP 8.0.1, just leave it on 7.4.2 and ignore Android Studio's recommendation for now.

I will keep this issue open to track my efforts to upgrade to AGP 8.0.1.

@bubenheimer
Copy link

@icbaker Would you still be able to look into why "publishToMavenLocal" does not work? The media3 project looks set up to publish to a repo via standard Gradle & AGP mechanisms, which generally means that it will publish to local as well; there is no extra setup required to make this work. It is puzzling that it is not working.

@icbaker
Copy link
Collaborator

icbaker commented May 19, 2023

@bubenheimer I just tried ./gradlew publishToMavenLocal on the main branch at fe66756 and it seemed to 'just work'. The task succeeded, and I see the artifacts in ~/.m2/repository/, e.g. ~/.m2/repository/androidx/media3/media3-exoplayer/1.1.0-alpha01/media3-exoplayer-1.1.0-alpha01.aar.

I then bumped the version number to 1.1.0-alpha02 locally (similar to 8c5e197), rebuilt, verified the alpha02 artifacts were created and then checked I could use that dep from a separate Android Studio project on the same computer where I had added the mavenLocal() repository in the gradle config - this must be coming from the local maven repo, since 1.1.0-alpha02 doesn't exist in https://maven.google.com/web/index.html?q=media3#androidx.media3 (which is the only place we publish media3 artifacts).

I did this in a Debian-based development environment.

If you're seeing a different behaviour when following the same steps then I suggest you file a separate issue, though I'm afraid we have limited capacity to investigate build problems that don't repro for us, so we may not be able to offer much assistance.

icbaker added a commit to google/ExoPlayer that referenced this issue May 19, 2023
This is blocking the upgrade to AGP 8.0.1. The Android Studio Upgrade
Assistant refuses to run with the error:
> Modules have the same package for their `main` and `androidTest`
> artifacts
>
> The package specifications in `AndroidManifest.xml` files define the
> same package for the `main` and `androidTest` artifacts, in the
> following modules: `effect`, `muxer`, `transformer`,
`test_exoplayer_abr`, `test_exoplayer_performance`, and `container`.

This change also adds the `.test` suffix to `test/AndroidManifest.xml`
files where it's missing, because although it's not mentioned in the
Upgrade Assistant error it does cause problems later.

```
> Incorrect package="androidx.media3.database" found in source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
  Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
  Recommendation: remove package="androidx.media3.database" from the source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
```

Issue: androidx/media#409
PiperOrigin-RevId: 533460180
icbaker added a commit to google/ExoPlayer that referenced this issue May 19, 2023
This is a pre-requisite for the Android Studio upgrade assistant to
upgrade from AGP 7.2.2 to 8.0.1, otherwise it fails and complains
this is missing.

Issue: androidx/media#409
PiperOrigin-RevId: 533463246
icbaker added a commit to google/ExoPlayer that referenced this issue May 19, 2023
Docs:
* https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
* https://developer.android.com/reference/tools/gradle-api/8.0/com/android/build/api/dsl/PublishingOptions

This resolves the following warning from Android Gradle Plugin 7.2.2 and
helps unblock the upgrade to AGP 8.0.1:

> Software Components will not be created automatically for Maven
> publishing from Android Gradle Plugin 8.0. To opt-in to the future
> behavior, set the Gradle property
> `android.disableAutomaticComponentCreation=true` in the
> `gradle.properties` file or use the new publishing DSL.
>
> Affected Modules: `lib-cast`, `lib-common`, `lib-container`,
> `lib-database`, `lib-datasource`, `lib-datasource-cronet`,
> `lib-datasource-okhttp`, `lib-datasource-rtmp`, `lib-decoder`,
> `lib-effect`, `lib-exoplayer`, `lib-exoplayer-all (legacy)`,
> `lib-exoplayer-dash`, `lib-exoplayer-hls`, `lib-exoplayer-ima`,
> `lib-exoplayer-rtsp`, `lib-exoplayer-smoothstreaming`,
> `lib-exoplayer-workmanager`, `lib-extractor`, `lib-media2 (legacy)`,
> `lib-mediasession (legacy)`, `lib-muxer`, `lib-session`,
> `lib-transformer`, `lib-ui`, `lib-ui-leanback`, `test-utils`,
> `test-utils-robolectric`

Issue: androidx/media#409
PiperOrigin-RevId: 533464133
icbaker added a commit to google/ExoPlayer that referenced this issue May 19, 2023
This change was auto-generated by the Android Studio Upgrade Assistant.

Issue: androidx/media#409
PiperOrigin-RevId: 533467455
icbaker added a commit that referenced this issue May 19, 2023
This is blocking the upgrade to AGP 8.0.1. The Android Studio Upgrade
Assistant refuses to run with the error:
> Modules have the same package for their `main` and `androidTest`
> artifacts
>
> The package specifications in `AndroidManifest.xml` files define the
> same package for the `main` and `androidTest` artifacts, in the
> following modules: `effect`, `muxer`, `transformer`,
`test_exoplayer_abr`, `test_exoplayer_performance`, and `container`.

This change also adds the `.test` suffix to `test/AndroidManifest.xml`
files where it's missing, because although it's not mentioned in the
Upgrade Assistant error it does cause problems later.

```
> Incorrect package="androidx.media3.database" found in source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
  Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
  Recommendation: remove package="androidx.media3.database" from the source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
```

Issue: #409
PiperOrigin-RevId: 533460180
icbaker added a commit that referenced this issue May 19, 2023
This is a pre-requisite for the Android Studio upgrade assistant to
upgrade from AGP 7.2.2 to 8.0.1, otherwise it fails and complains
this is missing.

Issue: #409
PiperOrigin-RevId: 533463246
icbaker added a commit that referenced this issue May 19, 2023
Docs:
* https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
* https://developer.android.com/reference/tools/gradle-api/8.0/com/android/build/api/dsl/PublishingOptions

This resolves the following warning from Android Gradle Plugin 7.2.2 and
helps unblock the upgrade to AGP 8.0.1:

> Software Components will not be created automatically for Maven
> publishing from Android Gradle Plugin 8.0. To opt-in to the future
> behavior, set the Gradle property
> `android.disableAutomaticComponentCreation=true` in the
> `gradle.properties` file or use the new publishing DSL.
>
> Affected Modules: `lib-cast`, `lib-common`, `lib-container`,
> `lib-database`, `lib-datasource`, `lib-datasource-cronet`,
> `lib-datasource-okhttp`, `lib-datasource-rtmp`, `lib-decoder`,
> `lib-effect`, `lib-exoplayer`, `lib-exoplayer-all (legacy)`,
> `lib-exoplayer-dash`, `lib-exoplayer-hls`, `lib-exoplayer-ima`,
> `lib-exoplayer-rtsp`, `lib-exoplayer-smoothstreaming`,
> `lib-exoplayer-workmanager`, `lib-extractor`, `lib-media2 (legacy)`,
> `lib-mediasession (legacy)`, `lib-muxer`, `lib-session`,
> `lib-transformer`, `lib-ui`, `lib-ui-leanback`, `test-utils`,
> `test-utils-robolectric`

Issue: #409
PiperOrigin-RevId: 533464133
icbaker added a commit that referenced this issue May 19, 2023
This change was auto-generated by the Android Studio Upgrade Assistant.

Issue: #409
PiperOrigin-RevId: 533467455
@icbaker
Copy link
Collaborator

icbaker commented May 19, 2023

I just pushed some commits (linked above) that update the main branch to AGP 8.0.1. If you're cherrypicking these somewhere elsewhere you'll probably need to take all of them, since there was quite a lot of pre-work before the actual Android Assistant was able to do its 'magic'.

I'm going to close this, since I think the question has been answered and we've also now updated.

@icbaker icbaker closed this as completed May 19, 2023
@D7766
Copy link
Author

D7766 commented May 19, 2023

"...@D7766 if you just want to experiment then I would not try and upgrade to AGP 8.0.1, just leave it on 7.4.2 and ignore Android Studio's recommendation for now.
I will keep this issue open to track my efforts to upgrade to AGP 8.0.1. ..."

@icbaker Thank you for your replay very much :-)

@bubenheimer
Copy link

@icbaker I tried what you did with publishToMavenLocal on the commit you referenced, but it did not put any artifacts in my local .m2 folders. I suspect there is something private in your build setup that I don't have. I remember that it also does not even seem to build the desired artifacts if I just do ./gradlew clean publishToMavenLocal. I'm on Intel Mac.

OxygenCobalt pushed a commit to OxygenCobalt/media that referenced this issue Jul 11, 2023
This is blocking the upgrade to AGP 8.0.1. The Android Studio Upgrade
Assistant refuses to run with the error:
> Modules have the same package for their `main` and `androidTest`
> artifacts
>
> The package specifications in `AndroidManifest.xml` files define the
> same package for the `main` and `androidTest` artifacts, in the
> following modules: `effect`, `muxer`, `transformer`,
`test_exoplayer_abr`, `test_exoplayer_performance`, and `container`.

This change also adds the `.test` suffix to `test/AndroidManifest.xml`
files where it's missing, because although it's not mentioned in the
Upgrade Assistant error it does cause problems later.

```
> Incorrect package="androidx.media3.database" found in source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
  Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
  Recommendation: remove package="androidx.media3.database" from the source AndroidManifest.xml: libraries/database/src/test/AndroidManifest.xml.
```

Issue: androidx#409
PiperOrigin-RevId: 533460180
OxygenCobalt pushed a commit to OxygenCobalt/media that referenced this issue Jul 11, 2023
This is a pre-requisite for the Android Studio upgrade assistant to
upgrade from AGP 7.2.2 to 8.0.1, otherwise it fails and complains
this is missing.

Issue: androidx#409
PiperOrigin-RevId: 533463246
OxygenCobalt pushed a commit to OxygenCobalt/media that referenced this issue Jul 11, 2023
Docs:
* https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
* https://developer.android.com/reference/tools/gradle-api/8.0/com/android/build/api/dsl/PublishingOptions

This resolves the following warning from Android Gradle Plugin 7.2.2 and
helps unblock the upgrade to AGP 8.0.1:

> Software Components will not be created automatically for Maven
> publishing from Android Gradle Plugin 8.0. To opt-in to the future
> behavior, set the Gradle property
> `android.disableAutomaticComponentCreation=true` in the
> `gradle.properties` file or use the new publishing DSL.
>
> Affected Modules: `lib-cast`, `lib-common`, `lib-container`,
> `lib-database`, `lib-datasource`, `lib-datasource-cronet`,
> `lib-datasource-okhttp`, `lib-datasource-rtmp`, `lib-decoder`,
> `lib-effect`, `lib-exoplayer`, `lib-exoplayer-all (legacy)`,
> `lib-exoplayer-dash`, `lib-exoplayer-hls`, `lib-exoplayer-ima`,
> `lib-exoplayer-rtsp`, `lib-exoplayer-smoothstreaming`,
> `lib-exoplayer-workmanager`, `lib-extractor`, `lib-media2 (legacy)`,
> `lib-mediasession (legacy)`, `lib-muxer`, `lib-session`,
> `lib-transformer`, `lib-ui`, `lib-ui-leanback`, `test-utils`,
> `test-utils-robolectric`

Issue: androidx#409
PiperOrigin-RevId: 533464133
OxygenCobalt pushed a commit to OxygenCobalt/media that referenced this issue Jul 11, 2023
This change was auto-generated by the Android Studio Upgrade Assistant.

Issue: androidx#409
PiperOrigin-RevId: 533467455
@androidx androidx locked and limited conversation to collaborators Jul 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants