in my application i want to use this below pasted code as PicassoCache, but after use that such as :
PicassoCache.getPicassoInstance(context)
.load(list.get(position).getStoreImage())
.placeholder(R.drawable.ic_messages)
.into(holder.store_avatar);
i get this error:
Could not find class 'com.squareup.okhttp.CacheControl$Builder', referenced from method com.squareup.picasso.OkHttpDownloader.load
06-12 01:13:17.484 6246-6246/ir.pishguy.signalpresentationproject E/AndroidRuntime: FATAL EXCEPTION:
main java.lang.NoClassDefFoundError: com.squareup.okhttp.OkHttpClient
PicassoCache:
import com.squareup.picasso.Downloader;
import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;
public class PicassoCache {
private static Picasso picassoInstance = null;
private PicassoCache(Context context) {
Downloader downloader = new OkHttpDownloader(context, Integer.MAX_VALUE);
Picasso.Builder builder = new Picasso.Builder(context);
builder.downloader(downloader);
picassoInstance = builder.build();
}
public static Picasso getPicassoInstance(Context context) {
if (picassoInstance == null) {
new PicassoCache(context);
return picassoInstance;
}
return picassoInstance;
}
}
My gradle:
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'android-command'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "ir.pishguy.signalpresentationproject"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
command {
events 2000
}
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
ext {
supportLibVersion = '23.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.picasso:picasso:2.5.2'
compile('io.socket:socket.io-client:0.7.0')
{
// excluding org.json which is provided by Android
exclude group: "org.json", module: "json"
}
compile ('com.squareup.retrofit2:retrofit:2.0.2'){
exclude module:'okhttp'
}
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.devlight.navigationtabbar:library:+'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile "de.hdodenhof:circleimageview:2.0.0"
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
compile "com.balysv:material-ripple:1.0.2"
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.github.chyrta:AndroidOnboarder:+'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:multidex:1.0.1'
}
For me combination
// Retrofit
compile('com.squareup.retrofit2:retrofit:2.0.2') {
exclude module: 'okhttp'
}
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
// Picasso
compile 'com.squareup.picasso:picasso:2.5.2'
works well, but here some answers said that
compile 'com.squareup.okhttp:okhttp-urlconnection:x.x.x'
may help.
Try the following combination, it's working for me :
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
Hope it will work for you :)
Related
I am new in android app development. I have to store a android library in bintray but I am not getting file upload option. What should I do so that I can get file upload option? my android library's build.gradle file is below
apply plugin: 'com.android.library'
apply plugin: 'realm-android'
ext {
PUBLISH_GROUP_ID = 'cyd.awesome.android'
PUBLISH_ARTIFACT_ID = 'awesome-material'
PUBLISH_VERSION = '1.0'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true // shrink
useProguard true // don't obfuscate
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' http://stackoverflow.com/ }
} }
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'
})
androidTestCompile ('com.android.support.test:runner:0.3') {
exclude group: 'com.android.support', module: 'support annotations'
}
androidTestCompile ('com.android.support.test:rules:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.android.support:appcompat-v7:25.1.0'
//network
compile 'com.squareup.okhttp:okhttp:2.5.0'
//beacon
compile 'org.altbeacon:android-beacon-library:2.+'
//geofence
compile 'com.google.android.gms:play-services-location:10.0.1'
//firebase
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
//parsing json
compile 'com.google.code.gson:gson:2.8.0'
//compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
//testing
testCompile 'junit:junit:4.12'
//testCompile 'org.mockito:mockito-core:1.9.5'
//testCompile "org.robolectric:robolectric:3.0"
//reactive
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
//beacon Monitoring
//compile 'org.altbeacon:android-beacon-library:2+'
//disk storage
//compile 'com.squareup.sqlbrite:sqlbrite:1.1.1'
//compile 'com.github.satyan:sugar:1.4'
//geofire
//compile 'com.firebase:geofire-android:2.1.1'
}
apply plugin: 'com.google.gms.google-services'
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
A week ago I started implement Chat System to my app using Smack API (4.1.8 version). And It works well on Lolipop device and Marshmallow too. But on Kitkat( API 19) I get exception NoClassDefFoundError
LogCat:
Process: mobi, PID: 23510
java.lang.NoClassDefFoundError: org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration
at mobi.networking.ChatXMPPConnection.connect(ChatXMPPConnection.java:76)
at mobi.networking.ChatXMPPService.initConnection(ChatXMPPService.java:80)
at mobi.networking.ChatXMPPService.access$100(ChatXMPPService.java:36)
at mobi.networking.ChatXMPPService$1.run(ChatXMPPService.java:112)
at java.lang.Thread.run(Thread.java:841)
So what is it on the line 76(the first line):
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(mUsername, mPassword);
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setResource("Android");
configBuilder.setServiceName(DOMAIN);
configBuilder.setHost(HOST);
configBuilder.setPort(PORT);
My build-gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
dataBinding
{
enabled = true
}
defaultConfig {
applicationId "mobi"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.1'
compile 'com.android.support:design:24.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.support:recyclerview-v7:24.0.1'
compile 'com.zaihuishou:expandablerecycleradapter-databinding:1.0.0'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-SNAPSHOT'
compile 'com.kyleduo.switchbutton:library:1.4.1'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.github.Kennyc1012:BottomSheet:2.3.1'
compile 'com.aurelhubert:ahbottomnavigation:1.3.3'
compile 'com.vk:androidsdk:1.6.5'
compile 'com.brucetoo.pickview:library:1.2.2'
compile 'gun0912.ted:tedpermission:1.0.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.basgeekball:awesome-validation:1.3'
compile 'com.google.code.gson:gson:2.4'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.github.aakira:expandable-layout:1.6.0#aar'
compile 'fr.xebia.android.freezer:freezer:2.0.3'
provided 'fr.xebia.android.freezer:freezer-annotations:2.0.3'
apt 'fr.xebia.android.freezer:freezer-compiler:2.0.3'
compile "me.henrytao:smooth-app-bar-layout:24.2.1.0"
compile ("org.igniterealtime.smack:smack-android-extensions:4.1.8") {
exclude group: 'xpp3', module: 'xpp3'
}
compile ("org.igniterealtime.smack:smack-tcp:4.1.8"){
exclude group: 'xpp3', module: 'xpp3'
}
compile ("org.igniterealtime.smack:smack-experimental:4.1.8"){
exclude group: 'xpp3', module: 'xpp3'
}
}
}
also, my libs folder is empty. I don't use jar-files
Link to Smack-Wiki https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide#using-eclipses-android-development-tools-adt-ant-based-build
Please, help, I loose two days on fixing it
I was also facing the same issue.
Try adding the following dependency:
compile 'com.android.support:multidex:1.0.1'
and in your application class add this,
#Override
protected void attachBaseContext(Context base)
{
super.attachBaseContext(base);
MultiDex.install(BaseApplication.this);
}
i read more solutions about this problem but my problem couldn't resolve. its happened after add more library such Dagger and Realm on my project
Full stack error:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/internal/widget/TintManager;
at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1179)
at android.support.design.widget.TabLayout.createTabView(TabLayout.java:655)
at android.support.design.widget.TabLayout.addTabView(TabLayout.java:690)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:385)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:360)
at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:644)
at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:615)
UPDATED:
My gradle file content :
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.pishguy.androidapplication.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
project.ext {
supportVersion = '24.2.1'
daggerVersion = '2.0.1'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile("com.android.support:support-v4:$supportVersion") {
force = true;
}
compile "com.android.support:appcompat-v7:$supportVersion"
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile('io.socket:socket.io-client:0.7.0') {
exclude group: "org.json", module: "json"
}
compile('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.bugsnag:bugsnag-android:+'
compile 'com.facebook.rebound:rebound:0.3.8'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.jaredrummler:android-device-names:1.0.9'
compile 'org.sufficientlysecure:html-textview:1.6'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.kogitune:pre-lollipop-activity-transition:1.3.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.alexvasilkov:foldable-layout:1.2.0'
compile 'cat.ereza:customactivityoncrash:1.5.0'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.3'
compile 'com.github.goka.flickableview:flickableview:1.0.0'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.github.justzak:dilatingdotsprogressbar:1.0.1'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:0.6.5'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.tumblr:backboard:0.1.0'
compile "com.google.dagger:dagger:${daggerVersion}"
apt "com.google.dagger:dagger-compiler:${daggerVersion}"
provided 'javax.annotation:javax.annotation-api:1.2'
compile project(':lib-searchview')
}
how can i resolve this problem?
Replace
compile("com.android.support:support-v4:${supportPackageVersion}") {
force = true;
}
compile "com.android.support:appcompat-v7:${supportPackageVersion}"
with
compile 'com.android.support:appcompat-v7:23.1.1'
May be it will help you.
Support library versions from RxBinding:
supportVersion = '24.2.1'
supportAnnotations = "com.android.support:support-annotations:$supportVersion"
supportV4CoreUi = "com.android.support:support-core-ui:$supportVersion"
supportRecyclerView = "com.android.support:recyclerview-v7:$supportVersion"
supportAppCompat = "com.android.support:appcompat-v7:$supportVersion"
supportDesign = "com.android.support:design:$supportVersion"
supportLeanback = "com.android.support:leanback-v17:$supportVersion"
Your current build.gradle support version:
project.ext {
supportPackageVersion = '24.0.0'
You should update to 24.2.1.
I have multidex enabled and i am using org.apache.http.legacy.jar and added jumblr gradle path in my gradle file.I am getting exception
Error:Execution failed for task :app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/codec/binary/Base64.class
I think this is because jumblr is also using the http legacy library so i think i need to explicitly remove http legacy library from jumblr gradle path. Kindly let me know on how to remove specific file/jar/class from a gradle path.
Update
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.0"
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
debug {
shrinkResources true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// configurations {
// all*.exclude group: 'org.apache', module: 'commons'
// }
}
dependencies {
// Enabling multidex support.
compile 'com.android.support:multidex:1.0.1'
//Other Libraries
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/okhttp-2.2.0.jar')
compile files('libs/okhttp-urlconnection-2.2.0.jar')
compile files('libs/okio-1.2.0.jar')
compile files('libs/volley.jar')
compile files ('org.apache.http.legacy.jar')
compile files('libs/universal-image-loader-1.9.0.jar')
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.pkmmte.view:circularimageview:1.1'
// compile 'com.github.satyan:sugar:1.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.googlecode.mp4parser:isoparser:1.0.5.4'
compile 'org.bytedeco:javacv:1.0'
compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-x86'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-x86'
compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-arm'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-arm'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
compile project(':vidEffect')
// For Endless adapter
compile 'com.commonsware.cwac:adapter:1.0.+'
compile 'com.commonsware.cwac:endless:1.2.3'
// For Facebook
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
// For Twitter
compile('com.twitter.sdk.android:twitter:1.8.0#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
// For Tumblr
compile files('libs/signpost-commonshttp4-1.2.jar')
compile files('libs/signpost-core-1.2.jar')
compile 'com.google.guava:guava:18.0'
compile project(':ViewPagerIndicator')
compile ('com.tumblr:jumblr:0.0.11'){
transitive = true;
exclude module: 'Base64';
}
//Incase we have no choice but to use source code
// compile project(':jumblr')
}
I think you can use exclude
compile('jumblr.jar') {
transitive = true;
exclude module: 'Base64';
}
OR
compile ('com.tumblr:jumblr:0.0.11') {
transitive = true;
exclude module: 'Base64';
}
When executing ./gradlew clean connectedAndroidTest with the following configuration... I'm getting No tests found
This is my build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.1'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
}
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LGP2.1'
exclude 'META-INF/LGPL2.1'
}
compileSdkVersion 21
buildToolsVersion "21.1.0"
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "com.example"
minSdkVersion 9
targetSdkVersion 21
versionCode 2
versionName "0.1"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
}
}
sourceSets {
androidTest {
setRoot('src/espressoTest')
}
}
}
apply plugin: 'android-unit-test'
dependencies {
// App
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.code.gson:gson:2.2.4'
compile 'de.greenrobot:eventbus:2.0.2'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup:otto:1.3.5'
compile 'com.google.guava:guava:18.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.wrapp.floatlabelededittext:library:0.0.3'
compile 'com.daimajia.swipelayout:library:1.0.7#aar'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'info.hoang8f:android-segmented:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.1.2#aar'
compile 'com.balysv.materialmenu:material-menu-toolbar:1.4.0'
// Espresso
androidTestCompile files('lib/espresso-1.1.jar', 'lib/testrunner-1.1.jar', 'lib/testrunner-runtime-1.1.jar')
androidTestCompile 'com.google.guava:guava:14.0.1'
androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.1'
// Robolectric
testCompile('junit:junit:4.11') {
exclude module: 'hamcrest-core'
}
testCompile files('lib/robolectric-2.4-SNAPSHOT-jar-with-dependencies.jar')
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'com.squareup:fest-android:1.0.+'
testCompile 'com.googlecode.catch-exception:catch-exception:1.2.0'
}
tasks.findByName("assembleDebug").dependsOn("testDebugClasses")
This is the class for the tests under src/espressoTest:
package com.example;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import com.betavalue.myvalue.MainActivity;
import com.betavalue.myvalue.R;
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
#LargeTest
public class MainEspressoTest extends ActivityInstrumentationTestCase2<MainActivity> {
#SuppressWarnings("deprecation")
public MainEspressoTest() {
// This constructor was deprecated - but we want to support lower API levels.
super(MainActivity.class);
}
#Override
public void setUp() throws Exception {
super.setUp();
// Espresso will not launch our activity for us, we must launch it via getActivity().
getActivity();
}
public void testCheckText() {
onView(withId(R.id.text))
.check(matches(withText("Hello Espresso!")));
}
}
And MainActivityis an empty Activity just to try testing.
Any ideas? Is there something on the AndroidManifest.xml I could be missing?
If anyone is having this issue... It just solved automatically when pulling it from my repository again.
It had to do something with Android Studio cache.