Hi I am using roboelectric for unit testing of my android application. I want to compare expected intent and actual intent using assertj-android. I have added required dependency of assertj-android, even though I have done Gradle sync multiple times but still unable to import org.assertj.android.api.content.IntentAssert.
What could be the issue ? Any idea ? Thanks in advance
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.2.2'
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
androidTestCompile 'com.squareup.assertj:assertj-android:1.1.1'
}
AssertJ dependency in your build.gradle is for androidTest and it should be for test since you're using Robolectric?
Related
I'm getting the following error
Error:(17, 0) Could not find method compile() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I stumbled upon this error after importing a previous project done on an earlier version of Android Studio.
I. Upgrade your build tools version to 3.0.1 or later so that it recognizes the terms testImplementation , androidTestImplementation, implementation
II. Edit your build.gradle app file so that all implementation are replaced with compile
Previous
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.0.2'
testImplementation 'junit:junit:4.12'
// RecyclerView
implementation 'com.android.support:recyclerview-v7:27.0.2'
Should now read
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.2'
testImplementation 'junit:junit:4.12'
// RecyclerView
compile 'com.android.support:recyclerview-v7:27.0.2'
The above solution then generates an error about Aapt that is then fixed by adding the line below in the gradle.properties file
android.enableAapt2=false
Wonder if this was a fluke or it works every time
I've the below dependence in my Android app build.gradle
compileSdkVersion 25
buildToolsVersion "25.0.2"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
but getting an error about versions compatibility, as shown below, what is the one to be changed here, i could not figure it out :(
I had same problem what i did was compile the higher version of libraries ,which were creating this error,in app:gradle only.
for example in your case
compile 'com.android.support:mediarouter-v7:25.0.0'
Add this in app:gradle.
There may be more like this mediarouter libraries if it still give error add them jst like this(making them higher version).
First you need to find out where's what consists of a conflicting version of the library. The easiest way to do so is to:
Open Terminal pane in your Android Studio.
Type in: ./gradlew androidDependencies
Find the row that represents the ENCLOSING library consisting of a conflict.
Then just use exclude statement for the conflicting library, like so:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
(the example assuming com.android.support.test.espresso:espresso-core:2.2.2 was the ENCLOSING library, and com.android.support:support-annotations being the conflict)
Every time I create a new Activity in AS 2.3 it messes up the build.gradle indentation that results in errors like this.
Error:Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I have to redo the indentations every time. Any idea how to fix this permanently?
Don't use compile as a property and don't change the gradle structure.
compile 'com.android.support:appcompat-v7:22.2.1' compile
'com.parse:parse-android:1.11.0'
Sometimes Gradle build messes up the code like above, it still happens. Probably related to Java JDK updates.
The problem seems to be caused by the lines which contain curly braces like:
compile('com.github.tony19:logback-android-core:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
In order to avoid the bug just put all the lines with curly braces above the "usual" (i.e. compile 'something') lines like this:
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.github.tony19:logback-android-core:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
compile('com.github.tony19:logback-android-classic:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
compile 'com.bolyartech.forge.android:forge-android:6.1.0'
compile 'com.bolyartech.scram_sasl:scram_sasl:2.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup:otto:1.3.6'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.franmontiel:PersistentCookieJar:v0.9.3'
compile 'com.google.dagger:dagger:2.9'
...
I have recently updated my Android Studio version to 2.3
I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.
I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;
This is are my dependencies from build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?
Thank you.
You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.
I add viatmio library using gradle in android studio V2.2 .
It crash at
if (!LibsChecker.checkVitamioLibs(this))
with exception like
couldn't find "libvinit.so"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'me.neavo:vitamio:4.2.2'
testCompile 'junit:junit:4.12'
}
Need any suggestions or correction.
Thanks
Download latest version of Vitamio from Official Web site and Add this line to initiate
Vitamio.isInitialized(this);