pusher / pusher-channels-flutter

Pusher Channels client library for Flutter targeting IOS, Android, and WEB
MIT License
74 stars 133 forks source link

Build fails after install #149

Open loxi5 opened 9 months ago

loxi5 commented 9 months ago

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

FAILURE: Build failed with an exception.

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.

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

islambelhardi commented 8 months ago

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 commented 5 months ago

same issue any fix ?

jorgeGasparRamirez commented 4 months ago

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

baxevanis commented 4 months ago

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 commented 4 months ago

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

jorgeGasparRamirez commented 3 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 1 month ago
  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