bkonyi/FlutterGeofencing

Updating project to AndroidX breaks build

Closed this issue · 6 comments

I'm getting the following Gradle build error after I've updated to AndroidX:

The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
root project 'android' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.30

I can't find a combination of settings that will allow this to build.

Relevant files here:
android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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
}

gradle/wrapper/gradle-wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fermovian.nas_activity">

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name=".Application"
        android:label="nas_activity"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <receiver android:name="io.flutter.plugins.geofencing.GeofencingBroadcastReceiver"
            android:enabled="true" android:exported="true"/>
        <receiver android:name="io.flutter.plugins.geofencing.GeofencingRebootBroadcastReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
        <service android:name="io.flutter.plugins.geofencing.GeofencingService"
            android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>
    </application>
</manifest>

app/src/main/java/.../Application.java


import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.geofencing.GeofencingService;

public class Application extends FlutterApplication implements PluginRegistry.PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        GeofencingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry);
    }
}

Thanks for filing. I'll take a look.

It looks like your Kotlin version is quite old: ext.kotlin_version = '1.3.10'. Have you tried updating it to something more recent (e.g., 1.3.62)?

Hi, guys. I’ve just started a new flutter project to test the geofencing plugin and I’m facing the same problem.
I’ve also tried many combinations of the kotlin gradle and android gradle plugins.
Based on following post I’ve tried to downgrade the android gradle plugin to satisfy the support of the kotlin gradle 1.2.30. But, without success.
Stackoverflow post:
https://stackoverflow.com/questions/54693595/flutter-the-android-gradle-plugin-supports-only-kotlin-gradle-plugin-version-1

I would like to know if you've found a turnaround. Thks!

i also face the same thing that related to Gradle version when try to build
The following dependencies do not satisfy the required version:
project ':flutter_geofencing' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0

thank you

I tried to copy the source files into a new project with the latest Flutter distribution, and I think it's working. See #45.