Related
I am getting the following error when running espresso test ./gradlew connectedAndroidTest
> Task :app:fixStackFramesLiveDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:fixStackFramesLiveDebugAndroidTest'.
> Cannot convert the provided notation to a File or URI: classes.jar (androidx.databinding:databinding-adapters:3.4.1).
The following types/formats are supported:
- A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
- A String or CharSequence URI, for example 'file:/usr/include'.
- A File instance.
- A Path instance.
- A Directory instance.
- A RegularFile instance.
- A URI or URL instance.
app/build.gradle contains the following
...
android {
.....
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
...
}
dataBinding {
enabled = true
}
}
...
Irrespective of espresso dependencies, I am getting the above error. Can someone please help to resolve this issue. I am new to android and espresso.
I am not sure if I had missed out information. Please let know if needed.
On Android Studio 4.0 canary 4 with Gradle Kotlin DSL enabled, I got the kinda same error:
Unable to resolve dependency for ':app#debug/compileClasspath': Cannot convert the provided notation to a File or URI: {dir=libs, include=[*.jar]}.
After I changed my build script from
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}
to
dependencies {
implementation(fileTree(Pair("dir", "libs"), Pair("include", listOf("*.jar"))))
}
everything works well. WTF.
I ran into this error after updating gradle to 3.4.+ After I downgraded to 3.3.2 I was able to build without any issues.
I am trying to integrate Google sign in, in my app, I added these libraries:
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
Also add this to project build gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
Also add plugin to app build gradle:
apply plugin: 'com.google.gms.google-services'
then add required permissions
but when I try to run my app, received this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
Try adding multiDexEnabled true to your app build.gradle file.
defaultConfig {
multiDexEnabled true
}
EDIT:
Try Steve's answer first. In case it happens frequently or first step didn't help multiDexEnabled might help. For those who love to dig deeper here is couple similar issues (with more answers):
:app:dexDebug ExecException finished with non-zero exit value 2
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException
Another thing to watch for, is that you don't use
compile 'com.google.android.gms:play-services:8.3.0'
That will import ALL the play services, and it'll only take little more than a hello world to exceed the 65535 method limit of a single dex APK.
Always specify only the services you need, for instance:
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
I just had to Clean my project and then it built successfully afterwards.
This error began appearing for me when I added some new methods to my project. I knew that I was nowhere near the 65k method limit and did not want to enable multiDex support for my project if I could help it.
I resolved it by increasing the memory available to the :app:transformClassesForDexForDebug task. I did this by specifying javaMaxHeapSize in gradle.build.
gradle.build
android {
...
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
I tried this after having had no success with other common solutions to this problem:
Running a project clean
Manually deleting the /app/build and /build directories from my project
Invalidating Gradle Cache and restarting Android Studio
Error
Error:Execution failed for task
> ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
Note: increasing the memory available to the DEX task can cause performance problems on systems with lower memory - link.
I also faced similar issue in Android Studio 1.5.1 and gradle 1.5.0.
I just have to remove unwanted libraries from dependencies which may be automatically added in my app's build.gradle file.
One was : compile 'com.google.android.gms:play-services:8.4.0'.
So for best practices try to only include specific play services library like for ads include only
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Although
defaultConfig {
multiDexEnabled true
}
this will also solve the issue, but provides with a lot of Notes in gradle console, making it confusing to find the other real issues during build
you can see the documentation of Android
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
I'm using AS 1.5.1 and encountered the same problem. But just cleaning the project just wont do, so I tried something.
clean project
restart AS
Sync Project
This worked with me, so I hope this helps.
At my case change buildToolsVersion from "24" to "23.0.2", solve the problem.
In my case the Exception occurred because all google play service extensions are not with same version as follows
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
It worked when I changed this to
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
I resolved it with the next:
I configured
multidex
In build.gradle you need to add the next one.
android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
...
}
dexOptions {
incremental true
maxProcessCount 4 // this is the default value
javaMaxHeapSize "2g"
}
...
}
dependencies {
...
compile 'com.android.support:multidex:1.0.1'
...
}
Add the next one in local.properties
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
After that into Application class you need to add the Multidex too.
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
//mas codigo
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forget add the line code into Manifest.xml
<application
...
android:name=".MyApplication"
...
/>
That's it with this was enough for resolve the bug:
Execution failed for task ':app:transformClassesWithDexForDebug.
Check very well into build.gradle with javaMaxHeapSize "2g" and the local.properties org.gradle.jvmargs=-Xmx2048m are of 2 gigabyte.
I had same problem when i rolled back to old version via git, and that version had previous .jar library of one 3rd party api, and for some reason turned out that both jar of the same sdk, just different versions were in /libs folder.
First Delete intermediates files
YOUR APP FOLDER\app\build\intermediates
OR
Clean your project and then rebuild.
Thent add
multiDexEnabled true
i.e.
defaultConfig {
multiDexEnabled true
}
It's work for me
I solved this issue by change to use latest buildToolsVersion
android {
//...
buildToolsVersion '26.0.2' // change from '23.0.2'
//...
}
A helpful answer if all above didn't work for you.
Go to your app gradle file,
Check all the dependency versions are mentioned with proper version code rather than any relative value like (com.example.demo:+)
Previous - implementation 'com.google.api-client:google-api-client-android:+'
After - implementation 'com.google.api-client:google-api-client-android:1.30.0'
If you are using the latest gradle version ie classpath 'com.android.tools.build:gradle:1.5.0' and classpath 'com.google.gms:google-services:1.4.0-beta3', then try updating the latest support respository from the SDK manager and rebuild the entire project.
If you need add this reference for cordova plugin add next line in your plugin.xml file.
<framework src="com.android.support:support-v4:+" />
If the different dependencies have a same jar also cause this build error.
For example:
compile('com.a.b:library1');
compile('com.c.d:library2');
If "library1" and "library2" has a same jar named xxx.jar, this will make such an error.
It happened to me because of Eclipse memory leak. I had to restart my computer.
I changed a couple of pngs and the build number in the gradle and now I get this. No amount of cleaning and restarting helped. Disabling Instant Run fixed it for me. YMMV
I had the same option and as soon as I turned off Instant run, it worked fine on my API16 device, but on the API24 device it worked fine with Instant run.
Hope this helps someone having the same issue
Simply go to Build - Edit Build Types - Properties Tab - Build Type Version and downgrade it to ver 23.0.1. Click ok.
This works for android studio 1.5.
It worked for me.
the write answer is in gradle put
defaultConfig {
multiDexEnabled true
}
then application name in manifest
android:name="android.support.multidex.MultiDexApplication"
wish this answer is hellpful to some one
this code solved problem
defaultConfig {
multiDexEnabled true
}
For easiest way to implement google sign in visit: google sign in android
Also try
dexOptions {
javaMaxHeapSize "4g"
}
Also keep same version number for different services.
I solved this issue by adding:
In build.gradle:
defaultConfig {
multiDexEnabled true
}
in local.properties ,
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
mention dependency:
compile 'com.android.support:multidex:1.0.1'
Clean and Rebuild.
Incase 'Instant Run' is enable, then just disable it.
My project was working fine, I stopped development for a week and when I came back, when I build the project I get this exception:
Error:Execution failed for task ':app:transformClassesWithPreJackRuntimeLibrariesForDebug'. > com.android.sched.scheduler.RunnerProcessException: Error during 'ReachingDefinitions' runner on 'static void org.mozilla.universalchardet.prober.contextanalysis.JapaneseContextAnalysis.
I tried to change org.gradle.jvmargs=-Xmx1024m, it was actually 1536.
No change.
What is this exception about? How to fix it?
Thank you.
UPDATE:
I was planning to use Data Binding in this project. Apparently,
apply plugin: 'com.android.databinding'
and this
classpath 'com.android.databinding:dataBinder:1.0-rc4'
caused his behaviour.
The question is why?
You just need to enable DataBinding in build.gradle to use it
android{
defaultConfig{
dataBinding {
enabled true
}
}
}
I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well.
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: 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
also my gradle file is below
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 9
targetSdkVersion 21
multiDexEnabled true
}buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v7-cardview.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc'
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-api-client-java6-1.18.0-rc.jar')
compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-http-client-jdo-1.18.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
compile files('libs/GraphView-4.0.1.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jetty-6.1.26.jar')
compile files('libs/jetty-util-6.1.26.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/jxl.jar')
compile files('libs/mail.jar')
compile files('libs/transaction-api-1.1.jar')
}
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
java.lang.RuntimeException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
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
The upper error occure due to lot of reason. So I can put why this error occure and how to solve it.
REASON 1 : Duplicate of class file name
SOLUTION :
when your refactoring of some of your class files to a library project. and that time you write name of class file So, double check that you do not have any duplicate names
REASON 2 : When you have lot of cache Memory
SOLUTION :
Sometime if you have lot of cache memory then this error occure so solve it.
go to File/Invalidate caches / Restart then select Invalidate and Restart it will clean your cache memory.
REASON 3 : When there is internal bug or used beta Version to Switch back to stable version.
SOLUTION :
Solution is just simple go to Build menu and click Clean Project and after cleaning click Rebuild Project.
REASON 4 : When you memory of the system Configuration is low.
SOLUTION :
open Task Manager and stop the other application which are not most used at that time so it will free the space and solve OutOfMemory.
REASON 5 : The problem is your method count has exceed from 65K.
SOLUTION :
open your Project build.gradle file add
defaultConfig {
...
multiDexEnabled true
}
and in dependencies add below line.
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
**In my case problem solved with Instant Run DISABLE **
Check Whether multidex enabled or not in your build.gradle(app level) under dependencies.if not place like below
dependecies{
multidexEnabled true
}
Check your gradle.properties(app level).if you see the below code
#org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
remove # before the line ,then it should be like this
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Please
Add this into your gradle file
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
AND also add the below dependency in your gradle
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
OR another option would be: In your manifest file add the MultiDexApplication package from the multidex support library in the application tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
This can be because of following reason:
one of the jar files inside project was using an older version of google play services.
use multiDexEnabled true in defaultconfig
Be specific with classes you add in dependencies. like
compile 'com.google.android.gms:play-services-maps:8.4.0'
Not like compile 'com.google.android.gms:play-services:+'
I tried everything but still this error won't go, until I changed my JDK version.
My JDK version was 7, and after I changed it to 8, the error went away, you can try it if nothing else works.
i have tried this one and it worked for me.
hope it works for others too.
Open build.gradle module file
downgrade you sdkversion from 25 to 24 or 23
add 'multiDexEnabled true'
comment this line : compile 'com.android.support:appcompat-v7:25.1.0' (if it's in 'dependencies')
Sync your project
and ready to go.
Here i have attached screenshot to explain things.
Go through this steps
happy to help.
thanks.
Or you can try this -
Extend your Application class with MultiDexApplication instead of Application !
Duplicate name Classes
like
class BackGroundTask extends AsyncTask<String, Void, Void> {
and
class BackgroundTask extends AsyncTask<String, Void, Void> {
i have tried this one for more projects and it worked for me. note that solution can configure your app for multidex:
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
...
minSdkVersion 9
targetSdkVersion 25
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}}
dependencies {
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
...
}
Thank #Ironman for his complete answer, however I should add my solution according to what I've experienced facing this issue.
In build.gradle (Module: app):
compile 'com.android.support:multidex:1.0.1'
...
dexOptions {
javaMaxHeapSize "4g"
}
...
defaultConfig {
multiDexEnabled true
}
Also, put the following in gradle.properties file:
org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
I should mention, these numbers are for my laptop config (MacBook Pro with 16 GB RAM) therefore please edit them as your config.
A temporary solution is to place the code below in the module build.gradle :
android {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
And Sync the Project.
My Settings Screenshot:
Thanks to this post.
Just turn off instant run in your settings. You can easily search the keyword "instant" like I showed and it would switch to the window you want.
In my case I had 2 projects A and B. And I upgraded to gradle 4.5.
A was dependent on B but both had references of my 3rd party jar
I was getting this error
com.android.tools.r8.errors.CompilationError: Program type already
present: com.mnox.webservice.globals.WebServiceLightErrorHashCode
Program type already present: com.mnox.webservice.globals.WebServiceLightErrorHashCode
To fix it
I removed the duplicate jar's
I used api in the B build.gradle file so that it gets referred to in A.
The other root cause can be if you have upgraded to gradle 4.5 and used implementation instead of api in your commons build.gradle
Just worth mentioning that while others suggest tempering with files, I was able to resolve this issue by installing a missing plugin (ionic framework)
Hopefully it helps someone.
cordova plugin add cordova-support-google-services --save
For me the solution was to delete the gradle cache folder (.gradle/caches) in the home directory and build again. Possibly due to a duplicate class loading issue.
For Ionic 4 Just
$ cordova clean
Helped me then run
$ ionic cordova run android --device
I'm getting this error:
Error:Execution failed for task ':ProjectName:compileUniversalDebugJava'.
> Could not find property 'bootClasspath' on com.android.build.gradle.AppExtension_Decorated#26fd94a1.
Why is that?
I'm building Android app with gradle on Android Studio.
Apparently I had to update com.android.tools.build:gradle:0.10.+ instead of com.android.tools.build:gradle:0.9.+. Here in my build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
...
}