mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 462 forks source link

Build error on Android? #122

Closed rgbinnovation closed 4 years ago

rgbinnovation commented 5 years ago

App Gradle:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }

    // Added for QR
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.2, 0.99.99]'
    }
}

Android Gradle:

buildscript {
    ext.kotlin_version = '1.2.31'

    repositories {
        google()
        jcenter()
    }

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

My error:

Anyone has any idea? Thanks!

liminal commented 5 years ago

there are two kinds of dependencies blocks. One is for dependencies for the build tools, that's the one in the buildscript block. The other is the dependencies for the app you're building. implementation is only for the second kind.

The problem is caused by you adding implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" do the buildscript dependencies block. it should be outside of the buildscript block. also, you shouldn't be applying the plugins inside of the buildscript block.

I think what you want is something more like

app/build.gradle:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    }

    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.2, 0.99.99]'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
hqwlkj commented 4 years ago

According to the above configuration, the operation still reports an error.

/build.gradle


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

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

/app/build.gradle


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

error info

image

devtronic commented 4 years ago

Try to update to the latest version of the package.