Android: ExternalSystemException: String index out of range: -130 building release

Karim Varela picture Karim Varela · Sep 15, 2015 · Viewed 12.3k times · Source

So, just updated to Android Studio 1.4 Beta 4 and having trouble building a release build. I can build a debug build fine. This is the error I get:

ExternalSystemException: String index out of range: -130

Upon further inspection, I see this:

String index out of range: -130
com.intellij.openapi.externalSystem.model.ExternalSystemException: String index out of range: -130
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:223)
at com.android.tools.idea.gradle.invoker.GradleTasksExecutor.invokeGradleTasks(GradleTasksExecutor.java:400)
at com.android.tools.idea.gradle.invoker.GradleTasksExecutor.run(GradleTasksExecutor.java:221)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)

Any ideas? I've tried with Gradle 2.3 - 2.7 and always get this error building a release build.

build.gradle from main module:

import java.util.regex.Pattern

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
    classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
}
}

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
// This does not break the build when Android Studio is missing the JRebel for     Android plugin.
apply plugin: 'com.zeroturnaround.jrebel.android'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {
signingConfigs {
    config {
        keyAlias 'XXX'
        keyPassword 'XXX'
        storeFile file('../signing/keystore.jks')
        storePassword 'XXX'
    }
}
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
    applicationId "com.coffeemeetsbagel"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 605
    versionName '2.0.6.0'
    signingConfig signingConfigs.config
    multiDexEnabled true
}

productFlavors {
    lollipop {
        minSdkVersion 21
    }

    everything {
        minSdkVersion 16
    }
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
        debuggable false
    }
    debug {
        debuggable true
    }
    superuser.initWith(release)
    superuser {
        debuggable true
        minifyEnabled false
    }
}

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/license'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/DEPENDENCIES.txt'
}

dexOptions {
    javaMaxHeapSize "4g"
}
}

dependencies {
compile files('libs/commons-validator-1.4.1.jar')
compile files('libs/com.kontagent.android.sdk.jar')
compile files('libs/urbanairship-lib-4.0.4.jar')
compile files('libs/apsalar.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
    transitive = true
}
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-base:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.firebase:firebase-client-android:2.2.0'
compile 'com.facebook.shimmer:shimmer:0.1.0@aar'
compile 'com.balysv:material-ripple:1.0.2'
compile 'io.branch.sdk.android:library:1.8.8'
compile 'com.facebook.device.yearclass:yearclass:1.0.1'
compile 'com.appyvet:materialrangebar:1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.adobe.creativesdk:image:4.0.0'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile project(':core')
compile project(':layouts')
compile project(':volley')
}

Answer

David Wadge picture David Wadge · Oct 29, 2015

If you're using Android Studio, selecting the Gradle Console will show you where the problem lies. In my case, it was duplicate textView identifiers that caused this error.