I am new To android studio. I have made a Java project which mainly works with an SQLite db (in assets folder). I migrated This project to android studio from netbeans. When I press run and choose an emulator, Gradle Build Tasks start to execute and an error occurs which says:
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
The Complete error output in console says:
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 39s
This is the Stack trace after pressing 'run'
Executing tasks: [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
: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:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
There are a lot of solution on the web like putmultiDexEnabled true in gradle.build file which I already had.
Update This is my gradle.build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.bcosta.myapplication"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
This seems like a common problem with no definitive solution.
Try:
Delete the .gradle directory.
Clean project and build again.
If that doesn't work, try adding the following to your build.gradle:
android {
dexOptions{
jumboMode=true;
javaMaxHeapSize "4g"
}
}
Also, try File -> Invalidate Caches/Restart
Try this,
android {
defaultConfig {
...
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
If you don’t have a custom Application class, then add this line to manifest
<application
android:name="android.support.multidex.MultiDexApplication"
.....your code
If you already have your own Application class, make it extend android.support.multidex.MultiDexApplication instead of android.app.Application
import android.support.multidex.MultiDexApplication;
public class MyApplication extends MultiDexApplication {
/* To enable Multi-Dex, you have 3 options -
1. Declare android.support.multidex.MultiDexApplication as your application class in AndroidManifest.xml
2. Extend MultiDexApplication like we are doing here
3. Override attachBaseContext() in your application class as shown below
/*
*/
/*
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
*/
}
Related
When I run Build - rebuild project I get the following error
I have tryed many sollution but nothing works..
What went wrong:
the error build code:
Executing tasks: [:app:generateDebugSources]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:mainApkListPersistenceDebug UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
AGPBI: {"kind":"error","text":"error: resource drawable/appiconlarge () not found.","sources":[{"file":"/home/.gradle/caches/transforms-1/files-1.1/appcompat-v7-25.3.1.aar/a9a8f29f5baeae5b590388a64347d1e6/res/values/values.xml","position":{"startLine":1362,"startColumn":4,"startOffset":99385,"endLine":1403,"endColumn":12,"endOffset":102566}}],"original":"","tool":"AAPT"}
:app:processDebugResources
error: failed linking references.
:app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "xxxx"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner
manifestPlaceholders = [auth0Domain:"#string/com_auth0_domain"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.google.android.gms:play-services-maps:10.0.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.auth0.android:lock:2.7.0'
implementation 'com.android.support:cardview-v7:25.3.1'
implementation 'com.android.support:support-annotations:24.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
}
The main issue is
resource drawable/appiconlarge not found
Please check the drawable/appiconlarge file exists or not. If not please add appiconlarge image on the drawable directory.
Hope this will solve your problem.
Consider doing this, not sure it would remove the error but it helped in my case.
android.enableAapt2=true
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
GRADLE CONSOLE OUTPUT:
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2510Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72510Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library 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:prepareComAndroidSupportSupportV42510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2510Library UP-TO-DATE
:app:prepareComAndroidVolleyVolley100Library 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
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Can anyone help me in fixing this. I am new to android :(
I have added a screen shot of Android Manifest.
So far I have tried below steps to fix the issue. Still no help.
1) Clean Prjoect
2) Rebuild Project
3) File > Invalid Cache/Restart
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.theaquarious.myfavapp"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
This issue is now resolved. The error was raised due to the image file. I have changed the extension of an JPG image to PNG without using any editor. Due to this android studio started to throw the error. Thanks to everyone who tried to help me. If anyone needs more clarification on this, just comment.
This appears to be a bug in aquiring a lock in some Java thread. I see this on my Windows 7 PC starting recently. I have had success by simply running Task Manager and then killing the java.exe process. If I then try again, the build seems to work fine.
The error is because the names of the files that are saved in your Drawable folder can not be capitalized. Rename the file and leave everything in lowercase.
Don’t save drawable images in capital case and it should be png not jpg else it will throw an error : Execution failed for task ':app:mergeDebugResources'
I am getting this error from build-tools\23.0.2\ (Aapt.exe)
finished with non zero exit value 1.
I am using Android Studio Version 1.4.1
I am using the API level 23 with the updated build tools, and my log cat is often meaning out the string.xml where I created my strings to refer it for the list view.
Executing tasks: [:app:generateDebugSources,
:app:generateDebugAndroidTestSources, :app:compileDebugSources,
:app:compileDebugAndroidTestSources, :mylibrary:generateDebugSources,
:mylibrary:generateDebugAndroidTestSources,
:mylibrary:compileDebugSources,
:mylibrary:compileDebugAndroidTestSources]
Configuration on demand is an incubating feature. :app:preBuild
UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library 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 AGPBI: { "kind":"error","text":"Apostrophe
not preceded by \ ( in ithin the lifecycle callback methods, you can
declare how your activity behaves when the user leaves and re-enters
the activity. For example, if you\u0027re building a streaming video
player, you might pause the video and terminate the network connection
when the user switches to another app. When the user returns, you can
reconnect to the network and allow the user to resume the video from
the same spot. )", "sources":[
{"file":"C:\Users\PreciseT3\AndroidStudioProjects\ListviewApp1\app\src\main\res\values\strings.xml","position":
{ "startLine":1}}],"original":""}
FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'C:\Users\PreciseT3\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe''
finished with non-zero exit value 1
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: 12.649 secs
Problem is in your string.xml
find all occurrences of single-quote (') or apostrophe and add a back-slash escape character (\) before each occurrence.
XML cannot deal with (')
Basically, replace all ' with \'
Compare your gradle file I hope this work
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "info.tranetech.laundry"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:design:23.0.1'
compile 'com.squareup.picasso:picasso:+'
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile files('libs/android-async-http-1.4.4.jar')
compile 'com.google.android.gms:play-services:8.4.0'
}
I just clone this project from Github: https://github.com/mutexkid/android-studio-robolectric-example
I m on Android Studio 1.2, Java 8, Ubuntu Linux distro.
When running the test with gradle it generates the message below. I got the same error on a Windows OS machine.
Any idea what could me missing ?!?
Thanks
Elcio A.
Executing tasks: [cleanTest, test]
Configuration on demand is an incubating feature.
:app:cleanTest UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
: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
:app:preCompileDebugUnitTestJava
:app:compileDebugUnitTestJava
:app:compileDebugUnitTestSources
:app:mockableAndroidJar
:app:assembleDebugUnitTest
:app:testDebug
com.example.joshskeen.myapplication.MyActivityTest > clickingClickMeButtonChangesHelloWorldText FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchMethodException
com.example.joshskeen.myapplication.MyActivityTest > myActivityAppearsAsExpectedInitially FAILED
java.lang.RuntimeException
Caused by: java.lang.RuntimeException
Caused by: java.lang.NoSuchMethodException
2 tests completed, 2 failed
:app:testDebug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:testDebug'.
There were failing tests. See the report at: file:///home/elcio/AndroidStudioProjects/android-studio-robolectric-example/app/build/reports/tests/debug/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: 10.662 secs
Here is my build.grandle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.joshskeen.myapplication"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.easytesting:fest:1.0.16'
testCompile 'com.squareup:fest-android:1.0.8'
testCompile('org.robolectric:robolectric:3.0-rc2') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
Here is my test Class:
package com.example.joshskeen.myapplication;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import static org.fest.assertions.api.ANDROID.assertThat;
#RunWith(RobolectricGradleTestRunner.class)
#Config(constants = BuildConfig.class, emulateSdk = 21)
public class MyActivityTest {
private MyActivity mActivity;
#Before
public void setup() {
mActivity = Robolectric.buildActivity(MyActivity.class).create().get();
}
#Test
public void myActivityAppearsAsExpectedInitially() {
assertThat(mActivity.mClickMeButton).hasText("Click me!");
assertThat(mActivity.mHelloWorldTextView).hasText("Hello world!");
}
#Test
public void clickingClickMeButtonChangesHelloWorldText() {
assertThat(mActivity.mHelloWorldTextView).hasText("Hello world!");
mActivity.mClickMeButton.performClick();
assertThat(mActivity.mHelloWorldTextView).hasText("HEY WORLD");
}
}
I am trying to import libraries using gradle. This is my build.gradle file:
apply plugin: 'android'
dependencies {
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.squareup.okhttp:okhttp:1.3.0'
compile 'com.squareup.retrofit:retrofit:1.4.1'
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile files('libs/activeandroid-3.1-SNAPSHOT.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// TODO: Fix the warnings and removed this section!
lintOptions {
abortOnError false
}
}
I get errors like these:
I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/TransportMediatorJellybeanMR2$1; interface 964 'Landroid/view/ViewTreeObserver$OnWindowAttachListener;'
W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/TransportMediatorJellybeanMR2$1;' failed
W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/print/PrintHelperKitkat$1; (155)
W/dalvikvm﹕ Link of class 'Landroid/support/v4/print/PrintHelperKitkat$1;' failed
I/dalvikvm﹕ Failed resolving Lretrofit/RestAdapter$RxSupport$1; interface 1942 'Lrx/Observable$OnSubscribeFunc;'
W/dalvikvm﹕ Link of class 'Lretrofit/RestAdapter$RxSupport$1;' failed
I have run gradlew clean and build command. But it doesn't help. Do you have any idea what is wrong ?
There are my logs for gradlew build command:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:app:compileDebugNdk
:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV71910Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJava
:app:preDexDebug
:app:dexDebug
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:assembleDebug
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:compileReleaseJava
:app:lintVitalRelease SKIPPED
:app:compileReleaseNdk
:app:preDexRelease
:app:dexRelease
:app:processReleaseJavaRes UP-TO-DATE
:app:packageRelease
:app:assembleRelease
:app:assemble
:app:compileLint
:app:lint
Ran lint on variant release: 25 issues found
Ran lint on variant debug: 25 issues found
Wrote HTML report to file:.../lint-results.html
Wrote XML report to .../lint-results.xml
:app:check
:app:build
BUILD SUCCESSFUL
This is my gradle.build file from project directory:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Maybe support-v4 dependencies mismatch ?
Try to add this into build.gradle:
configurations {
all*.exclude group: 'com.google.android', module: 'support-v4'
}
dependencies {
....