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
606 stars 205 forks source link

Execution failed for task ':flutter_one_signal:compileDebugKotlin'. #71

Closed Denmal1982 closed 5 years ago

Denmal1982 commented 5 years ago

Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.523], locale ru-RU) [√] Android toolchain - develop for Android devices (Android SDK 28.0.3) [√] Android Studio (version 3.2) [√] Connected device (1 available)

build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 1.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "ru.sell2buy.businessapp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [
                onesignal_app_id: '-------',
                onesignal_google_project_number: 'REMOTE'
        ]
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

Full Error

Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.3.0+2\android\src\main\java\com\flutter_webview_plugin\WebviewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_one_signal-0.2.1\android\src\main\kotlin\com\myhexaville\flutteronesignal\FlutterOneSignalPlugin.kt: (50, 35): Type mismatch: inferred type is Boolean? but Boolean was expected
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_one_signal-0.2.1\android\src\main\kotlin\com\myhexaville\flutteronesignal\FlutterOneSignalPlugin.kt: (79, 28): Type mismatch: inferred type is String? but String was expected
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_one_signal-0.2.1\android\src\main\kotlin\com\myhexaville\flutteronesignal\FlutterOneSignalPlugin.kt: (98, 80): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
jkasten2 commented 5 years ago

@Denmal1982 I recommend removing the flutter_one_signal (Flutter-One-Signal) in you have in your project for this official one which is onesignal as flutter_one_signal is no longer maintained.

Make sure you follow the full step guide when switching to this plugin https://documentation.onesignal.com/docs/flutter-sdk-setup