我是新的Android工作室。我创建了一个Java项目,主要使用SQLite数据库(在资源文件夹中)。我将此项目从netbeans迁移到android studio。当我按下run并选择一个模拟器时,Gradle Build Tasks开始执行并出现错误,其中包含:
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 39s
控制台中的完整错误输出显示:
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
这是按下' run'
后的堆栈跟踪执行任务:[:app:assembleDebug]
multiDexEnabled true
网上有很多解决方案,例如gradle.build
放在我已经拥有的 apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.bcosta.myapplication"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
文件中。
更新这是我的gradle.build文件
RewriteEngine On
RewriteRule ^([^_]*)_([^_]*)\.html$ /?s=scheda&id=$1&slug=$2 [L]
RewriteRule ^([^/]*)\.html$ /?s=$1 [L]
答案 0 :(得分:0)
试试这个,
Service.startForeground(int, android.app.Notification)
如果您没有自定义Application类,请将此行添加到
android { defaultConfig { ... multiDexEnabled true } } dependencies { compile 'com.android.support:multidex:1.0.1' }
manifest
如果您已拥有自己的Application类,请将其扩展为
<application android:name="android.support.multidex.MultiDexApplication" .....your code
而不是android.support.multidex.MultiDexApplication
android.app.Application
答案 1 :(得分:0)
这似乎是一个没有确定解决方案的常见问题。
尝试:
如果这不起作用,请尝试将以下内容添加到build.gradle
:
android {
dexOptions{
jumboMode=true;
javaMaxHeapSize "4g"
}
}
另外,尝试文件 - &gt;使高速缓存/重新启动无效