编辑:这是我的完整版本扫描:https://scans.gradle.com/s/fva2ntifaimgi
原始消息:
将multidexEnabled true
添加到我的应用程序的gradle配置中的defaultConfig
后,我遇到以下无法解决的事件:
java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.lang.ArrayIndexOutOfBoundsException
...
Caused by: com.android.build.api.transform.TransformException: java.lang.ArrayIndexOutOfBoundsException
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 65535
我必须检查要真正启用的multidex是什么?我在做什么错了?
我的配置是:
minSdkVersion 26
targetSdkVersion 28
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="come.example.project">
<uses-permission [...]/>
<supports-screens [...]/>
<application
android:name="com.example.project.App"
android:allowBackup="false"
android:fullBackupContent="false"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<!-- activities -->
[...]
<!-- providers -->
[...]
<!-- broadcast receivers -->
[...]
</application>
</manifest>
我的gradle配置: 应用插件:“ com.android.application” 应用插件:“ org.greenrobot.greendao”
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.project.dev"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "0.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
[...]
}
debug {
[...]
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
final String chain = [...]
outputFileName = [...]
}
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
dataBinding {
enabled = true
}
packagingOptions {
exclude 'META-INF/LICENSE*'
exclude 'META-INF/NOTICE.txt'
merge 'reference.conf'
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
greendao {
// increment when changing DB structure
schemaVersion 8
}
configurations {
compile.exclude group: 'com.google.guava', module: 'listenablefuture'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:multidex:1.0.3'
//implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha05'
//implementation 'com.android.support:preference-v7:28.0.0'
implementation 'androidx.preference:preference:1.0.0'
//implementation 'com.android.support:preference-v14:28.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
//implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'androidx.media:media:1.0.1'
//implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.google.android.gms:play-services-drive:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation('android.arch.work:work-runtime:1.0.1-rc01') {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
// logging
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'com.github.tony19:logback-android:1.1.1-12'
implementation('com.papertrailapp:logback-syslog4j:1.0.0') {
exclude group: 'ch.qos.logback'
}
// required for greendao encryption, disabled for now
implementation 'net.zetetic:android-database-sqlcipher:3.5.6'
// qr codes
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
// events
implementation 'org.greenrobot:eventbus:3.0.0'
// http client
testImplementation 'junit:junit:4.12'
}
我的应用程序文件:
public class App extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
[...]
}
答案 0 :(得分:1)
您必须做一些事情。 https://developer.android.com/studio/build/multidex?authuser=1
添加依赖项:
error: 'test_plot' undefined near line 1 column 60
使Gradle知道它在那里
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
如果有,请在您的应用程序类中覆盖它:
defaultConfig {
...
multiDexEnabled true
}
更新清单以指向您的应用程序类:
public class MyApplication extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
或者,如果您没有扩展应用程序类的自定义应用程序类,则只需更改应用程序标签即可使用默认的支持multidexapplication类,而不必担心。
<application
android:name="com.mypackage.MyApplication" >
...
</application>
希望有帮助,如果您还有其他问题,请告诉我。
答案 1 :(得分:0)
尝试使缓存无效并重新启动android studio。转到文件->使缓存无效/重新启动