Can't build Android bundle or APK
I'm using IDEA 2019.2.2 on Mac. I'm trying to create a new release of one of my Android apps, but I can't get it to build either a bundle or APK. I select Build->Generate Signed Bundle/APK. If I choose "Android App Bundle" it gives this error message: "Generating signed bundle requires you to update the Android Gradle plugin to version 3.2.0 or higher." It provides a link that says, "Close this dialog and update the plugin." When I click, it asks me to confirm I want to upgrade. I click Update and the dialog goes away, but nothing else happens. I still can't build. And if I select the Check For Updates command, it informs me, "You already have the latest version of IntelliJ IDEA and plugins installed."
As an alternative I tried telling it to build an APK. That goes through building, but then fails with this error:
java.lang.AssertionError
at com.android.sdklib.BuildToolInfo.getPath(BuildToolInfo.java:388)
at org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard.createAndAlignApk(ExportSignedPackageWizard.java:464)
at org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard.access$1100(ExportSignedPackageWizard.java:81)
at org.jetbrains.android.exportSignedPackage.ExportSignedPackageWizard$1.run(ExportSignedPackageWizard.java:174)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:894)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:169)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:591)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:537)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:156)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:408)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:294)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
I tried reinstalling the IDE, updating the Android SDK, restarting, etc. Nothing helps.
Please sign in to leave a comment.
Updating plug-in means you need to edit build.gradle file:
I don't have a build.gradle file. I'm using IDEA's built in build system, not gradle.
I tried going to Project Structure->Project as that link suggests, but there's nothing there about plugins or gradle. The only options are Project Name, Project SDK, Project Language Level, and Project Compiler Output.
IntelliJ IDEA build system for Android is obsolete, please switch to the Gradle Android projects.
Is there a way to convert it automatically? This isn't a new project. I've been developing it continuously since 2010, and this is the first time IDEA has ever had a problem building a release. And given that the IDEA project has years of history in it, recreating it from scratch would not be trivial.
There's also nothing in the UI saying the standard build system isn't supported anymore, or that my project needs to be recreated, or anything like that.
There is no way to convert legacy Android projects to Gradle projects automatically. You can use older IDE version as a workaround: https://www.jetbrains.com/idea/download/previous.html.
Another workaround may be to downgrade Android SDK/build tools package: https://stackoverflow.com/questions/43292063/null-java-lang-assertionerror-in-intelij-ultimate-plugin-android-support.
I've been trying to follow your advice and convert my project to the Gradle build system, but without success. I roughly followed the instructions at https://developer.android.com/studio/intro/migrate#migrate-intellij for creating the script, though some parts seem to be out of date. My full build script is quoted below. I run into two problems with it. First, a message appears at the top of the window: "Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly." Second, my build gets several errors that all say, "Cannot resolve external dependency com.android.support:support-compat:28.0.0 because no repositories are defined." Note that my build script specifies both the google() and jcenter() repositories, so I don't know what that's talking about.
Check idea.log for errors: Help | Compress Logs and Show in ...
See if the build works from the command line Gradle.
The dependency you are using may be old or obsolete, you can ask for help at https://stackoverflow.com/.