transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
650 stars 241 forks source link

I can't compile the application after configuring the plugin #1338

Closed jacsdev closed 3 months ago

jacsdev commented 3 months ago

Your Environment

• No issues found!

Expected Behavior

It should compile without problems, but I see it happens when I add the line apply from: "${background_geolocation.projectDir}/background_geolocation.gradle " in the app/build.gradle

Actual Behavior

I am trying to compile my application in android, I have already done the setup, I have everything ready, the license and everything configured, only when I put the line apply from: "${background_geolocation.projectDir}/background_geolocation.gradle", then I get that problem when compiling. I am using flutter 3.16

Steps to Reproduce

1. 2. 3. 4.

Context

Debug logs

Logs ``` Building with Flutter multidex support enabled. FAILURE: Build failed with an exception. * Where: Script '/Users/jacsdev/.pub-cache/hosted/pub.dev/flutter_background_geolocation-4.14.1/android/background_geolocation.gradle' line: 2 * What went wrong: A problem occurred evaluating script. > Could not find method android() for arguments [background_geolocation_t6cjxr7v1mimd1be2zpdnvis$_run_closure1@75dd5b7e] on project ':app' of type org.gradle.api.Project. * 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 518ms Running Gradle task 'bundleRelease'... 1,088ms Gradle task bundleRelease failed with exit code 1 ```
christocracy commented 3 months ago

There’s something wrong with your app.

I suggest you first practice setting up the plug-in in a simple hello-world app.

jacsdev commented 3 months ago

I really appreciate the fact that you interact with the queries we make. I'll give it a try and then let you know

YaLazreq commented 3 months ago

I really appreciate the fact that you interact with the queries we make. I'll give it a try and then let you know

can you show us the android/app/build.gradle

jacsdev commented 3 months ago

I really appreciate the fact that you interact with the queries we make. I'll give it a try and then let you know

can you show us the android/app/build.gradle

Of course...

app/build.gradle (Now it's working fine!!!)

plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" id 'com.google.gms.google-services' }

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

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

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

def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties')

if (keystorePropertiesFile.exists()) { keystorePropertiesFile.withReader('UTF-8') { reader -> keystoreProperties.load(reader) } }

// flutter_background_geolocation Project background_geolocation = project(':flutter_background_geolocation') apply from: "${background_geolocation.projectDir}/background_geolocation.gradle"

android { compileSdkVersion 34
namespace "here.goes.your.application.id" ndkVersion "25.1.8937393"

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "here.goes.your.application.id"

    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion 34 
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        signingConfig signingConfigs.release
        minifyEnabled true
        shrinkResources false

        proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
    }
}

}

flutter { source '../..' }

dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }

YaLazreq commented 3 months ago

oh okey if it's working then 👍🏽