2015-12-04 137 views
7

我在Android Studio中生成已签名的apk时出现以下错误。任务执行失败':app:shrinkReleaseMultiDexComponents'

:app:shrinkReleaseMultiDexComponents FAILED 
Error:Execution failed for task ':app:shrinkReleaseMultiDexComponents'. 
> java.io.IOException: The output jar [E:\SVN_studio\100's\trunk\app\build\intermediates\multi-dex\release\componentClasses.jar] must be specified after an input jar, or it will be empty. 
Information:BUILD FAILED 
Information:1 error 
Information:Total time: 35.975 secs 
Information:159 warnings 

这里是我的build.gradle文件

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 

android { 
compileSdkVersion 21 
buildToolsVersion "22.0.1" 

defaultConfig { 
    applicationId "<packageName>" 
    minSdkVersion 16 
    targetSdkVersion 21 
    versionCode 1 
    versionName "1.0" 
    multiDexEnabled true 
} 
buildTypes { 
    release { 
     minifyEnabled true 
     shrinkResources true 


    } 
} 
packagingOptions { 
    exclude 'META-INF/LICENSE.txt' 
} 
lintOptions { 
    abortOnError true; 
} 

} 

repositories { 
    mavenCentral() 
} 
repositories { 
    flatDir { 
    dirs 'libs' 
    } 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.nineoldandroids:library:2.4.0' 
compile 'com.android.support:design:22.2.1' 
compile 'com.google.android.gms:play-services-gcm:7.5.0' 
compile 'com.android.support:cardview-v7:21.0.+' 
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' 
compile 'com.android.support:support-v13:22.2.1' 
compile 'com.astuetz:pagerslidingtabstrip:1.0.1' 
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' 
compile 'com.android.support:recyclerview-v7:22.2.1' 
compile 'com.mikhaellopez:circularimageview:2.0.1' 
compile(name: 'app-debug', ext: 'aar') 
compile 'com.facebook.android:facebook-android-sdk:4.1.0' 
compile files('libs/YouTubeAndroidPlayerApi.jar') 
} 

不知道为什么我收到这些错误?谁能帮我?

+0

将'multiDexEnabled true'更改为'multiDexEnabled false' – Piyush

+0

如果您想使用'Proguard',那么必须在必须解决错误后编写'minifyEnabled true'。它已经解决了你的问题,但你的apk不安全。 –

+0

@PratikButani好的,设置为true后,我需要在proguard文件中进行更改吗? –

回答

3

尝试为false minifyEnable和同步工程

buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } } 
+6

那么如果他想使用'Proguard'呢?我想这不是一个解决方案,如果他想使用'Proguard' –

+0

我想使用Proguard,甚至想要解决这个问题。这个怎么做? – NarendraJi

2

设置minifyEnabledfalseSync gradle这个和项目。

2

尝试删除...

compile files('libs/YouTubeAndroidPlayerApi.jar')

因为

compile fileTree(include: ['*.jar'], dir: 'libs')

将编译所有jar文件。

+0

是做到了,还有一件事我做了minifyEnabled错误,它的工作原理 –

相关问题