I am using Comriva library to extract MFCC features to my speech recognition project. And i have imported the comriva core packages to my project. When i tired to build it im getting this error in gradle,
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:packageAllDebugClassesForMultiDex UP-TO-DATE
:app:shrinkDebugMultiDexComponents UP-TO-DATE
:app:createDebugMainDexClassList UP-TO-DATE
:app:dexDebug
trouble processing "javax/xml/stream/events/StartElement.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 5.524 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
I didn't include any xml libraries so far like simple-xml.
This is my gradle.build file,
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "info.androidhive.sleepApp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile files('libs/jl1.0.jar')
compile files('libs/commons-logging-api.jar')
compile files('libs/cp.jar')
compile files('libs/http-2.2.1.jar')
compile files('libs/jama-1.0.2.jar')
compile files('libs/jl1.0.jar')
compile files('libs/jogg-0.0.7.jar')
compile files('libs/lucene-analyzers-3.0.0.jar')
compile files('libs/lucene-core-3.0.0.jar')
compile files('libs/lucene-queries-3.0.0.jar')
compile files('libs/lucene-queryparser-3.0.0.jar')
compile files('libs/lucene-snowball-3.0.3.jar')
compile files('libs/jorbis-0.0.15.jar')
compile files('libs/mdsj.jar')
compile files('libs/tritonus_remaining.jar')
compile files('libs/tritonus_share.jar')
compile files('libs/wstx-lgpl-3.0.1.jar')
compile files('libs/weka-stable-3.6.13.jar')
compile files('libs/stax-api-1.0.jar')
compile files('libs/mp3spi1.9.4.jar')
}
Please help me to overcome this problem.
I figured out the issue it was the stax-api-1.0.jar this included the javax.xml.stream.events.* classes after removing the jar i was able to build it successfully. This jar came with the comriva that is why i didn't notice it.
Related
I'm trying to write a BitBucket Pipeline script for my repository, but so far without much luck, because Gradle seems a pain to debug.
Is there any way to show the resulting files (from compiling the jar for example) in the console when it finishes the : build task?
Preferably I'd like to see as much information as possible, rather too much than too little.
Adding logging.captureStandardOutput LogLevel.DEBUG in my build.gradle file didn't seem to do much, still getting the same output:
:compileJavaNote: -snip-\src\main\java\com\-snip-\atlas\utility\SchematicUtil.java uses or overrides a deprecated API.
Note: Recompile with -Xlint: deprecation for details.
:processResources
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 1.16 secs
Here's one way to do it (e.g. jar for a simple Java project). The build.gradle is:
apply plugin: 'java'
jar {
doLast {
new File("${buildDir}/libs").eachFileRecurse { file ->
println "TRACER: ${file.getAbsolutePath()}"
}
}
}
It should be straight-forward to tailor for other needs.
I'm trying to compile and deploy my Android App, but i have got an MultiDex issue :
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.lang.UnsupportedOperationException (no error message)
I already tryed many fix but they doesn't works.
What i already tryed :
1. multiDexEnabled true
2. dexOptions
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
3. Turning off Instant Run in Android Studio settings
4. Reboot Android Studio and computer.
5. Clear and Rebuild project.
6. File > Invalidate Caches / Restart.
7. compile 'com.android.support:multidex:1.0.1' [EDIT]
And finally reboot my life but nothing want to works..
What can be done to fix this problem ?
Here is my Gradle file
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'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.X.Y"
minSdkVersion 15
targetSdkVersion 21
versionCode 90
versionName "1.2.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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'
}
}
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://dl.bintray.com/X/maven/' }
maven { url "https://jitpack.io" }
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
// Utils
//ANR Helper & Memory Leaks helper
//compile 'com.github.anrwatchdog:anrwatchdog:1.1.+'
//compile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
// HoneyWell sdk
compile files('libs/honeywell.jar')
// RealmAdapter
compile 'io.realm:android-adapters:1.2.1'
// Volley
compile 'com.mcxiaoke.volley:library:1.0.19'
// EventBus
// compile 'org.greenrobot:eventbus:3.0.0'
// Gson
compile 'com.google.code.gson:gson:2.3.1'
// Jjp
compile 'com.instagram:ig-json-parser-processor:0.0.6+'
// Sticky List headers
compile 'se.emilsjolander:stickylistheaders:2.7.0'
// Parallax
compile 'com.github.nirhart:parallaxscroll:1.0'
// Facebook
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
// Zbar
compile 'me.dm7.barcodescanner:zbar:1.9'
// NumberProgressBar
compile 'com.daimajia.numberprogressbar:library:1.2#aar'
// AutoFitTextView
compile 'me.grantland:autofittextview:0.2.+'
// RoundedImageView
compile 'com.makeramen:roundedimageview:2.2.0'
// UpdateChecker
compile 'com.github.rampo.updatechecker:library:2.1.8'
// UniversalImageLoader
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
// GifDrawable
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
// PieChart
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
compile 'com.android.support:support-v13:+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
//AndroidSlidingUpPanel
compile 'com.sothree.slidinguppanel:library:3.3.0'
// YPL
compile 'com.X:Xandroidlibrary:1.4.0'
compile project(':kdcreader')
}
And here Gradle Console
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature. WARNING: WARNING:
Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for
debug as it may be conflicting with the internal version provided by
Android.
In case of problem, please repackage it with jarjar to change the class packages WARNING: WARNING: Dependency
org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it
may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages WARNING: WARNING: Dependency
org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as
it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages WARNING: WARNING: Dependency
org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as
it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages :app:preBuild UP-TO-DATE :app:preDebugBuild
UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72330Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV132510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42510Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers136Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidBeta114Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlytics255Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore238Library
UP-TO-DATE :app:prepareComDaimajiaNumberprogressbarLibrary12Library
UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk460Library
UP-TO-DATE :app:prepareComGetkeepsafeRelinkerRelinker122Library
UP-TO-DATE :app:prepareComGithubNirhartParallaxscroll10Library
UP-TO-DATE :app:prepareComGithubRampoUpdatecheckerLibrary218Library
UP-TO-DATE :app:prepareComMakeramenRoundedimageview220Library
UP-TO-DATE :app:prepareComSothreeSlidinguppanelLibrary330Library
UP-TO-DATE :app:prepareComXXnandroidlibrary140Library
UP-TO-DATE :app:prepareIoFabricSdkAndroidFabric1310Library UP-TO-DATE
:app:prepareIoRealmAndroidAdapters121Library UP-TO-DATE
:app:prepareIoRealmRealmAndroidLibrary211Library UP-TO-DATE
:app:prepareMeDm7BarcodescannerCore19Library UP-TO-DATE
:app:prepareMeDm7BarcodescannerZbar19Library UP-TO-DATE
:app:prepareMeGrantlandAutofittextview021Library UP-TO-DATE
:app:preparePlDroidsonroidsGifAndroidGifDrawable1117Library UP-TO-DATE
:app:prepareSeEmilsjolanderStickylistheaders270Library UP-TO-DATE
:app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig
UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders
UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets
UP-TO-DATE :app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug :app:generateDebugResValues
UP-TO-DATE :app:generateDebugResources :app:mergeDebugResources
:app:processDebugResources :app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE :app:compileDebugNdk
UP-TO-DATE :app:compileDebugSources UP-TO-DATE
:app:transformClassesWithRealmTransformerForDebug UP-TO-DATE
:app:transformClassesWithJarMergingForDebug UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.lang.UnsupportedOperationException (no error message)
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.277 secs
[EDIT] And more info about crash : http://pastebin.com/vG79DLuN
Thanks for your help !
I had a same issue. In my app I am using guava-retrying library, which was fetching google guava library version 21. Guava version 21 requires JDK 1.8 without providing back porting support and this was causing this error in my case.
I was able to solve it by including the guava-retrying library so that it uses version 19.0 of guava library:
compile ("com.github.rholder:guava-retrying:2.0.0") {
exclude group: 'com.google.guava', module: 'guava'
}
compile 'com.google.guava:guava:19.0'
I am trying to write an instrumentation test for my MainActivity. I followed the answers given here. Still Android Studio cannot find any tests. I have the class ApplicationTest.java in the androidTest folder. Here's the contents of the class:
package com.example.monicamarcus.mymusicplayer
import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;
import com.example.monicamarcus.mymusicplayer.MainActivity;
public class ApplicationTest extends ActivityInstrumentationTestCase2<MainActivity> {
public ApplicationTest() {
super(MainActivity.class);
}
public void testNextTrackButton() throws Exception {
Activity activity = getActivity();
Button nextButton = (Button) activity.findViewById(R.id.nextTrackBt);
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
nextButton.performClick();
assertTrue(currentPosition < songList.size());
}});
activity.finish();
}
}
What is wrong with this test class? Or with the tests? I don't get any error, it just does not find any test to run. After I run the ApplicationTest the output ends with the following lines:
Running tests
Test running startedFinish
Empty test suite.
Here's the build.gradle file for the app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.monicamarcus.mymusicplayer"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testApplicationId "app.src.androidTest.java.com.example.monicamarcus.mymusicplayer"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
android {
sourceSets {
androidTest {
java.srcDirs = ['androidTest/java']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
androidTestCompile 'junit:junit:4.12'
}
Here's the output of the test run:
Testing started at 1:56 PM ...
Target device: gt_i8190n-4790068ee9a750c6
Installing APK: /Users/monicamarcus/AndroidStudioProjects/MyMusicPlayer/app/build/outputs/apk/app-debug.apk
Uploading file to: /data/local/tmp/com.example.monicamarcus.mymusicplayer
Installing com.example.monicamarcus.mymusicplayer
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.monicamarcus.mymusicplayer"
pkg: /data/local/tmp/com.example.monicamarcus.mymusicplayer
Success
Installing APK: /Users/monicamarcus/AndroidStudioProjects/MyMusicPlayer/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
Uploading file to: /data/local/tmp/app.src.androidTest.java.com.example.monicamarcus.mymusicplayer
Installing app.src.androidTest.java.com.example.monicamarcus.mymusicplayer
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/app.src.androidTest.java.com.example.monicamarcus.mymusicplayer"
pkg: /data/local/tmp/app.src.androidTest.java.com.example.monicamarcus.mymusicplayer
Success
Running tests
Test running startedFinish
Empty test suite.
After I made some changes (I can publish them if anybody is interested) the result of running the instrumentation test class read as follows: "Running tests. Test running started. Test running failed: No test results. Empty test suite." Nobody has experience with these kind of tests?
In build.gradle, testApplicationId looks very strange. I would remove this and testInstrumentationRunner. The default values should be fine. Specifically, if you do not specify testApplicationId, it will be created by appending ".test" to your applicationId.
not sure if the problem has been found. Running into similar but only if added assertTrue() it got the "Empty test suite.".
but replace with assertNotNull() the test is fine, still cannot use assertTrue though (not know why).
(I'm using kotlin and modify the Android studio generated default test in the AndroidTest folder, and the test is coded in kotlin's companion object, if this make any difference).
Update: using assertTrue() outside the companion object is fine.
i just created a new project in android studio 2.2.2, made an android test fail did a gradle cC, and got the output below.
you can see the test failing on each device at the bottom of the output.
this question may be related.
the reports are in So35426990/app/build/reports/androidTests/connected/index.html
d:\AndroidStudioProjects\So35426990>gradle cC
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be
removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instea
d.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2421Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoCore222Library UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoIdlingResource222Library UP-TO-
DATE
:app:prepareComAndroidSupportTestExposedInstrumentationApiPublish05Library UP-TO
-DATE
:app:prepareComAndroidSupportTestRules05Library UP-TO-DATE
:app:prepareComAndroidSupportTestRunner05Library UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:incrementalDebugAndroidTestJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
:app:mergeDebugAndroidTestShaders UP-TO-DATE
:app:compileDebugAndroidTestShaders UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:transformClassesWithDexForDebugAndroidTest
:app:mergeDebugAndroidTestJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebugAndroidTest UP-TO-DATE
:app:processDebugAndroidTestJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebugAndroidTest UP-TO-DATE
:app:validateSigningDebugAndroidTest
:app:packageDebugAndroidTest
:app:assembleDebugAndroidTest
:app:connectedDebugAndroidTest
acme.so35426990.ExampleInstrumentedTest > useAppContext[KFFOWI - 5.1] FAILED
java.lang.AssertionError: failing
at org.junit.Assert.fail(Assert.java:88)
acme.so35426990.ExampleInstrumentedTest > useAppContext[KFFOWI - 5.1.1] FAILED
java.lang.AssertionError: failing
at org.junit.Assert.fail(Assert.java:88)
acme.so35426990.ExampleInstrumentedTest > useAppContext[Nexus 7 - 5.1.1] FAILED
java.lang.AssertionError: failing
at org.junit.Assert.fail(Assert.java:88)
:app:connectedDebugAndroidTes
t FAILEDng 96% > :app:connectedDebugAndroidTest
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///D:/AndroidStudioProjects/
So35426990/app/build/reports/androidTests/connected/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 35.227 secs
d:\AndroidStudioProjects\So35426990>
Just for start, I am not rly trying to read cell(s) from .xlsx file in Android,
I already tried almost everything what I Googled, but every time (on two different PCs, both Java 1.7.0_79) when I'm trying to build (run) this app, it ends with same error:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
I have no idea, what more should I do, Java and Android Studio already reinstalled... Nothing. I used code from https://github.com/hmkcode/Java/tree/master/java-excel-poi
Full output from Messages
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex100Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:dexDebug
trouble processing "javax/xml/stream/events/StartElement.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 2.301 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
MainActivity.java
package tona_kriz.kriziksupl;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.widget.Toast;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Workbook wb = null;
//1. Open the file
try {
AssetManager assManager = getApplicationContext().getAssets();
InputStream is = null;
try {
is = assManager.open("supl_zak.xlsx");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream caInput = new BufferedInputStream(is);
wb = new XSSFWorkbook(caInput);
int i = wb.getNumberOfSheets();
Toast.makeText(getApplicationContext(), "pocet: " + i, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "otevreno", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//2. Open a sheet
Sheet sheet = wb.getSheetAt(0);
//3. Get each cell by row & column number
Cell cell;
//Cell cell = sheet.getRow(0).getCell(0);
//double numberVal = cell.getNumericCellValue();
//System.out.println("Row: 0 - Column: 0 = "+numberVal);
//-----------------------------
cell = sheet.getRow(0).getCell(8);
String stringVal = cell.getStringCellValue();
System.out.println("Row: 0 - Column: 1 = "+stringVal);
//-----------------------------
//cell = sheet.getRow(0).getCell(2);
//Date dateVal = cell.getDateCellValue();
//System.out.println("Row: 0 - Column: 2 = "+dateVal);
//-----------------------------
//cell = sheet.getRow(0).getCell(3);
//boolean booleanVal = cell.getBooleanCellValue();
//System.out.println("Row: 0 - Column: 3 = "+booleanVal);
//-----------------------------
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tona_kriz.kriziksupl" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:largeHeap="true"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"> >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries false
incremental true
javaMaxHeapSize "4g"
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "tona_kriz.kriziksupl"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/commons-codec-1.5.jar')
compile files('libs/dom4j-1.6.1.jar')
compile files('libs/poi-3.9.jar')
compile files('libs/poi-ooxml-3.9.jar')
compile files('libs/poi-ooxml-schemas-3.9.jar')
compile files('libs/stax-api-1.0.1.jar')
compile files('libs/xml-apis-1.0.b2.jar')
compile files('libs/xmlbeans.jar')
}
But, when I remove:
compile files('libs/commons-codec-1.5.jar')
compile files('libs/dom4j-1.6.1.jar')
compile files('libs/stax-api-1.0.1.jar')
compile files('libs/xml-apis-1.0.b2.jar')
compile files('libs/xmlbeans.jar')
the app starts, but crashes...
Logcat
http://pastebin.com/NG3AnW3z
File "supl_zak.xlsx" can be downloaded from here.
Libraries
Is there any solution for me?
Unfortunately you cannot directly use Apache POI on Android due to third party library dependencies that are pulled in. Also the size of the library causes a very big application file, which is often not possible/desirable. You even sometimes exceed limits imposed by the Dalvik Android Bytecode compilation.
There are some resources available which discuss how to get POI running on Android:
https://github.com/andruhon/android5xlsx - repackaged jars with duplicate packages in XMLBeans removed
http://blog.kondratev.pro/2015/08/reading-xlsx-on-android-4-and-hopefully.html
Apache POI with Android -- How to Create ,Read , Write, Delete PowerPoint Presentations?
The reason is that at least one the libraries (xmlbeans.jar) is declaring classes that may conflict with the core libraries that Android uses.
xmlbeans declares classes in a javax.xml package - Android also has classes in this package and other similar ones.
From the error message:
If you are legitimately using some code that happens to be in a core
package, then the easiest safe alternative you have is to repackage
that code. That is, move the classes in question into your own
package namespace.
Basically, the build tools think that you should be building a core library, but instead, you are attempting to build an application using a library which conflicts with the default Android core library. It suggests you move your code from the core package into a different package.
My advice - stop using external libraries that attempt to use core package names and use the XML functionality that Android provides.
Problem: java.exe finished with non-zero exit value 1
Solution: For solving this problem I have tried most of the solutions and hit and try again and again.
At last found the solution to this problem.
These are possible solutions you should try for solving your problem and according to me, it will definitely solve your issue.
Clean and Rebuild your Project.
Please check all the libraries are updated and gradle build version also updated.
try to increase your java heap size.
Don't use lambda expressions or syntax in your code. in my case that is the problem because I was using lambda expressions and when I was using lambda expression then it needs a declaration in build.gradle (app)file like
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
this.
it is the actual problem which I have faced please either remove this compileOptions declaration from build.gradle file or use the proper version which is compatible with your Gradle version.
Thanks
I hope this solution will help you and make your problem resolvable.
I have an idea you can follow:
some jars you import are internal API, like layoutlibs.jar, they are only involved in compiling, not packaged in apk.If you want to use them ,just create a folder named mylib in the root of the module ,then look the picture,follow them:
If my answer solve your problem ,please adopt it.
I have just started using android studio 1.1.0 and cannot get over the problem of adding an external jar in my project.
I am building an extremely simple app that runs perfectly well as long as I don't try to add the external jar in my app module. The jar I am trying to add is named 'xstream-1.4.8.jar'. I pasted the jar file in the 'libs' folder in my app module. Then in the project explorer tab on left hand side, I right clicked on the 'xstream-1.4.8.jar' in the 'libs' section and chose the 'add as library..' option.
Now the dependencies section of build.gradle in the src folder of my app module reads as :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/xstream-1.4.8.jar')
}
When I build the project, it build perfectly fine without any error. But when I try to run the app, then I get the following error :
The event log reads as :
Gradle build finished with 1 error(s) in 15 sec
And the messages section reads as:
Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE :app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig
UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets
UP-TO-DATE :app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE :app:mergeDebugResources
UP-TO-DATE :app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE :app:generateDebugSources
UP-TO-DATE :app:compileDebugJava UP-TO-DATE :app:preDexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic
(cafebabe) or version (0034.0000) at
com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at
com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at
com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at
com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704) at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at
com.android.dx.command.dexer.Main.access$300(Main.java:83) at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632) at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) at
com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) at
com.android.dx.command.dexer.Main.run(Main.java:246) at
com.android.dx.command.dexer.Main.main(Main.java:215) at
com.android.dx.command.Main.main(Main.java:106) ...while parsing
com/thoughtworks/xstream/mapper/LambdaMapper.class 1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with
non-zero exit value 1
Information:BUILD FAILED
I have already tried cleaning the project several times, but that doesn't help. Every time I try to run the app, I get this error. I have also built a normal java project using the same .jar file in eclipse which runs perfectly without any issues. What am I doing wrong?
You have to compile your java project (jar) with JDK 1.7.
if you use JDK 1.8, set the target to 1.7
By the way,you don't need to add this line in the dependencies block of your build.gradle.
compile files('libs/xstream-1.4.8.jar')
This line is enough.
compile fileTree(dir: 'libs', include: ['*.jar'])
You can use:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}