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

[BUG]Namespace not specified. Specify a namespace in the module's build file. #1345

Open
chandruyadav1995 opened this issue Oct 28, 2024 · 8 comments
Assignees
Labels
new issue New issue which has not been checked yet

Comments

@chandruyadav1995
Copy link

History check
Yes
Describe the bug
FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':better_player'.

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.
To Reproduce
Run the app with following configuration.
Gradle version : gradle-8.5-bin.zip
java 21.0.5 2024-10-15 LTS
Flutter 3.24.3

*Example code
used the code as per the code block

Flutter doctor
Please add flutter doctor output here.
Screenshot 2024-10-28 at 10 02 19 AM

Better Player version

  • Version: ^0.0.83

Smartphone (please complete the following information):

  • Device: Android
  • OS: 12+

Additional context

Screenshot 2024-10-28 at 10 03 26 AM
@chandruyadav1995 chandruyadav1995 added the new issue New issue which has not been checked yet label Oct 28, 2024
@ostue
Copy link

ostue commented Oct 28, 2024

BetterPlayer doesnt currently support the newest gradle version. But you can quickly fix it yourself:

Go to your Pub/Cache folder where flutter caches your packages, look for betterplayer and the build.gradle file.

Then add:

namespace = "com.jhomlala.better_player"
right before
compileSdkVersion 31

full code example:

...

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    namespace = "com.jhomlala.better_player"
    compileSdkVersion 31

    compileOptions {
    ...

This should resovle the problem

@mesaglam
Copy link

mesaglam commented Nov 5, 2024

I hope it'll be fixed in the next release. Thanks for all...

@diljith-dev
Copy link

diljith-dev commented Nov 19, 2024

find the Pub/Cache file by this command :

sudo ~/.pub-cache/hosted/pub.dev

you can find better_player folder. find and update gradle

happy coding

@mohsinnaqvi606
Copy link

@jhomlala Please fix this issue.
I believe this will not take too much time.

this solution is working as a quick fix, but every time I need to make changes after flutter clean
#1345 (comment)

@ostue
Copy link

ostue commented Nov 21, 2024

There even are multiple outstanding PRs that implemented a fix already!

@istiaksaif
Copy link

use this in android/build.gradle
it worked in my project

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null && project.name == "better_player") {
                    namespace 'com.jhomlala.better_player'
                }else if (namespace == null) {
                    namespace project.group
                }
            }
        }
        if (project.plugins.hasPlugin("com.android.application") ||
                project.plugins.hasPlugin("com.android.library")) {
            project.android {
                compileSdkVersion 34
            }
        }
    }
}

@afrahshaikh
Copy link

https://github.com/afrahshaikh/even_better_player i have fixed it here

@Abdul-rehman0045
Copy link

I am also getting the same I have fixed it by adding:

namespace = "com.jhomlala.better_player"

in the build.gradle file you can find it in:

.pub-cache/hosted/pub.dev/better_player-0.0.84

after adding it your code should be like this:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace = "com.jhomlala.better_player"
compileSdkVersion 31

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    minSdkVersion 16
}

dependencies {
    implementation "com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-hls:$exoPlayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoPlayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoPlayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-ui:$exoPlayerVersion"
    implementation "com.google.android.exoplayer:extension-mediasession:$exoPlayerVersion"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-common:$lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
    implementation "androidx.annotation:annotation:$annotationVersion"
    implementation "androidx.work:work-runtime:$workVersion"
}

}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue New issue which has not been checked yet
Projects
None yet
Development

No branches or pull requests

9 participants