OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
615 stars 213 forks source link

I can't build on Android #573

Closed pdechanoz closed 2 years ago

pdechanoz commented 2 years ago

Description: On a new project : After add line (Step 5. Set up OneSignal for Android) in android/app/build.gradle, application can't build.

Environment

flutter doctor : Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale fr-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.68.1) [✓] Connected device (4 available) [✓] HTTP Host Availability

pubsec.yaml : onesignal_flutter: ^3.3.2

Steps to Reproduce Issue:

1°) flutter create onesignal 2°) Add onesignalflutter: ^3.3.2 in pubsec.yaml 3°) Add following line in android/app/build.gradle : buildscript { repositories { // ... maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal } dependencies { // ... // OneSignal-Gradle-Plugin classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]' } } apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'_

Run app

ERROR :

**Launching lib/main.dart on Pixel 6 in debug mode... Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

BUILD FAILED in 2s Exception: Gradle task assembleDebug failed with exit code 1**

pdechanoz commented 2 years ago

In fact, this plugin is not compatible with gradle 7 :

File : android/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

nan-li commented 2 years ago

Hi @pdechanoz,

I apologize for the delayed response. Thank you for reporting this. It does look like there is incompatibility with the onesignal-gradle-plugin. This issue you report is also tracked here.

There has been some investigation of a rewrite of the onesignal-gradle-plugin... However, we don't have an ETA on this at this time.

However, onesignal-gradle-plugin is actually an optional part of integrating OneSignal into your Android app, it simply resolves dependency version mismatches, but you may not have any conflicting versions of Firebase or other libraries this plugin is designed to solve.

Given the above, since you are seeing an issue with onesignal-gradle-plugin, you can remove it from your project. After that, make sure your app builds AND runs. If you see either a build issue or crash after removing it, follow up here and we will try to help you with any remaining issues.

brismithers commented 2 years ago

Hi @pdechanoz! Checking in to see if removing onesignal-gradle-plugin from your project has resolved your issue? If removing it results in a build issue or a crash when running please let us know. Thanks!

BlackLeg15 commented 2 years ago

Hi @brismithers I had this same bug, but I've deleted the "buildscript" stuff and my app is running. Thanks for your help.

pdechanoz commented 2 years ago

Hi When I've removed the "buildscript" and the apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' line, it's works.

Thanks for your help.

elhe26 commented 1 year ago

Hi When I've removed the "buildscript" and the apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' line, it's works.

Thanks for your help.

This is the answer.