2014-12-18 6 views
40

sto cercando di compilare la mia app come assembleRelease in Android 1.0.1 Studio e ottenere il seguente messaggio:proguardRelease fallì quando la compilazione APK con assembleRelease in Android Studio

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:proguardRelease'. 
> java.io.IOException: Please correct the above warnings first. 

L'applicazione compila e funziona perfettamente in di debug modalità e assembleRelease ha funzionato con Android Studio 0.8.

Il file proguard-rules.pro è vuoto. Il file build.gradle e l'errore completo sono indicati di seguito.

Chiunque può aiutare?

build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 19 
    buildToolsVersion '19.1' 

    defaultConfig { 
     applicationId "com.xxx.xxx" 
     minSdkVersion 15 
     targetSdkVersion 19 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    lintOptions { 
     abortOnError false 
     absolutePaths false 
     lintConfig file("lint.xml") 
    } 
} 

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

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.urbanairship:urbanairship-lib:[email protected]' 
    compile 'com.google.android.gms:play-services:6.1.+' 
    compile 'me.grantland:autofittextview:[email protected]' 
    compile 'com.google.code.gson:gson:2.2.+' 
    compile 'net.danlew:android.joda:[email protected]' 
    compile 'com.android.support:support-v4:21.0.0' 
    compile 'com.android.support:support-v13:21.0.0' 
    compile 'com.squareup.okio:okio:[email protected]' 
    compile 'net.danlew:android.joda:2.4.0' 
    compile 'de.greenrobot:eventbus:2.2.1' 
    compile 'se.emilsjolander:stickylistheaders:2.5.0' 
    compile 'se.emilsjolander:StickyScrollViewItems:1.1.0' 
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' 
    compile 'com.sothree.slidinguppanel:library:2.0.2' 
    compile 'com.squareup.okhttp:okhttp:2.1.0' 
    compile 'com.squareup.picasso:picasso:2.4.0' 
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0' 
    compile 'de.greenrobot:eventbus:2.4.0' 
} 

L'errore è

13:40:19: Executing external task 'assembleRelease'... 
:app:preBuild 
:app:preReleaseBuild 
:app:checkReleaseManifest 
:app:preDebugBuild 
:app:prepareComAndroidSupportSupportV0Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServices6171Library UP-TO-DATE 
:app:prepareComSothreeSlidinguppanelLibrary202Library UP-TO-DATE 
:app:prepareComUrbanairshipUrbanairshipLib510Library UP-TO-DATE 
:app:prepareMeGrantlandAutofittextview011Library UP-TO-DATE 
:app:prepareNetDanlewAndroidJoda240Library UP-TO-DATE 
:app:prepareSeEmilsjolanderStickyScrollViewItems110Library UP-TO-DATE 
:app:prepareSeEmilsjolanderStickylistheaders250Library UP-TO-DATE 
:app:prepareReleaseDependencies 
:app:compileReleaseAidl 
:app:compileReleaseRenderscript 
:app:generateReleaseBuildConfig 
:app:generateReleaseAssets UP-TO-DATE 
:app:mergeReleaseAssets 
:app:generateReleaseResValues UP-TO-DATE 
:app:generateReleaseResources 
:app:mergeReleaseResources 
:app:processReleaseManifest 
:app:processReleaseResources 
:app:generateReleaseSources 
Note: <path_to_my_project>/app/src/main/java/com/xxx/xxx/fragments/MatchCenterFragment.java uses unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
:app:compileReleaseJava 
:app:lintVitalRelease 
:app:compileReleaseNdk 
:app:proguardRelease 
Warning: com.ooyala.android.player.WidevineLibPlayer: can't find superclass or interface com.widevine.drmapi.android.WVEventListener 
(more com.ooyala.* warnings) 
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl 
Warning: com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl 
Warning: com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpsURLConnection: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpURLConnection 
Warning: com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpsURLConnection: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpURLConnection 
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 
Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Files 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class java.nio.file.Path 
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption 
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 
Warning: there were 234 unresolved references to classes or interfaces. 
     You may need to add missing library jars or update their versions. 
     If your code works fine without the missing classes, you can suppress 
     the warnings with '-dontwarn' options. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) 
Warning: there were 4 unresolved references to program class members. 
     Your input classes appear to be inconsistent. 
     You may need to recompile the code. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember) 
:app:proguardRelease FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:proguardRelease'. 
> java.io.IOException: Please correct the above warnings first. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 14.674 secs 
Please correct the above warnings first. 
13:40:35: External task execution finished 'assembleRelease'. 
+0

L'output di build ha una serie di avvisi relativi a riferimenti errati e, nonostante il fatto che li chiami "avvisi", sembra che alla fine siano errori fatali. –

+0

@ScottBarta ma funziona in debug, quindi sembra essere un problema con proguard, e non so come fare il debug. – jul

risposta

47

Aggiungi questo al ProGuard di file (come proguard-rules.pro) impostazione

-dontwarn okio.** 
+1

dove mettere questa riga – myatmins

+2

@ septemberboy7 inserite nel file di impostazioni proguard come 'proguard-rules. pro ' – hoi

+0

usa dontwarn per ogni libreria che causa questo problema. Risposta corretta - upvote – blueether

13

ho dovuto disabilitare Proguard con

minifyEnabled false 

Non è la soluzione migliore, ma funziona.

+0

risolto questo problema grazie per il suggerimento! – Phoneswapshop

+5

Attenzione utilizzando minifyEnabled false, disabiliterà la protezione dell'app e la riduzione della dimensione apk. – Smeet

+2

Se si imposta minifyEnabled su false, proguard non ossiderà il codice! In un modo comune, è necessario impostarlo su true in modalità di rilascio. – StevenTB

7

Ho avuto lo stesso problema con Gradle 1.1.0. Ricordava alcuni vecchi riferimenti di classe che ho spostato, e non ho potuto creare apk.

Provare Build>Pulire.

Mi ha aiutato e ora posso creare di nuovo l'apk.

+0

Questo ha funzionato per me. – eqiz