Hello, I see this issue is affecting lots of older projects.
I was able to completely build my Ionic project and get it onto the Google Play store (it’s still there) but this error is beyond me so far.
I’ve seen several other posts, some with some cryptic answers, others with people asking same thing I am.
So far, I have gathered this:
Related to multiple plugins calling for various versions of a file (JAR?)
– gradle dependencies doesnt work for me, says “no configuration”
– I haven’t been able to get the “gradle” view from Android studio
– Adding lines to build.gradle to dexOptions preDexLibraries == FALSE
Have tried to remove/add android platform multiple times
Have upgraded ionic
Have done “ionic state reset”
I can’t seem to find the dependency tree to figure out how to fix this.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:transformClassesWithDexForDebug’.
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
** at com.google.common.base.Preconditions.checkState(Preconditions.java:173)**
** at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:645)**
** at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608)**
** at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605)**
** at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)**
** at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:120)**
** at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.java:603)**
** at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93)**
** at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)**
I’m not sure why I can’t list the gradle dependencies…
Hmm What i would do is to update my SDK, update cordova,ionic and create a new project and copy the files from the existing ones.
The other solution is to fix the gradle file but i don’t know what other errors it might bring.
Third solution can be that you can safely delete the whole .gradle folder located under project directory.
It will recreate once when you rebuild your project
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:transformClassesWithDexForDebug’.
Check your project dependencies. You might be adding dependency for android-support-v4.jar twice or it might already been referenced in your project by some plugin.
So about project dependencies… I’m doing this all through the command line (not android studio) and simply doing things like:
ionic plugin add plugin1
ionic plugin add another
Also, I had read to try “gradle -q dependencies” and similar commands, but I get no output, or a message about not finding any projects (while in the project root with ionic.config.json, package.json etc)
I realize that this first issue is around having duplicate v4 JAR images, but beyond that my knowledge is a bit stretched.
First try removing all the plugins depending on support v4 and check if the same error is there. If so open project.properties file and remove support v4 library and rebuild project. If it worked then add first plugin rebuild the entire project if error comes then search hack for that plugin with error or post here plugin name I may help you in that regard
It Will be linked to your project via project.properties or inside some of the plugins. So remove it from individual plugin and keep it referenced from project.properties file.