Can't build Android bundle or APK

Answered

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.

8 comments
Comment actions Permalink

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.

0
Comment actions Permalink

IntelliJ IDEA build system for Android is obsolete, please switch to the Gradle Android projects.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}

allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'com.android.application'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 11
targetSdkVersion 28
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-compat:28.0.0'
}
0
Comment actions Permalink

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/.

0

Please sign in to leave a comment.