Incompatible JUnit tests with greenDAO - android

when I add greenDao Library in my proyect, my project doesn't work, because I have Junit test.
testCompile 'junit:junit:4.12'
compile ('de.greenrobot:DaoGenerator:1.3.0')
Any idea?

I fix my problem, I change this
compile ('de.greenrobot:DaoGenerator:1.3.0')
to
compile('de.greenrobot:greendao:1.3.7')

Related

Android: Program type already present: com.google.zxing.BarcodeFormat

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

How Do I Resolve android.arch.lifecycle:common Version Conflicts?

Given a project with this set of dependencies:
dependencies {
compile "com.android.support:recyclerview-v7:26.1.0"
compile "com.android.support:support-core-utils:26.1.0"
compile "com.android.support:support-fragment:26.1.0"
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'android.arch.lifecycle:runtime:1.0.0'
compile 'android.arch.lifecycle:extensions:1.0.0-beta2'
compile 'android.arch.lifecycle:reactivestreams:1.0.0-beta2'
compile "android.arch.persistence.room:runtime:1.0.0-beta2"
compile "android.arch.persistence.room:rxjava2:1.0.0-beta2"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-beta2"
androidTestCompile "com.android.support:support-annotations:26.1.0"
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'android.arch.core:core-testing:1.0.0-beta2'
androidTestCompile "com.android.support:support-core-utils:26.1.0"
androidTestCompile "com.android.support:support-compat:26.1.0"
}
I am getting the following error:
Error:Conflict with dependency 'android.arch.lifecycle:common' in project ':app'. Resolved versions for app (1.0.2) and test app (1.0.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
How do I resolve this?
Artifact dependency inconsistencies are a common problem, and I expect this to be a frequent issue with the Architecture Components, given that the versioning of those components is byzantine1.
In this case, there is an undocumented version 1.0.2 of the undocumented android.arch.lifecycle:common artifact.
android.arch.lifecycle:extensions:1.0.0-beta2 and android.arch.lifecycle:reactivestreams:1.0.0-beta2 depend upon this undocumented version 1.0.2 of the undocumented android.arch.lifecycle:common artifact. However, the corresponding test artifact (android.arch.core:core-testing:1.0.0-beta2) depends on version 1.0.0 of android.arch.lifecycle:common. As a result, we get the conflict.
The workaround is to manually request 1.0.2 for the test code, via:
androidTestCompile 'android.arch.lifecycle:common:1.0.2'
Gradle will now use 1.0.2 for both the main code and the test code, and all is well.
1 The term "byzantine" is used to describe something that is unnecessarily complex. The Byzantines might have described complex things with the phrase "like the versioning system of the Architecture Components", had those components existed back then.

Mockito+PowerMock gradle configuration

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"

dependencies compiled using androidTestCompile are not recognized

I am trying to integrate robotium-solo 5.5.4 into my project.
If i run this line:
compile 'com.jayway.android.robotium:robotium-solo:5.5.4'
then everything is fine,
however if I run this line:
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4'
it is like the dependency is not there.
What can I do to fix the problem ?
Try
testCompile
instead of
androidTestCompile

Android Unable to execute dex error after cloning correct project

This is a really strange problem and I've been days stuck with it: we've got a working project (no errors whatsoever) in a git repository. Everything is OK (it's even published in Google Play) when executing the project from the creator's equip, but, when we try to clone it in a different equip (we've tried Mac, Linux and Windows), this exception is thrown:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Hereafter, even if we apply the multidex solution as described in Android Developers or delete the unused dependencies, the app raises an exception when trying to load class android.support.design.widget.NavigationView (coming from a NoClassDefFound in runtime).
I suspect maybe it has something to do with the gradle plugin or appcompat libs version, but so far, nothing we've tried has worked.
Edit: This is not a common multiDex error, I'm pretty familiarized about how to solve them, it's about one computer executing the app without problems but when you clone the same project from git in other computer, it won't run and the MultiDex error is thrown.
EDIT 2: mi dependenvy list is as follows (I ommit the company libs but they're not the problem
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mo2o.third:valnif:1.0.0'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile('com.afollestad.material-dialogs:core:0.8.0.1#aar') {
transitive = true
}
compile 'com.android.support:percent:23.0.0'
compile 'se.emilsjolander:stickylistheaders:2.6.0'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile "com.google.android.gms:play-services-gcm:8.3.0"
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'

Categories

Resources