问题
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')
}
回答1:
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.
回答2:
Worked By adding this in build.gradle
lintOptions {
checkReleaseBuilds false
}
回答3:
My error is
ExternalSystemException: String index out of range:-
My app support Turkish and English language. My English strings.xml contains
<string name="hello_world">Hello world!</string>
and my Turkish strings.xml do not contains
<string name="hello_world">Bla bla!</string>
When i add <string name="hello_world">Bla bla!</string>
to Turkish strings.xml file the problem solved.
Note: Please look Android Studio's Gradle Console
回答4:
I had the same problem with Android Studio 1.4 Build on September 28, 2015 What I did was :
Started a build on the main gradle script - that created a run configuration in the menu.
Edited the run configuration by adding ":app:assembleRelease" on the script parameters row. and started it.
The gradle build showed me that I had missing translations in the main strings.xml file.
After fixing this. Generate Signed APK finished without problem.
回答5:
I had the same problem but with this error:
ExternalSystemException: String index out of range: -119
My problem was that in the string editor i forgot to set a default variable into my translation, after adding it, the problem was solved.
Hope it helps!
回答6:
So I reverted back to Android Studio 1.3 and the issue went away.
回答7:
Although this is an old thread, however the following info might be useful for some people. I was getting a bit different message (but similar, googling for the following message redirects me to this thread.)
Execution failed for task ':app:mergeReleaseResources'.
> String index out of range: 0
For me the problem was the string.xml was missing the name for a string resource as mentioned below.
<string name="">Some strings...</string>
Adding the proper resource name resolved the issue.
<string name="some_string">Some strings...</string>
回答8:
I have same problem. my Android Studio version is ver2.1.1
My strings.xml contains
<string name="title_connecting">connecting...</string>
then I change to the following statement. the problem solved.
<string name="title_connecting">connecting..</string>
来源:https://stackoverflow.com/questions/32575778/android-externalsystemexception-string-index-out-of-range-130-building-relea