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

Build fails after install #149

Open
loxi5 opened this issue Feb 27, 2024 · 9 comments
Open

Build fails after install #149

loxi5 opened this issue Feb 27, 2024 · 9 comments

Comments

@loxi5
Copy link

loxi5 commented Feb 27, 2024

When the library is installed, building app fails with the following error:

FAILURE: Build failed with an exception.

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

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.

  • 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.

BU�LD FAILED in 8s
Error: Gradle task assembleDebug failed with exit code 1

@islambelhardi
Copy link

islambelhardi commented Mar 12, 2024

i faced the same problem when i tried to upgrade flutter to 3.19.3 i get asked to upgrade my build.gradle as the flutter docs says then i faced this error

i fixed it by adding this line inside android {
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'com.pusher.channels_flutter'
}
inside the android/build.gradle for the pusher package source code

@LScodeblack
Copy link

same issue any fix ?

@jorgeGasparRamirez
Copy link

I have the same issue. Someone knows how can I solve it

@baxevanis
Copy link

I have the same issue. Someone knows how can I solve it

for me this worked

Created a file on root android folder named pusher_channels_flutter_fix.gradle
and added this content

subprojects { subproject ->
    if (subproject.name == 'pusher_channels_flutter') {
        subproject.afterEvaluate {
            // Remove the package attribute from the AndroidManifest.xml
            def manifestFile = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
            if (manifestFile.exists()) {
                def manifestContent = manifestFile.text
                manifestContent = manifestContent.replaceAll('package="com.pusher.channels_flutter"', '')
                manifestFile.text = manifestContent
            }

            // Add the namespace property to build.gradle
            subproject.android {
                namespace = 'com.pusher.channels_flutter'
            }
        }
    }
}

then at the end of build.gradle I added this line

apply from: 'pusher_channels_flutter_fix.gradle'

Was having two issues for both the manifest and the namespace

At least for me this worked!
Hope it helps you also

@AmanBhangre
Copy link

I am getting the same issue after upgrading my compileSDKVersion and targetSDKVersion. Any Solutions?

@jorgeGasparRamirez
Copy link

I have the same issue. Someone knows how can I solve it

for me this worked

Created a file on root android folder named pusher_channels_flutter_fix.gradle and added this content

subprojects { subproject ->
    if (subproject.name == 'pusher_channels_flutter') {
        subproject.afterEvaluate {
            // Remove the package attribute from the AndroidManifest.xml
            def manifestFile = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
            if (manifestFile.exists()) {
                def manifestContent = manifestFile.text
                manifestContent = manifestContent.replaceAll('package="com.pusher.channels_flutter"', '')
                manifestFile.text = manifestContent
            }

            // Add the namespace property to build.gradle
            subproject.android {
                namespace = 'com.pusher.channels_flutter'
            }
        }
    }
}

then at the end of build.gradle I added this line

apply from: 'pusher_channels_flutter_fix.gradle'

Was having two issues for both the manifest and the namespace

At least for me this worked! Hope it helps you also

I got this message * What went wrong:
A problem occurred evaluating root project 'android'.

Could not read script '/Users/io/Trabajo/test/project/android/pusher_channels_flutter_fix.gradle' as it does not exist.

@Apkboi
Copy link

Apkboi commented Sep 2, 2024

I have the same issue. Someone knows how can I solve it

for me this worked
Created a file on root android folder named pusher_channels_flutter_fix.gradle and added this content

subprojects { subproject ->
    if (subproject.name == 'pusher_channels_flutter') {
        subproject.afterEvaluate {
            // Remove the package attribute from the AndroidManifest.xml
            def manifestFile = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
            if (manifestFile.exists()) {
                def manifestContent = manifestFile.text
                manifestContent = manifestContent.replaceAll('package="com.pusher.channels_flutter"', '')
                manifestFile.text = manifestContent
            }

            // Add the namespace property to build.gradle
            subproject.android {
                namespace = 'com.pusher.channels_flutter'
            }
        }
    }
}

then at the end of build.gradle I added this line

apply from: 'pusher_channels_flutter_fix.gradle'

Was having two issues for both the manifest and the namespace
At least for me this worked! Hope it helps you also

I got this message * What went wrong: A problem occurred evaluating root project 'android'.

Could not read script '/Users/io/Trabajo/test/project/android/pusher_channels_flutter_fix.gradle' as it does not exist.

Add the pusher_channels_flutter_fix.gradle on the anndroid folder

@jorgeGasparRamirez
Copy link

jorgeGasparRamirez commented Sep 8, 2024

I solve it. This way:

/Users/your username/.pub-cache/hosted/pub.dev/pusher_channels_flutter-2.2.1/android/build.gradle
I wrote the package name
android {
namespace 'com.pusher.channels_flutter'
.....
}
I clean my cache with flutter clean and the error disappear. The error message "Namespace not specified" indicates that the pusher_channels_flutter library you're using doesn't have a namespace defined in its build.gradle file. This is a requirement since Android Gradle Plugin 8.0

@dola99
Copy link

dola99 commented Sep 30, 2024

  pusher_channels_flutter:
    git:
      url: https://github.com/dola99/pusher-channels-flutter
      ref: new_version
      

it will clear all cached packages on your device

then

flutter pub cache clean
flutter clean 
flutter pub get 

flutter build apk  

it will work with you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants