我的项目在Java类和许多xml文件中有很多字符串。我为此使用了Multidex,但是当我尝试构建APK时,我收到了此错误:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidDatabindingAdapters10Rc5Library UP-TO-DATE
:app:prepareComAndroidDatabindingLibrary10Rc5Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:dataBindingProcessLayoutsDebug UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:dataBindingExportBuildInfoDebug UP-TO-DATE
:app:compileDebugJavaWithJavac
C:\WoW17\WoW17\app\build\generated\source\r\debug\com\xxx\test\R.java
Error:(12127, 25) error: too many constants
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 3 mins 5.842 secs
Information:2 errors
我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxx.test"
minSdkVersion 14
targetSdkVersion 23
versionCode 13
versionName "1.66"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:multidex:1.0.0'
}
之前我使用过eclipse,但我无法使用它进行多重索引,这就是我切换到使用Android Studio的原因。我有35000个字符串,也有xml和Java文件。这有什么解决方案吗?
答案 0 :(得分:0)
你没有在JAVA_HOME变量中抛出的问题,这里有一个指南: https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/