angelos3lex / react-native-smtp-mailer

Send emails by connecting to smtp server+attachments, using android javamail and ios mailcore2
38 stars 32 forks source link

Could not find method implementation() #2

Closed nsethuraman closed 5 years ago

nsethuraman commented 6 years ago

how to fix this error A problem occurred evaluating project ':react-native-smtp-mailer'.

Could not find method implementation() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

angelos3lex commented 6 years ago

@nsethuraman Cannot reproduce without any info about your gradle version, RN version etc. But, probably this error is due to low gradle version in your project(try to upgrade gradle version to 3.0.1 for example, or either change implementation in react-native-smtp-mailer/android/build.gradle to compile.

nsethuraman commented 6 years ago

my gradle version below ( ...android\build.gradle) dependencies { classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:3.1.1' classpath 'com.android.tools.build:gradle:2.2.+' }

react native version "react-native": "~0.47.0", and npm version 3.10.10

Now i changed gradle version(3.0.1) in react-native-smtp-mailer/android/build.gradle but again getting below error

A problem occurred configuring project ': app'.

Could not resolve all dependencies for configuration ':app:_debugApk'. A problem occurred configuring project ':react-native-smtp-mailer'. Could not resolve all dependencies for configuration ':react-native-smtp-mailer:classpath'. Could not find com.android.tools.build:gradle:3.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar

angelos3lex commented 6 years ago

You have two options: 1) Upgrade gradle in your project, which means you change in yourApp/android/build.gradle

buildscript {
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android plugin 3.0.0 or higher.
        google()
        ...
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

Which means, add google() in repositories and change version to 3.0.1. Then, in yourApp/android/gradle/wrapper/gradle-wrapper.properties change distribution url to:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

But because your RN version is old, and i do not know if they support gradle 3+, you may need to go for option 2: 2) In yourApp/node-modules/reactt-native-smtp-mailer/android/build.gradle change:

dependencies {
    implementation 'com.facebook.react:react-native:+'
    implementation fileTree(dir: 'libs', include: '*.jar')
}

to

    compile 'com.facebook.react:react-native:+'
    compile fileTree(dir: 'libs', include: '*.jar')

But with second option, if this module gets updated, and you run npm update, your changes will be overridden, and you 'll need to change them again. So maybe fork this repo first, and use your repo instead of this, so that updates not bother you.