Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Android build: java.lang.IllegalStateException: buildToolsVersion is not specified

Since today, somehow my ionic project is not longer able to build for some reason. I already tried to remove the platform and add it again, but it didn't work. I now almost spent three ours with upgrading, downgrading and reinstalling cordova and ionic but for some reason I always get the following error when I try to build the Android version:

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:176)
            at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:599)
            at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:566)
            at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:563)
            at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
            at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
            at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:562)
            at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:559)
            at org.gradle.listener.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:109)
            at org.gradle.listener.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:98)
            at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
            at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
            at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
            at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
            at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:79)
            at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:65)
            at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:504)
            at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:83)
            at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
            at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
            at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
            at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
            at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
            at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
            at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
            at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
            at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
            at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
            at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
            at org.gradle.util.Swapper.swap(Swapper.java:38)
            at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
            at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
            at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
            at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:46)
            at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
            at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)

    FAILURE: Build failed with an exception.

I already tried to set the buildToolsVersion in the config.xml but without any success. Did anyone have the same problem before?

like image 989
Lukas Avatar asked Mar 23 '16 00:03

Lukas


4 Answers

I figured it out, the problem was due to a misconfigured config.xml entry:

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:cdv="http://cordova.apache.org/ns/1.0"
        id="ch.papers.test"
        version="1.0.{BUILD_NUMBER}"
        android-versionCode="{BUILD_NUMBER}">...

Which we use for our Jenkins configuration. Unfortunately the error message was quite confusing.

Update corrected version:

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:cdv="http://cordova.apache.org/ns/1.0"
        id="ch.papers.test"
        version="1.0.0"
        android-versionCode="1">...
like image 142
Lukas Avatar answered Nov 16 '22 07:11

Lukas


I was facing this issue. The problem was that my ANDROID_HOME path was pointing to Android Studio's folder. I changed it to point to my Android SDK Folder and problem was solved.

  1. Check your ANDROID_HOME:

echo $ANDROID_HOME

  1. It should point to the Android SDK Folder:

export ANDROID_HOME="your-android-sdk-folder"

like image 36
Leonardo Soares e Silva Avatar answered Nov 16 '22 07:11

Leonardo Soares e Silva


I had the same issue. I fixed it as follows:-

Open Android studio configuration.

Go to config>SDK Manager>Android SDK>SDK Tools and install Android SDK Build-Tools.

Check the ANDROID_HOME variable. I am on mac, so it points to "/Users/user_name/Library/Android/sdk/"

If not set correctly set it as follows:-

export ANDROID_HOME="/Users/user_name/Library/Android/sdk/"

Now build it again and it should work fine.

PS:Getting android sdk by installing Android Studio is highly recommended than installing the sdk manually. This way you will not run into unnecessary trouble.

like image 4
Mav55 Avatar answered Nov 16 '22 09:11

Mav55


I solved this issue by saving the build.gradle and/or the build-extras.gradle with Unix (LF) line endings.. Your android-versionCode should have nothing to do with the buildversion of your android sdk...

like image 1
pkmelee337 Avatar answered Nov 16 '22 07:11

pkmelee337