ERROR: Gradle DSL method not found: 'imlementation()' - java

My app is not working after I updated my android phone to Android 10. So I migrated my app to androidx. Now I am trying to update my gradle from 2.3.1 to 3.5.1.
This is my build.gradle(Project:) file -
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
My build.gradle(Project:) file is -
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "....."
minSdkVersion 19
targetSdkVersion 29
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
imlementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('....')
implementation files('....')
implementation files('....')
implementation files('....')
}
This is the Error I get -
ERROR: Gradle DSL method not found: 'imlementation()'
Possible causes:
The project '.....' may be using a version of the
Android Gradle plug-in that does not contain the method (e.g.
'testCompile' was added in 1.1.0). Upgrade plugin to version 3.5.1 and
sync project
The project '...' may be using a version of
Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
I am new to android development. I am using android studio.
Thank you in advance.

You made a typo in your first implementation declaration. imlementation -> implementation.

Change imlementation
to
implementation

Related

Error after adding Facebook login dependency in Android

I want to integrate my app with facebook login, but when adding below dependency and syncing Gradle:
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
I got the following errors:
ERROR: Failed to resolve: legacy-support-v4
Affected Modules: app
ERROR: Failed to resolve: browser
Affected Modules: app
ERROR: Failed to resolve: legacy-support-core-utils
Affected Modules: app
ERROR: Failed to resolve: media
Affected Modules: app
My build.gradle in app-level:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
}
repositories { }
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.***************"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.github.GrenderG:Toasty:1.4.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
implementation 'com.tuyenmonkey:mkloader:1.4.0'
implementation 'me.riddhimanadib.form-master:form-master:1.1.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
}
apply plugin: 'com.google.gms.google-services'
and build.gradle on project-level:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've searched a lot on google and StackOverflow and tested all the methods, but this problem doesn't fix. Please help me where is my problem.
First of all remove
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
}
repositories { }
from your app-level Gradle file when you have repositories set in your project-level Gradle file. This causes confusion.
Use implementation 'com.facebook.android:facebook-android-sdk:5.13.0' instead of your dependency.
You can always check Maven Centeral for the latest version of libraries.
or
Use Gradle, please, just enter the library name you need and copy the result (don't forget to replace compile with implementation)
I've tested some of Facebook SDK versions, suddenly in 4.26.0 version, my Gradle was successfully built.
I've checked the release note of Facebook SDK on the next version ( 4.27.0 ) and I find this:
Modified
+ Restructured the Facebook SDK and organized it into separate libraries/modules that can depend on one another.
+ Moves GraphRequest.createOpenGraphObject(ShareOpenGraphObject) to ShareGraphRequest.createOpenGraphObject(ShareOpenGraphObject)
+ Moves FacebookSDK.[set|get]WebDialogTheme(...) to WebDialog.[set|get]WebDialogTheme(...)
+ Removes unused dimens from styles.xml
+ Removes files only used by internal tests
+ updates proguard files
Anyway, with the following line, my problem was solved:
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'
It's not good news for me to use about 3 years ago package, but at this point, I don't have any Idea.
Looks like you're pointing to a library that doesn't exist.
Replace your implementation.... with:
implementation 'com.facebook.android:facebook-login:[5,6)'
(source: https://developers.facebook.com/docs/android/componentsdks/)
As Stated in this post, you need to add these two properties to gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true

Gradle sync error in Android Studio for appcompact-v7:26.0.1 [duplicate]

This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
I have installed Android Studio 3 in my system and assigned a API level 26 version 1 & 2 both (Android Oreo (8.0) to the project as shown in the image below:
And the SDK tools as 26.1.1 version installed as shown in image below:
Code in app module gradle:
Troubleshooting steps i have tried so far:
changing the versions of appcompact-v7 in gradle file to (26.0.0,26.0.1,26.0.2,26.1.1,26.1.2) and sync.
Invalidate cache and restart.
Rebuild project.
I did not get success in above methods. I get the error messages as:
and in more details according to the respective versions I get error msg as:
But if I change the version as appcompact-v7:+ then it works fine and gradle sync is successful. I know that it is not a good practice to use the above method.
How can we resolve the above error. Or is there any way we can find out which version of appcompact the studio is downloading when we add reference as appcompact-v7:+ ?
I am new to Android Studio and Android development.
Since API 26, Google has moved the repository to Google() repo. You must add it in your build.gradle project file:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and don't forget to update your gradle wrapper. You can use this command:
>gradle wrapper --gradle-version 4.2
Check ur build files. This is the best way to do it.
In your root level gradle.build use below
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and in your gradle-wrapper.properties file change the wrapper version as below
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
also in your app level build.gradle make sure you are using 26 vesion as below
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
(Sry it would be better as a comment, but I can't)
If you are behind a proxy check your gradle.properties with proxy configuration
systemProp.http.proxyHost=[url/ip]
systemProp.http.proxyPort=[port]
systemProp.https.proxyHost=[url/ip]
systemProp.https.proxyPort=[port]

How to pack Android Gradle app to *.jar or *.aar file

I created Android App with some gradle dependencies. Now I want to create from this project *.jar (without resources and add them separately) file or *.aar file.
I tried to create new library project (with build.xml), copied my *.java and res files and run ant jar, I'm fixing problem one by one. Is there any better solution to do this?
You need to make two modules. The first module would be the jar. This should be POJOs (Plain Old Java Object) and nothing Android. The second module would be the aar. This could depend on your first project but add on the Android specific code / resources.
Then your project (MyApp) structure would look like this
MyApp/
MyApp/build.gradle
MyApp/settings.gradle
MyApp/PoJoProject/
MyApp/PoJoProject/build.gradle
MyApp/AndroidProject/
MyApp/AndroidProject/build.gradle
Then your settings.gradle file would look something like this:
include ':PoJoProject', ':AndroidProject'
Now in the modules
In MyApp/PoJoProject/build.gradle you will want to apply the java plugin. This module will build to the desired jar format that can be ran anywhere on the normal JVM.
plugins {
id 'java'
}
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
dependencies {
compile 'com.google.code.gson:gson:2.5'
testCompile 'junit:junit:4.12'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
In the MyApp/AndroidProject/build.gradle you want to apply the android plugin. This module will build to the desired aar format and can only be used as an Android dependency.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
apply plugin: 'com.android.application'
// version could be different from app version if needed
// `version` & `group` could also be in the top level build.gradle
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.multiproject.gradle.android"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
// let the android `aar` project use code from the `jar` project
compile project(':PoJoProject')
testCompile 'junit:junit:4.12'
}

spoon gradle : Could not create plugin of type 'AppPlugin'

my gradle project was build succeed, but when add spoon ,then i got this error (Could not create plugin of type 'AppPlugin')
my gradle version 1.9
build.gradle :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:0.9.+'
}
}
apply plugin: 'android'
apply plugin: 'spoon'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
instrumentTestCompile 'com.squareup.spoon:spoon-client:1.0.5'
}
The minimum supported version Android plugin is 0.8. However there is no good documentation against what Spoon plugin version should be used with what version of Android plugin at the moment.
I recommend using the latest versions of both plugins, which will also require newer Gradle version.
P.S.
There was a github issue raised by you: https://github.com/stanfy/spoon-gradle-plugin/issues/14. Right? :)

Is it possible to integrate android annotations with android studio 0.4.6?

I tried many options from google and stackoverflow.
Android studio 0.4.6 and aa 2.7.1.
My build.gradle looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
ext.daggerVersion = '1.0.0';
ext.androidAnnotationsVersion = '2.7.1';
configurations {
apt
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"
compile "com.squareup.dagger:dagger:${daggerVersion}"
}
I've checked Activities_ in AndroidManifest.xml too.
If this quesion were not banned due to other "similar" questions I would prefer answers from people who did it with exacly the same as version. I know there will be next version's and maybe new questions but this looks litle tricky imho. Even though android development with aa is very robust.
"sync project with gradle files", clean, rebuild etc brings no effect.
EDIT:
I tryied with
ext.daggerVersion = '1.2.0';
ext.androidAnnotationsVersion = '3.0.1';
but it brings no result.
After switching to:
classpath 'com.android.tools.build:gradle:0.8.+'
and
ext.daggerVersion = '1.2.0';
it builds succesfully but outputs with:
Default Activity not found
I checked Error: Default Activity Not Found with no effect.
It looks like you need to add the android-apt dependency within the BuildScript dependencies and let gradle know to use it as a plugin.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
}
}
apply plugin: 'android'
apply plugin: 'android-apt'
This is my apt config section, you may need other settings but this should get you started
apt {
arguments {
resourcePackageName android.defaultConfig.packageName
androidManifestFile variant.processResources.manifestFile
}
}
Lot's more info here: https://bitbucket.org/hvisser/android-apt

Categories