This question already has answers here:
What is "deps" in "implementation deps.support.app_compat"?
(2 answers)
Closed 1 year ago.
I've downloaded a repository from github and in the dependencies I've founded this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation deps.kotlin.stdlib
implementation deps.support.app_compat
implementation deps.support.design
implementation deps.support.core_ktx
implementation deps.constraint_layout
implementation deps.arch_core.runtime
// Navigation
implementation deps.navigation.runtime_ktx
implementation deps.navigation.fragment_ktx
implementation deps.navigation.ui_ktx
// Android Testing Support Library's runner and rules
androidTestImplementation deps.atsl.runner
androidTestImplementation deps.atsl.rules
androidTestImplementation deps.room.testing
androidTestImplementation deps.arch_core.testing
// Espresso UI Testing
androidTestImplementation deps.espresso.core
androidTestImplementation deps.espresso.contrib
androidTestImplementation deps.espresso.intents
}
So I've tried to instal those dependencies to my project but I got an error
A problem occurred evaluating project ':app'.
Could not get unknown property 'deps' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
So any ideas what this "desp" means?
This is a way (with ExtraPropertiesExtension) to keep build.gradle files as clean as possible with an external file like a version.gradle file in which there are all dependencies and their version.
buildscript {
apply from: 'versions.gradle'
...
}
You can find this version.gradle at the root of the project. This file is applied in the ./build.gradle
The developer decided to manage his dependencies in this way but you can find many others.
This article present 3 ways to do it.
Related
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha06'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
This is my build.gradle file and I tried many ways but I can't fix this, when I start Android Studio and gradle starts build the project Android Studio throw this error
how can I fix it?( I am new in Android)
Could not find method testImplementation() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
It is Google's fault.You need to use your countries letters.So use 'İ' instead 'I'.
testİmplementation 'junit:junit:4.12'
androidTestİmplementation 'androidx.test:runner:1.1.1'
androidTestİmplementation 'androidx.test.espresso:espresso-core:3.1.1'
Well, I know that's not the nicest solution for this but this is what worked. I simply commented these lines out:
//testImplementation "junit:junit:4.12"
//testImplementation "org.robolectric:robolectric:3.1.2"
Hope it helps =)
Can you provide your Gradle version and complete build.gradle ?
Possible issues:
You are missing a plugin definition
apply plugin: 'com.android.application'
or any plugin that implicitly uses the Java Plugin ? That's where the testImplementation comes from.
You're using < Gradle 3.x (testImplementation is not available in the previous releases)
Ensure you are using Gradle 3.x+ and that the top level build.gradle has Android Gradle Plugin 3.x+ defined in it :
https://developer.android.com/studio/releases/gradle-plugin#updating-plugin
Even though the documentation says
In your app's top-level build.gradle file, specify the following libraries as dependencies:
... I haven't found an example that works that way.
In fact, this GoogleSamples Android Unit Test example specifies:
// NOTE: Do not place your application dependencies here; they belong in the individual module build.gradle files
So, move that line to the module build.gradle, not the top-level build.gradle
100% working.
Replace testİmplementation with testImplementation.(İ with I or i)
in your dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha06'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
Syncing only active variant
You can disable this experimental feature from
File → Settings → Experimental → Gradle → Only sync the active variant
build.gradle file in replace :
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
Before
I didn't know implementation needs to be within dependencies in build.gradle
// build.gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
implementation 'org.springframework.boot:spring-boot-starter-actuator'
gs-spring-boot/initial [master●] » ./gradlew bootRun
FAILURE: Build failed with an exception.
* Where:
Build file '/home/geoff/work/androidStuff/gs-spring-boot/initial/build.gradle' line: 27
* What went wrong:
A problem occurred evaluating root project 'spring-boot'.
> Could not find method implementation() for arguments [org.springframework.boot:spring-boot-starter-actuator] on root project 'spring-boot' 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 1s
After
// build.gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}
gs-spring-boot/initial [master●] » ./gradlew bootRun
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.2.RELEASE)
The error is caused by gradle daemon start with user's locale (TR). Starting gradle daemon with EN locale will solve the problem.
In gradle.properties file set user language by updating the following line
org.gradle.jvmargs=-Xmx1536m -Duser.language=en
I solved this problem as follows, maybe it will work for you.
before
androidtestImplementation('androidx.test.espresso:espresso-core:3.4.0'
after
testImplementation('androidx.test.espresso:espresso-core:3.4.0'
before
andoidtestImplementation 'junit:junit:4.13.2'
after
testImplementation 'junit:junit:4.13.2'
Add Configurations -->template-->gradle--> Define gradle project field gradle project.
One of these 3 methods will work
1)
Project Structure > Project > and change
Gradle Version: 4.6
Android Plugin Version: 3.2.1
2)
change it testImplementation --> testİmplementation
testİmplementation 'junit:junit:4.12'
androidTestİmplementation 'com.android.support.test:runner:1.0.2'
androidTestİmplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
3)
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
Clean --> Rebuild
or
File --> Sync Project with Gradle Files
Make sure you pay attention to proper Camel Case. TestImplementation not testimplementation. Unless you follow that convention you will receive an error and it will drive you crazy
I've been using Firebase messaging and databases for my project. Using different dependencies and and their specific versions, the program synced completely and there was no gradle build errors.
After connecting the debugging device and trying to install the apk, the error comes as following.
error:program type already present:
com.google.android.gms.measurement.appmeasurementinstallreferrerreceiver
I am unable to proceed further and would really like a solution.I tried surfing the web but am unable to find one.
Not quite sure whats causing the problem,but the gradle dependencies are the ones causing this error. Modifying my build.gradle file as follows
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: "CordovaLib"))
implementation "com.android.support:customtabs:26.+"
implementation "com.android.support:support-v4:24.1.1+"
implementation "com.google.gms:google-services:+"
implementation "com.google.android.gms:play-services-tagmanager:11.0.4"
implementation "com.google.firebase:firebase-core:11.0.4"
implementation "com.google.firebase:firebase-messaging:11.0.4"
implementation "com.google.firebase:firebase-crash:11.0.4"
implementation "com.google.firebase:firebase-config:11.0.4"
implementation "com.google.firebase:firebase-perf:11.0.4"
implementation "com.google.android.gms:play-services-auth:11.0.4"
implementation "com.google.android.gms:play-services-identity:11.0.4"
implementation "com.android.support:appcompat-v7:23+"
// SUB-PROJECT DEPENDENCIES END
}
solved that error for me
I've develop a project using zxing to scan the barcode. I had followed the tutorial from here, but unfortunately I got error when I tried to run the project to device. The error that I get is
This is the build.gradle(app)
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'
// volley
compile 'com.android.volley:volley:1.0.0'
// butter knife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// QR Zxing Library
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
}
Below is External Libraries list.
After a day I tried to find out the solution, but everything failed. Then I decided to create a new project and copy the current source code together with build.gradle(app). Luckily no more error occurred when I run new project.
But I still don't know what the actual reason why I got that error before this, so I assume maybe some part of the old project are missing or have some bug on it.
Because at new project you change buildToolVersion
Reason : Its happened because being conflict between core.jar and zxing
Solution : Just change buildToolVersion and build , after that revert old toolVersion and build again !
After weeks of searching, the following steps help me resolve the issue like a charm:
1.Remove android platform.
2.Install cordova-plugin-facebook4
3.Create build.gradle in /plugins/cordova-plugin-facebook4/
4.Copy this
dependencies {
compile("com.facebook.android:facebook-android-sdk:4.37.0") {
exclude group: 'com.google.zxing'
}
}
to ../plugins/cordova-plugin-facebook4/build.gradle
5.Edit ../plugins/cordova-plugin-facebook4/plugins.xml change
to
6.Add platform android and build
I'm fairly new to Android development, so apologies if this is obvious. I've searched quite a lot but am unable to resolve my issue.
In my build.gradle file I have the following section:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:26.1.0'
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'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
}
However the line implementation 'com.android.support:appcompat-v7:26.1.0' is showing with a red squiggly line underneath and displaying the following message:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 25.3.1. Examples include com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 less... (⌘F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
I am unable to find out how to solve this issue. Building the project works fine and does not report any errors. I've tried doing File > Invalidate Caches / Restart but to no avail.
After doing a bit of searching I read that I can add implementation 'com.android.support:support-v4:26.1.0' to the build.gradle file and it should fix it, however the same error shows even after syncing.
This is an old project I made sometime last year and it doesn't have a lot in it, but I thought it would be better to learn how to resolve this issue rather than just creating a new project to get around it.
Try adding
implementation 'com.android.support:support-v13:26.1.0'
Although in your question, error is explaining everything, com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 are not having same version.
Should always keep support libraries version same in build.grdale.
implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.android.support:design:$support_lib_version"
implementation "com.android.support:support-v4:$support_lib_version"
implementation "com.android.support:cardview-v7:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
where support_lib_version is a constant.
ext { support_lib_version = '26.1.0'}
in same build.gradle file out side 'android' and 'dependencies'.
I need to use in my android instrumented tests mockito and powermock.
The main problem is that both of them have some problems with configuring it in gradle because of conflicts and other stuff.
Maybe somebody who has working configuration of .gradle file for mockito+powermock in android instrumented tests could share it?
This is my gradle configuration to use mockito and powerMock:
dependencies {
...
/**Power mock**/
testCompile "org.powermock:powermock-core:1.7.3"
testCompile "org.powermock:powermock-module-junit4:1.7.3"
testCompile "org.powermock:powermock-api-mockito2:1.7.3"
/**End of power mock **/
}
NOTE: I had to remove the mockito dependency in order to make it works:
//Remove this line
testImplementation "org.mockito:mockito-core:2.13.0"
Here is the configuration I am using and it's working perfectly fine.
after 1.7.0 powermock-api-mockito change to powermock-api-mockito2
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation "org.powermock:powermock-module-junit4:2.0.7"
testImplementation "org.powermock:powermock-module-junit4-rule:2.0.7"
testImplementation "org.powermock:powermock-api-mockito2:2.0.7"
testImplementation "org.powermock:powermock-classloading-xstream:1.6.6"