Description:
I tried adding this to app/build.gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
And gradle build fails with error below:
Launching lib\main.dart on SM G975F in debug mode...
* Error running Gradle:
ProcessException: Process "C:\Users\Sukh\Desktop\Flutter\myapp\android\gradlew.bat" exited abnormally:
> Configure project :onesignal
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
*********************************************************
WARNING: This version of shared_preferences will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Sukh\Desktop\Flutter\myapp\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not get unknown property 'config' for object of type com.google.gms.googleservices.GoogleServicesPlugin$GoogleServicesPluginConfig.
* 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
BUILD FAILED in 2s
Command: C:\Users\Sukh\Desktop\Flutter\myapp\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Exited (sigterm)
Environment
Flutter: 1.7.8+hotfix.3
onesignal: ^1.1.0
Steps to Reproduce Issue:
pubspec.yamlapp/build.gradleAnything else:
If i remove Onesignal SDK from build.gradle it builds successfully.
I have adding following too to my gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
@sukhcha-in I spent a few hours on that issue and got that working. I had some additional problems with Google Maps but all is working fine, these are my gradle files
app/build.gradle
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 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_base_provider"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
and build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
}
allprojects {
repositories {
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '12.0.1'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '12.0.1'
}
}
}
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@demsey2 i choose to use Firebase Cloud Messaging instead of Onesignal. Thanks for response, hope it helps someone.
@sukhcha-in I was thinking to do the same, how is firebase? any issues?
@demsey2 No issues, atleast it supports AndroidX :)
Howdy,
We are currently investigating the issue. Thanks for your patience
I get this error when trying to build for android:
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.18362.239], locale en-SI)
• Flutter version 1.7.8+hotfix.3 at C:\flutter
• Framework revision b712a172f9 (13 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at C:\Users\sdukaric\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.36.1)
• VS Code at C:\Users\sdukaric\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.2.0
[√] Connected device (1 available)
• SM G955F • ce06171679052b2601 • android-arm64 • Android 9 (API 28)
! Doctor found issues in 2 categories.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity-0.4.3+6\android\src\main\java\io\flutter\plugins\connectivity\ConnectivityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\FlutterRegistrarResponder.java:4: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalPlugin.java:4: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalTagsController.java:3: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\FlutterRegistrarResponder.java:57: error: cannot find symbol
protected void runOnMainThread(@NonNull final Runnable runnable) {
^
symbol: class NonNull
location: class FlutterRegistrarResponder
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\FlutterRegistrarResponder.java:61: error: cannot find symbol
protected void invokeMethodOnUiThread(@NonNull final String methodName, @NonNull final HashMap map) {
^
symbol: class NonNull
location: class FlutterRegistrarResponder
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\FlutterRegistrarResponder.java:61: error: cannot find symbol
^
symbol: class NonNull
location: class FlutterRegistrarResponder
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalPlugin.java:69: error: cannot find symbol
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
^
symbol: class NonNull
location: class OneSignalPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalPlugin.java:69: error: cannot find symbol
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
^
symbol: class NonNull
location: class OneSignalPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalTagsController.java:34: error: cannot find symbol
@NonNull private AtomicBoolean replySubmitted = new AtomicBoolean(false);
^
symbol: class NonNull
location: class OSFlutterChangeTagsHandler
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalTagsController.java:87: error: cannot find symbol
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
^
symbol: class NonNull
location: class OneSignalTagsController
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalTagsController.java:87: error: cannot find symbol
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
^
symbol: class NonNull
location: class OneSignalTagsController
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
11 errors
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 5.5s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
androidbuild.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
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
}
android\appbuild.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.1, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
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 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.tennboardflutter"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
gradle.properties:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
If i change import android.support.annotation.NonNull; to import androidx.annotation.NonNull;
erros like this are gone:
symbol: class NonNull
location: class FlutterRegistrarResponder
C:\flutter\.pub-cache\hosted\pub.dartlang.org\onesignal_flutter-2.0.0\android\src\main\java\com\onesignal\flutter\OneSignalPlugin.java:69: error: cannot find symbol
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
but this error still remains:
\branches\develop\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:26: error: cannot access OneSignal
OneSignalPlugin.registerWith(registry.registrarFor("com.onesignal.flutter.OneSignalPlugin"));
^
class file for com.onesignal.OneSignal not found
1 error
the first part was AndroidX related problem, but i dont know why the second error is thrown...
@sukhcha-in The Could not get unknown property 'config' for object of type com.google.gms.googleservices.GoogleServicesPlugin$GoogleServicesPluginConfig. is due to https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/95.
Until the issue is fixed you can downgrade to com.google.gms:google-services version 4.2.0 to work around the issue for now. Follow https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/95 to stay updated on the progress of this error.
Update
OneSignal-Gradle-Plugin 0.12.3 now as this fix
@dukaric1991 The error you are seeing is unrelated to the OPs error. Upgrading to the just released onesignal_flutter 2.0.1 will fix the package android.support.annotation does not exist errors you are seeing
Closing due to inactivity
In your root build.gradle, under buildscript, add the following 2 new lines to your existing repositories and dependencies sections
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.6, 0.99.99]'
}
}
Most helpful comment
@dukaric1991 The error you are seeing is unrelated to the OPs error. Upgrading to the just released
onesignal_flutter2.0.1 will fix thepackage android.support.annotation does not existerrors you are seeing