构建签名时获取错误apk ExternalSystemException:字符串索引超出范围:-97

时间:2016-06-07 06:57:56

标签: android android-gradle signed

我建立了签名的apk,我有android studio 2.1.2

我的build.gradle文件如下

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.my.pkg"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    preDexLibraries = false
    javaMaxHeapSize "4g"
  }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/gson-2.1.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/json_simple-1.1.jar')
compile 'com.android.support:cardview-v7:22.+'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.android.support:appcompat-v7:22+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:design:22.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:recyclerview-v7:22.+'
compile 'com.google.android.gms:play-services:7.+'
compile 'com.android.support:multidex:1.0.0'


  compile project(':cropper')

}

当我构建apk时,我得到以下错误 ExternalSystemException:字符串索引超出范围:-97

  String index out of range: -97
  com.intellij.openapi.externalSystem.model.ExternalSystemException: String index out of range: -97
at      org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:238)
at    com.android.tools.idea.gradle.invoker.GradleTasksExecutor.invokeGradleTasks(GradleTasksExecutor.java:416)
at com.android.tools.idea.gradle.invoker.GradleTasksExecutor.run(GradleTasksExecutor.java:222)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:366)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)

任何想法我怎么能解决这个问题?你们所有的建议都很明显

2 个答案:

答案 0 :(得分:2)

这通常是由缺少翻译字符串引起的

查看错误运行

./gradlew assemble
来自项目根目录的

。 你会看到像这样的东西

String out of bound exception gradle

如果您的字符串不像fb app id那样可翻译,那么只需将translatable属性设置为false

即可

enter image description here

在其他情况下,请确保您拥有指定的所有语言的翻译

答案 1 :(得分:0)

我认为这个问题已经回答here基本上看看gradle控制台它会告诉你哪里出问题。