生成签名Apk - 任务执行失败':app:transformClassesWithDexForRelease'

时间:2016-06-17 10:33:16

标签: android android-studio android-gradle apk android-proguard

当我切换到调试模式时,我可以运行我的应用程序但是当我切换到发布模式时它会失败。

错误:

  

任务执行失败':app:transformClassesAndResourcesWithProguardForRelease'。   java.io.IOException:请先纠正上述警告。

-

的build.gradle

// form
= f.input :file, as: :file_hack

修改 如您所见,我的build.gradle文件中启用了multidex。

编辑2:

App.java

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

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.application.app"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
    }
}

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
}

dependencies {
compile 'com.sromku:simple-storage:1.2.0'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile project(':yandexmapkitlibrary')
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile 'com.google.code.gson:gson:2.6.2'

compile 'com.github.bumptech.glide:glide:3.7.0'
}

清单

public class App extends MultiDexApplication {

public static GoogleAnalytics analytics;
public static Tracker tracker;

@Override
public void onCreate() {
    super.onCreate();
    MultiDex.install(this);

    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800);
    tracker = analytics.newTracker("myAnalyticsId");
    tracker.enableExceptionReporting(true);
    tracker.enableAdvertisingIdCollection(true);
}

}

1 个答案:

答案 0 :(得分:2)

问题在于使用com.google.android.gms:play-services:9.0.2 而不是使用所有谷歌播放服务尝试使用你需要的

是的,你正在使用

compile 'com.google.android.gms:play-services-analytics:9.0.2'

然后

compile 'com.google.android.gms:play-services:9.0.2'

play-services-analytics:9.0.2

中包含play-services:9.0.2

删除

com.google.android.gms:play-services:9.0.2