2015-09-27 59 views
4

我試圖生成一個簽名的apk和日誌一直顯示我下面的錯誤:無法登錄發佈APK - :應用程序:shrinkReleaseMultiDexComponents失敗

:app:compileReleaseJavaWithJavac 
Note: Some input files use or override a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
:app:compileReleaseNdk UP-TO-DATE 
:app:compileReleaseSources 
:app:collectReleaseMultiDexComponents 
:app:proguardRelease 
Warning:com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient 
Warning:com.google.android.gms.internal.zzw: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzw$zza 
Warning:com.google.android.gms.internal.zzw$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzw$zza 
Warning:com.ironsource.mobilcore.j: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification 
Warning:com.mopub.volley.toolbox.HttpClientStack: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.mopub.volley.toolbox.HttpClientStack$HttpPatch 
Warning:com.mopub.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced method 'void setURI(java.net.URI)' in program class com.mopub.volley.toolbox.HttpClientStack$HttpPatch 
Warning:com.mopub.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient 
Warning:there were 4 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) 
Warning:there were 1 unresolved references to library class members. 
     You probably need to update the library versions. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) 
Exception while processing task 
java.io.IOException: Please correct the above warnings first. 
    at proguard.Initializer.execute(Initializer.java:473) 
    at proguard.ProGuard.initialize(ProGuard.java:233) 
    at proguard.ProGuard.execute(ProGuard.java:98) 
    at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) 
    at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) 
    at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) 
    at com.android.builder.tasks.Job.runTask(Job.java:48) 
    at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) 
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) 
    at java.lang.Thread.run(Thread.java:745) 
:app:shrinkReleaseMultiDexComponents FAILED 
Error:Execution failed for task ':app:shrinkReleaseMultiDexComponents'. 
> java.io.IOException: The output jar [<project_path>\app\build\intermediates\multi-dex\release\componentClasses.jar] must be specified after an input jar, or it will be empty. 

下面是我應用一級的build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.my.app" 
     minSdkVersion 14 
     targetSdkVersion 23 
     versionCode 25 
     versionName "2.5" 

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

    dexOptions { 
     incremental true 
     javaMaxHeapSize "2048M" 
    } 
} 

repositories { 
    mavenCentral() 
    maven { url "https://jitpack.io" } 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.android.support:appcompat-v7:23.0.1' 
    compile 'com.android.support:design:23.0.1' 
    compile 'com.android.support:recyclerview-v7:23.0.1' 
    compile 'com.google.android.gms:play-services:8.1.0' 
    compile 'com.google.code.gson:gson:2.3.1' 
    compile 'com.squareup.okhttp:okhttp:2.4.0' 
    compile 'com.facebook.android:facebook-android-sdk:4.2.0' 
    compile 'me.dm7.barcodescanner:zxing:1.7.2' 
    compile 'de.hdodenhof:circleimageview:1.3.0' 
    compile 'com.scottyab:secure-preferences-lib:0.1.3' 
    compile 'com.soundcloud.android:android-crop:[email protected]' 
    compile('com.afollestad.material-dialogs:core:[email protected]') { 
     transitive = true 
    } 
    compile('com.mopub:mopub-sdk:[email protected]') { 
     transitive = true 
    } 
    compile project(':android-support-v4-preferencefragment') 
    compile project(':circular_progress_bar') 
    compile files('libs/mobilecore_V1.1.jar') 
    compile files('libs/libAdapterSDKMoPub.jar') 
    compile files('libs/adcolony.jar') 
} 

而且我頂級的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

我已經嘗試過其他版本的gradle,如1.4.0-beta1', 1.4.0-beta21.3.1仍然沒有運氣。

+0

說明顯而易見:應用程序級build.gradle中的行:multiDexEnabled true導致該問題。 – LonelyIdiot

+0

你有解決方法嗎?因爲它超過了65k的限制,我必須啓用'multiDex' – Lancelot

+0

我希望我可以幫忙,但我對multiDex一無所知,抱歉。我希望你很快找到解決方案。 – LonelyIdiot

回答

3

有一個在你的跟蹤一些信息就在那裏 -

Warning:there were 4 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)

你的問題中至少有一部分是AndroidHttpClient在API 23取出,和你的文庫中的至少一個依賴於它。你有三個選擇。

1)您可以在您的build.gradle文件中包含以下內容。其中包括您的apk中的遺留庫。見Apache HTTP Client Removal

android { 
    useLibrary 'org.apache.http.legacy' 
} 

2)你可以降低你的目標和編譯SDK至22,而不是23,這應該讓你編譯,或者至少解決問題AndroidHttpClient直到庫更新,不需要它。

3)您可以將-dontwarn命令添加到您的proguard文件中,以禁止警告以獲取構建。正如文件中指出的那樣,如果您不確定警告是否可以安全地被忽略,這可能是危險的。我不確定是否忽略了HttpClient和相關類別的移除導致的警告是否安全。在M上運行時可能會導致構建不穩定,但對於L及以下版本應該是安全的,因爲這些類存在於該API級別的設備上。

增加: 因爲凡鬥爭一樣,請記住,你必須降低你的builToolsVersioncom.android.support在依賴於22.0.1

+1

我有這個問題。確保你正在使用庫的更新版本,因爲它們可能已經不使用Apache Http。 – fbarrosodev

0

這是一個很容易解決的問題。當你開發一個應用程序,並在你更新SDK的過程中,這個問題會上升。這很好,但是你不知道你的gradle配置項目應該是最新的。所以簡單地創建一個新項目,看看你的classpath哪些是我的項目com.android.tools.build:gradle:1.3.1在項目中,但現在新項目類路徑是classpath 'com.android.tools.build:gradle:1.5.0'。另一件要考慮的是compileSdkVersion,buildToolsVersion,targetSdkVersion。你還應該檢查你的庫版本是否是最新的。你可以通過簡單地打開你的SDK管理器來找到他們的版本。 所以把它包起來: 這就是你的項目gradle這個應該被更新:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.5.0' //update this section to the lates gradle core available 
    } 
} 

,這是gradle這個模塊級文件的部分應該更新:

android { 
    compileSdkVersion 23 // update this one 
    buildToolsVersion "23.0.2" // update this one 

    defaultConfig { 
     applicationId "ranjbar.hadi.something" 
     minSdkVersion 14 
     targetSdkVersion 23 // update this one 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 
        'proguard-rules.pro' 
     } 
    } 
} 

希望這有助於

+0

請不要張貼[重複的答案](// stackoverflow.com/help/deleted-answers)。相反,請調整您對特定問題的答案。如果你有必要的信譽點,你可以[flag](// stackoverflow.com/privileges/flag-posts)或[vote-to-close](// stackoverflow.com/privileges/close-questions)作爲重複的問題, 在適當情況下。 –

+0

@你好,下次我會嘗試將用戶引薦給我的回覆鏈接 – hadi

相關問題