I'm running tests on android using gradle and we're migrating our framework to junit5 to take advantage of some of it's tagging and filtering capabilities. I've created the dependencies in my build.gradle files and I'm able to get it to build and run using the gutter icon in android studio, but I'm unable to run my tests from the command line. I get the following error.
* What went wrong:
Execution failed for task ':app:compileTestKotlin'.
> Could not resolve all files for configuration ':app:testCompileClasspath'.
> Could not find junit:junit:5.7.0.
Searched in the following locations:
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.pom
- https://jcenter.bintray.com/junit/junit/5.7.0/junit-5.7.0.jar
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.pom
- https://repo.maven.apache.org/maven2/junit/junit/5.7.0/junit-5.7.0.jar
Required by:
project :app
Here's my build.gradle at the app level
plugins {
id 'io.qameta.allure' version '2.8.1' // Latest Plugin Version
id 'java'
}
allure {
autoconfigure = true
version = '2.13.7' // Latest Allure Version
useJUnit5 {
version = '2.13.7' // Latest Allure Version
}
}
sourceCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
dependencies {
testImplementation(
'org.junit.jupiter:junit-jupiter-params:5.7.0',
'org.junit.jupiter:junit-jupiter-api:5.7.0'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
)
}
test {
useJUnitPlatform(){
includeEngines 'junit-jupiter'
}
}
apply plugin: 'kotlin'
test {
systemProperty 'platform', project.findProperty('platform')
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation "io.appium:java-client:7.2.0"
// implementation 'junit:junit:4.12'
implementation 'junit:junit:5.7.0'
}
and here's the build.gradle at the project level.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The error message says it. implementation 'junit:junit:5.7.0' is a non-existing dependency. Leave it away and it might already work.
Related
I attempted to import a project that Udacity's android course provided, but there were some issues. In the build.grade(app module) I changed compile toimplementation and testCompile to testImplementation. The project synced successfully, but when I executed the project on the emulator it gave me the following errors.
Could not find com.android.tools.build:aapt2:3.3.1-5013011.
Searched in the following locations:
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- file:/C:/Users/root/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
Required by:
project :app
I think the required libraries needed to build cannot be found, but I don't know how to solve this. I googled the problem, but I can't find a solution.
My build.gradle file is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
api 'com.android.support:appcompat-v7:23.3.0'
api 'com.android.support:support-v4:23.3.0'
api 'com.android.support:design:23.3.0'
}
build.grade(project) is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Beginning with Android Studio 3.2, the source for AAPT2 (Android Asset Packaging Tool 2) is Google's Maven repository.
To use AAPT2, make sure that you have a google() dependency in your build.gradle file.
allprojects {
repositories {
google()
jcenter()
}
}
Check the official documentation.
The AAPT2 (Android Asset Packaging Tool) is a build tool that Android Studio and Android Gradle Plugin.
Android Gradle Plugin 3.0.0 and higher enable AAPT2 by default.
With Android Studio 3.2 to use AAPT2, make sure that you have a google() dependency in your build.gradle:
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
} allprojects {
repositories {
google() // and here
jcenter()
}
I am using a beta Kotlin and Android-Studio channel. After update to the latest version i got some gradle sync error.
Below are the log i copied from Event Log:
Error:Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0-rc-39.
Searched in the following locations:
file:/home/yourpc/Android/android/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
file:/home/yourpc/Android/android/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.pom
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0-rc-39/kotlin-gradle-plugin-1.2.0-rc-39.jar
Required by:
project :
below is the build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.0-rc-39'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha04'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
below is the app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.udebest.myapplication"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Please, anyone has an idea about this? I don't really know how can I solve this? I could not find any solutions out there.
Change your repositories in buildscript and allprojects into:
{
google()
jcenter()
mavenCentral()
maven {
url 'https://dl.bintray.com/kotlin/kotlin-dev/'
}
}
This works for me.
First, I updated Kotlin plugin thru tool, Kotlin, configure kotlin plugin update.
After, in App directory, in build.Gradle file search:
repositories {
// You need to add the following repository to download the
// new plugin.
google()
}
I add a new repository
maven { url 'C:/Program Files/Android/Android Studio/gradle/m2repository/'}
this is the path thru my local directory where the resources are. After this try again to sync
Change and try
classpath 'com.android.tools.build:gradle:3.1.0-alpha04'
to
classpath 'com.android.tools.build:gradle:3.0.0'
It may be due to the alpha release of gradle.
Use below version of kotlin in build.gradle(Project)
kotlin_version = '1.1.4-3'
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Declare dependency of kotlin in build.gradle(Module) as below
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
check your Kotlin version in build.gradle.
I got the same issue when the version was 1.1.0 which was added by default.
changed to recent version 1.3.21 then it is working fine.
This solution has worked for me for React Native(0.63) after installing react-native-image-picker by Ray Eldath, from above comment
//in android.build.gradle
{
google()
jcenter()
mavenCentral()
maven {
url 'https://dl.bintray.com/kotlin/kotlin-
dev/'
}
}
First, close Android studio, delete the .gradle folder, and then open Android Studio again, probably as an administrator
This will make it sync from the start, and solve the issue.
This issue was resolved for one of my peers.
Uninstall the Kotlin plugin (Preferences > Plugins > Kotlin > Uninstall) and use the version that comes with the IDE .
I have a project that need to use protobuf (Getting the objects from server and parsing them).
For that I configured the following things:
Project level gradle.build
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0'
classpath 'com.google.protobuf:protobuf-java:2.6.1'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level gradle.build
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.protobuf'
android {
...
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:2.6.1'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.protobuf:protobuf-java:2.6.1'
compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.0'
}
I put my proto file under .../app/src/main/proto/FILE.proto.
Once i am trying to build the project I am getting the following error:
Error:Execution failed for task ':app:generateDebugProto'.
> protoc: stdout: . stderr: /Users/XX/YY/app/build/extracted-protos/main: warning: directory does not exist.
/Users/XX/YY/app/build/extracted-include-protos/main: warning: directory does not exist.
...
protoc-gen-javanano: program not found or is not executable
--javanano_out: protoc-gen-javanano: Plugin failed with status code 1.
Any idea why is that? It should use the protoc from the repo and is should support that nano compilation.
Thanks.
Finally i downloaded the source from GitHub and compiled it. It fixed the issue because it includes the missing binary.
My Android project was working well before two days with material dialog library 0.7.6.0, but from last two days gradle sync fail with
Error:(32, 13) Failed to resolve: com.afollestad:material-dialogs:0.7.6.0
So as per solutions on stack overflow I followed new library, but still Gradle can't build successfully.Here is my Gradle dependencies:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:support-v4:22.1.0'
compile('com.afollestad.material-dialogs:core:0.8.1.0#aar') {
transitive = true
}
}
If you're using Android Plugin for Gradle 3.0 or latter version
dependencies {
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
}
buildscript {
repositories {
google()
jcenter()
}
allprojects {
repositories {
/* removed maven repo from here */
google()
jcenter()
}
}
My Reference Link here [Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)
Modify dependency
compile('com.afollestad.material-dialogs:core:0.8.5.2#aar')
I unable to build gradle with 0.8.5.2 version.
I use Custom classes from material-dialogs-0.6.1.3, its working fine in my application.
I have an artifact that has been published to my local Artifactory repository and now I am trying to pull that artifact into a project with gradle.
However, I keep getting the following error:
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.company.app:myapplication:1.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/company/app/...pom
https://jcenter.bintray.com/com/company/app/...jar
file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/company/app...pom
file:/Users/user/Library/Android/sdk/extras/android/m2repository/com/company/app...jar
file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/company/app...pom
file:/Users/user/Library/Android/sdk/extras/google/m2repository/com/company/app....jar
This error suggests that it's not even looking at the local artifactory repository. Below are my build.gradle files
Project Level build.gradle
buildscript {
repositories {
jcenter()
maven {
url '${artifactory_contextUrl}/libs-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.0"
}
}
allprojects {
repositories {
jcenter()
}
}
App Level build.gradle
allprojects{
apply plugin: "com.jfrog.artifactory"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.company.app:myapplication:1.0.0'
}
The issue was
The maven url needs to be outside of the buildscript
The maven url needs to be in the App level, not Project level build.gradle
Below are my current build.gradle files that work:
Project Level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
App Level build.gradle
repositories {
maven {
url '${artifactory_contextUrl}/libs-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.company.app:myapplication:1.0.0'
}
NOTE: I removed the jfrog plugin because it's only needed if you are publishing to Artifactory.