pusher / pusher-channels-flutter

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

Build fails after install #149

Open loxi5 opened 5 months ago

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

same issue any fix ?

jorgeGasparRamirez commented 1 month ago

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

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

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

jorgeGasparRamirez commented 2 weeks 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.