FAILURE: Gradle Build failed with an exception - android

I have included the new Android library module (dmxmediapicker) project into my currently working library project (Myapplication), which I have used as a library for my Android module (NormalProject). But after including the Library module, gradle failed to build, and also it showed the The input line is too long exception. How do I fix this?
Exception
:Myapplication:preDexDevDebug
:Myapplication:dexDevDebug
The input line is too long.
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Myapplication:dexDevDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\INO37\AppData\Local\Android\sdk\build-tools\19.1.0\dx.bat --dex --no-optimize --output D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\dex\dev\debug D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\classes\dev\debug D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-787d89f55747f839e6edf29f29d38d35f17b3a30.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\support-annotations-20.0.0-240aab9bab6593b41d1b3b540c6045232da1fa77.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\cwac-sacklist-1.0.1-dda711d827778efe1c760bdb948ba1a39acfd793.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\converter-jackson-1.5.1-f30ef27d5fcffccb406fd4debc4dd598df411298.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\annotations-12.0-b5b365c95aae0dd9d05b7150051dc81ac4a66207.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-6332debc38975f95cd72b9fb79d4ef959550aafc.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\android-viewbadger-6be9349f633a8c52e4e84a7473b884c75df7646f.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\cwac-merge-1.0.4-1690f7eaf3148874821653f2b44eb043d6dfac24.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-9663eb2427df2a79f7656f8997524dff6aba8ed3.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\robospice-retrofit-1.4.12-7add9ad83809cfec85130664e3f0f8d8f4db3812.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-annotations-2.3.1-12e826dc80ebd316473afbc007d5d62fb9ca931f.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\apktool-lib-1.4.4-3-8ee8794680007892ea0aa71ccf4f62f403b090c0.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-80d40aaa7e9898a9b07a24730ef98c587235ea59.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\slf4j-api-1.7.6-b9d683e8b480a08f5408a9b52ef0e5c371ce1989.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\eventbus-2.2.1-b9680385a60ef0d57864db42aa7b408c98a39042.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-40c97f3059c5dbf257683f47006900cf32413fef.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\bolts-android-1.1.2-441bafc5a672d6d05e9a4e94445d14df854efa44.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\robospice-cache-1.4.12-5cfde6eacf18940c1fb4721fafddd2699e39e6c8.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\vixlet-core-536faacbfbdc9433aee1f435fdb78fcd538268f9.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\parent-app-template\build\intermediates\pre-dexed\dev\debug\library-2.6.0-6a4e906d7bcdb8616d57e8a005349bc659a4824e.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\robospice-1.4.12-003969d6ebfe39f32a146d77d99400c5484dc106.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\retrofit-1.5.1-10a09668d9b0d5fe5ca0227e21727fd008a69d4c.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\internal_impl-20.0.0-6592f598898c5eae47b6699221e16f83ae130dd0.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\library-2.4.0-99f385b1bc28f43ad47d88dcaaee564612041d59.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\commons-io-1.3.2-c3e895cac4d0af50751028ec6b5cf91e13a11944.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\logback-android-classic-1.1.1-2-e37f9f12967b461668ea7a08aa31566dc647e9cb.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\universal-image-loader-1.9.2-30f8c46db3505acf9c16140d5124dce613db573a.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-core-2.3.1-569c0b6fff725c0772a2544b76c505956a040cb3.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\logback-android-core-1.1.1-2-ba8bc87e327fe59477b1a30abe6b447e438a32c5.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\okhttp-1.5.4-41055e1ec4b4b9e132ba9b71d7cc04e5a8a5553d.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\twitter4j-core-4.0.2-84defff66a9193544b9ef0f2c15565686a93cf7b.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-0cf819e9a2eb35706dd00dfff8f168e26bb6a9e5.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\commons-lang3-3.3.2-c4491073f0be9d854ecd8b34d316f7f2bc02ca21.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-ce1a88d8493673e442b95c84f6ac34b0b16fd5e4.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-499ae4fd3a32c9bb92892715a01ef3a35567e56c.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\classes-2b5d899cfe71f40eb1264e9826473d56e636ace6.jar D:\Jamal\Workspaces\AndroidStudioProjects\Workspace\From_GH_19_12_AND_63\Myapplication\build\intermediates\pre-dexed\dev\debug\jackson-databind-2.3.1-ad7662486febdd462bc1d048504a9658311ead09.jar
Error Code:
255
Output:
The input line is too long.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
biuld.gradle for dmxmediapicker
apply plugin: 'android-library'
android {
compileSdkVersion 20
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 12
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.0'
}
biuld.gradle for MyApplication
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion "19.1.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
minSdkVersion 12
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile project(":dmxmediapicker")
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
}
biuld.gradle for NormalProject
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "19.1.0"
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
dev {
}
staging {
}
production {
}
}
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 12
targetSdkVersion 20
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
debug {
debuggable true
signingConfig signingConfigs.test
}
release {
debuggable false
signingConfig signingConfigs.release
}
}
}
dependencies {
compile project(':MyApplication')
}

As per ligi's comment
I have set the buildToolsVersion As 21.1.1 now the build issue have been solved.

After installing openjdk-11-jdk my problem solved
sudo apt-get install openjdk-11-jdk
NOTE: before installing jdk11 uninstall any other jdks
For example
sudo apt autopurge openjdk-19-jdk:amd64 openjdk-19-jdk-headless:amd64 openjdk-19-jre:amd64 openjdk-19-jre-headless:amd64

This will solve your problem
In Android Studio, go to Tools->SDK manager and see that your android version is downloaded or not (for whatever emulator you have chosen as your virtual device).
If not download it and play the emulator again.
This should work now!!

In my case, the files of my android folder was misconfigured as I did some changes before.
I Just created a new flutter app and copied the android folder from the new created app and pasted it to my previous flutter project and that worked.
I know this is not an appropriate way to solve the problem but at least this solution could be useful in case you need to make it quick.

Related

Build complete and running but showing error on class android

i have some strange error / bug on android studio, my application gradle is complete and running smoothly on device but its showing error like my library is not completely include on android studio, i already do
Clean then Rebuild
Invalidate Cache and restart
but nothing work, this is the screenshot
This is My App Gradle
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.host.appname"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
and this is my project gradle
buildscript {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So i can run my application, i can use it but its really disturbing for me to do code because i cannot use autocomplete regarding the error libs and red marks everywhere .
Thank You..
Remove the lines and re-import them from correct/compatible packages.
Try removing all dependencies then sync and add all dependencies again then sync.
As you mentioned in comments nimi0112 and Ali Ahmed's your answer is really helped me a lot.

Gradle dependency causing error "Invalid Magic Number"

I have a project on GitHub that I work on both in the office at home. For about 2 months it was working fine on both machines. Then two weeks ago, it stopped running on my home PC, but still works fine on my work PC.
This is the error I get:
:app:shrinkDebugMultiDexComponents FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:shrinkDebugMultiDexComponents'.
java.io.IOException: Can't read [D:\dev\gitRepo\app\android\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [__MACOSX/com/stripe/android/._BuildConfig.class] (Invalid magic number [51607] in class))
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The stripe package that is giving me errors is a 3rd party library that you can find here. I list it as a dependency in my build.gradle file exactly as they say to.
compile 'com.stripe:stripe-android:+'
I have commented out all code pertaining the stripe and the app runs completely fine, so I do know it has something to do with how I am handling that package.
Unfortunately I don't remember exactly what I had done to make this stop working. I do think that the week before this happened I upgraded Android Studio, and spent a considerable amount of time messing with ProGuard configurations.
What I have tried:
Working on the master branch where no ProGuard changes have been made.
Uninstalling and Reinstalling Android Studio
Re-cloning the git repo
Installing API 17 (stripe for eclipse requires this. Not Studio but I gave it a shot).
Contacting stripe customer support but they had no clue.
This stack overflow post. However, there is no Mac computer that has touched the project nor have I personally zipped anything related to stripe.
From here, converted the magic number from Hex to ASCII. The result was Q` which I do not recognize.
I think it may have something to do with something I did for ProGuard, but I don't understand how. I'm on a completely different branch than any Proguard work, with a clean AndroidStudio install, with a clean repository clone, and the project still works fine when I'm in the office.
EDIT
I am running this on the debug BuildType. These are my 3 gradle files. The first is for the entire Project, the second is for the Application Module, and the third is for a local android library Module.
Project build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
maven{ url 'http://download.crashlytics.com/maven' }
}
}
Android Application Module build.gradle
buildscript {
repositories {
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' }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.android"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
debug {
buildConfigField 'Boolean', 'enableCrashlytics', 'false'
}
adhoc {
debuggable true
signingConfig signingConfigs.debug
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile project(':localLibrary')
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'commons-io:commons-io:2.4'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:22.0.1'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'io.card:android-sdk:5.0.1'
compile 'com.stripe:stripe-android:+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
Local Android Library Module build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:multidex:1.0.0'
compile group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
}
This problem is probably related to the version of Java that you are running. I had a similar problem and discovered that Java 8 was used for the build. When I changed to Java 7, this build problem was fixed.
In Android Studio go to
File -> Project Structure -> SDK Location
The JDK Location should be Java 1.7.x (Java 7)
Yeah verify both machines have the same Java version, and indeed the same version of Android Studio. The only other thing I can think of is that maybe Stripe is using the build tools bundled with AS to build your apk, and the ones you have installed by default differ slightly and are missing something - see this post I made on a similar problem I had.

Android app is only running when compiled using older maven repository

I`m working on a project that compiles correctly but crashes on start when I set new maven repository on build.gradle file.
The project is using the lib holoeverywhere, and it crashes with the error: java.lang.NoClassDefFoundError: android.support.v4.app._HoloFragmentInflater$1
Until last month, everything was working fine, but suddenly the older company repository went offline and we created a new one. Now, if I set the older repository on my build.gradle file the app compiles and runs successfully, but if I remove the older repository, it still compiles but when I try to open it crash.
The main problem with that, is that new people trying to compile the code for the first time, using new or older repo, gets the crash on start.
So, I think this can be caused by some cache made by gradle, but looking at the .gradle folder I couldn't find anything.
Can some one help me with that?
Here is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url "http://<new_repository_url>/artifactory/simple/libs-release-local/"
}
// if I remove comment from these lines the project runs correctly
//maven {
//url "https://<old_repository_url>/content/groups/AndroidPublicRepository/"
//}
maven {
url "http://holoeverywhere.cf/repo"
}
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 131
versionName '1.5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE.txt'
}
android {
lintOptions {
abortOnError false
}
}
productFlavors {
}
}
configurations {
all*.exclude(group: 'org.springframework', module: 'spring-core')
all*.exclude(group: 'org.springframework', module: 'spring-web')
all*.exclude(group: 'org.hamcrest', module: 'hamcrest-core')
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:support-v13:19.1.0'
compile 'org.holoeverywhere:library:2.1.0'
compile 'com.viewpagerindicator:viewpagerindicator:2.4.1'
compile 'com.googlecode.libphonenumber:libphonenumber:5.9'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.4'
compile 'com.google.code.gson:gson:2.3'
compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-cache:1.4.14'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.14'
compile 'org.springframework.social:spring-social-core:1.0.2.PATCHED'
compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
exclude group: 'org.springframework.social', module: 'spring-social-core'
}
compile project(':addon-preferences-2.1.0')
}
I recommend you to remove HoloEverywhere from your app. It was a great library, but it isn't now. It's not very difficult: just change imports, some little adjustments and minSdkVersion = 15. Other option: Material Design.
Anyway, if you can't remove it or you can't do it right now:
HoloEverywhere had a dependency with a patched support-v4. I think the problem is that you don't have this patched version at your maven repository. You can find this code in the branch support-library.

How to generate html report with gradle 1.12?

Anyone knows how to generate test report for gradle 1.12?
I'm using gradle 1.12. My Test extends ActivityInstrumentationTestCase2. using Espresso test framework. My test run but doesn't generate html report.
Here's my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
maven { url 'http://JRAF.org/static/maven/2' }
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
...
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(file('version.properties')))
defaultConfig {
applicationId 'com.android.apps'
minSdkVersion 9
targetSdkVersion 20
versionName versionProps['name']
versionCode versionProps['code'].toInteger()
testApplicationId 'my.test'
testInstrumentationRunner 'com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner'
}
android {
useOldManifestMerger true
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
productFlavors {
}
}
I run my test using shell script
Here's my shell script:
# Clean and Build the project
gradle clean build
# Install apk to device
gradle installDebug installDebugTest
# Run specific test
/Applications/Android\ Studio.app/sdk/platform-tools/adb shell am instrument -e class my.test.RunTestSuite -w my.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner
The result in command prompt:
...
BUILD SUCCESSFUL
Total time: 55.003 secs
my.test.TestActionBar:.
Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.
Time: 32.519
OK (1 test)
If fail
Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.E
Time: 29.595
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
See Gradle userguide by navigating to Example 23.14. Creating a unit test report for subprojects
Also see this post

Jacoco with Gradle 0.10.0: Remote object doesn't exist

UPDATE Oct 21, 2014:
The issue has been confirmed as fixed by using buildtools 21.
UPDATE SEPT 18, 2014:
The issue's status has been updated to FutureRelease.
UPDATE:
I have heard that this may not work with Dagger, and since Espresso uses Dagger, it might be causing some issues. A bug was submitted to the Gradle team.
Google recently updated their Gradle implementation to 0.10.0. One of the things they now offer is Jacoco support. To do this, they mention setting the following:
testCoverageEnabled = true
Into your build type. Now when I run my Espresso tests (using connectedCheck), I get an error right as I start to run the :connectedAndroidTest task that states:
Tests on HTC One - 4.2.2 - API 17 - 1080x1920 - 4.2.2 failed: Instrumentation run failed due to 'java.lang.VerifyError'
01:38:31 E/Device: Error during Sync: Remote object doesn't exist!
null
java.io.IOException: com.android.ddmlib.SyncException: Remote object doesn't exist!
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:114)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:158)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:42)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.SyncException: Remote object doesn't exist!
at com.android.ddmlib.SyncService.pullFile(SyncService.java:314)
at com.android.ddmlib.Device.pullFile(Device.java:849)
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:107)
... 8 more
:connectedAndroidTest FAILED
Here are the parts I have changed in the build.gradle file:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
...
}
...
}
android {
buildTypes {
debug {
testCoverageEnabled = true
...
}
....
}
...
}
Is there any other piece of build.gradle file that I need to update in order to get Jacoco working?
The error mentions that a "remote object" doesn't exist. Usually I attribute this to the emulator being out of sync and a restart would fix it. But I've tried that and it isn't worked either. Any ideas what the error is trying to tell me?
Try This One...
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.0'
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1" // Must Require
defaultConfig {
applicationId "com.packagename" <Change it>
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
lintOptions {
abortOnError false
}
buildTypes {
debug {
testCoverageEnabled true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
jacoco {
toolVersion = "0.7.1.201405082137"
}

Categories

Resources