2015-10-08 5 views
9

यह लंबे समय से रहा है, अगर कभी मैंने स्टैक ओवरफ्लो पर एक प्रश्न पूछा है। हालांकि मैं इसे लगभग दैनिक आधार का उपयोग करता हूं। वैसे भी; यहां यह जाता है:एंड्रॉइड स्टूडियो, ProGuard कक्षाओं के हैश की गणना करने में असमर्थ .jar

हाल ही में मैंने एपीआई 23 पर स्विच किया है; जिसने मुझे

useLibrary 'org.apache.http.legacy' 

का उपयोग करने के लिए मजबूर किया क्योंकि उन्होंने अपाचे लाइब्रेरी तक आसानी से पहुंच डाली है।

मेरा प्रोजेक्ट ठीक से संकलित करता है और डीबग मोड में सभी टेस्ट-डिवाइसों में ठीक चलता है। आज मैं उत्पादन करने के लिए अपने प्रोजेक्ट लाने की जरूरत है और ProGuard

की (..) \ निर्माण \ मध्यवर्ती \ वर्गों-ProGuard \ रिहाई \ classes.jar '

हैश गणना करने में असमर्थ के साथ चिल्लाता कोई अन्य त्रुटियां या चेतावनी नहीं है। वहां होता था लेकिन मैं उनसे छुटकारा पाता था। अपाचे पुस्तकालयों की डुप्लिकेट प्रतियों से छुटकारा पाने की तरह।

यहाँ मेरी Gradle फ़ाइल है:

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.1' 

    } 
} 

apply plugin: 'com.android.application' 

repositories { 
    maven { url "http://dl.bintray.com/populov/maven" } 
    mavenCentral() 
    jcenter() 
} 


dependencies { 
    compile 'com.github.lzyzsd:circleprogress:[email protected]' 
    compile('com.fasterxml.jackson.datatype:jackson-datatype-joda:2.0.4') { 
     exclude module: 'joda-time' 
    } 
    compile 'net.danlew:android.joda:2.8.1' 
    compile "commons-io:commons-io:+" 
    compile 'com.google.android.gms:play-services-location:7.8.0' 
    compile 'com.google.android.gms:play-services-nearby:7.8.0' 
    compile ('com.google.apis:google-api-services-translate:v2-rev41-1.20.0') 
      { 
       // Exclude artifacts that the Android SDK/Runtime provides. 
       exclude group: 'xpp3', module: 'shared' 
       exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
       exclude group: 'junit', module: 'junit' 
       exclude group: 'com.google.android', module: 'android' 
      } 
    compile ('com.google.http-client:google-http-client-android:1.18.0-rc') 
      { 
       // Exclude artifacts that the Android SDK/Runtime provides. 
       exclude group: 'xpp3', module: 'shared' 
       exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
       exclude group: 'junit', module: 'junit' 
       exclude group: 'com.google.android', module: 'android' 
      } 

    compile 'com.theartofdev.edmodo:android-image-cropper:1.0.+' 
    compile 'com.viewpagerindicator:library:[email protected]' 
    compile 'me.leolin:ShortcutBadger:[email protected]' 
    compile 'com.android.support:appcompat-v7:23.0.+' 
    compile "com.android.support:support-v4:23.0.+" 
    compile "com.android.support:gridlayout-v7:23.0.+" 
    compile "com.android.support:cardview-v7:23.0.+" 
    compile (
      [group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.4.1'], 
      [group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.4.1'], 
      [group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.4.1'] 
    ) 
    compile 'de.undercouch:bson4jackson:2.4.0' 

} 

// The sample build uses multiple directories to 
// keep boilerplate and common code separate from 
// the main sample code. 
List<String> dirs = [ 
    'main',  // main sample code; look here for the interesting stuff. 
    'common', // components that are reused by multiple samples 
    'template'] // boilerplate code that is generated by the sample template process 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 
    useLibrary 'org.apache.http.legacy' 
    defaultConfig { 
     minSdkVersion 10 
     targetSdkVersion 23 
    } 
    buildTypes { 
     debug { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 

     } 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
    sourceSets { 
     main { 
      dirs.each { dir -> 
       java.srcDirs "src/${dir}/java" 
       res.srcDirs "src/${dir}/res" 
      } 
     } 
     androidTest.setRoot('tests') 
     androidTest.java.srcDirs = ['tests/src'] 

    } 
    packagingOptions { 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
    } 

} 

और यहाँ जाता है ProGuard-rules.txt

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in C:\android-sdk/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the proguardFiles 
# directive in build.gradle. 
# 
# For more details, see 
# http://developer.android.com/guide/developing/tools/proguard.html 

# Only obfuscate 


-dontshrink 

# Keep source file and line numbers for better crash logs 
-keepattributes SourceFile,LineNumberTable 

# Avoid throws declarations getting removed from retrofit service definitions 
-keepattributes Exceptions 

# Allow obfuscation of android.support.v7.internal.view.menu.** 
# to avoid problem on Samsung 4.2.2 devices with appcompat v21 
# see https://code.google.com/p/android/issues/detail?id=78377 
-keep class !android.support.v7.internal.view.menu.** { *; } 

# Amazon IAP library has some missing stuff 
-dontwarn com.amazon.** 

# ButterKnife uses some annotations not available on Android. 
-dontwarn butterknife.internal.** 
# Prevent ButterKnife annotations from getting renamed. 
-keepnames class * { @butterknife.InjectView *;} 

# Eventbus methods can not be renamed. 
-keepclassmembers class ** { 
    public void onEvent*(**); 
} 

# Gson uses generic type information stored in a class file when working with fields. Proguard 
# removes such information by default, so configure it to keep all of it. 
-keepattributes Signature 
# Gson specific classes 
-dontwarn sun.misc.Unsafe 

# joda-time has some annotations we don't care about. 
-dontwarn org.joda.convert.** 

# OkHttp has some internal stuff not available on Android. 
-dontwarn com.squareup.okhttp.internal.** 

# Okio has some stuff not available on Android. 
-dontwarn java.nio.file.* 
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 

# Oltu has some stuff not available on Android (javax.servlet), we don't use (slf4j) 
# and not included because it is available on Android (json). 
-dontwarn javax.servlet.http.** 
-dontwarn org.slf4j.** 
-dontwarn org.json.** 
-dontwarn com.fasterxml.** 

# Retrofit has some optional dependencies we don't use. 
-dontwarn rx.** 
-dontwarn retrofit.appengine.** 

मैं अपने प्रोजेक्ट इनसे मुक्त कर; एंड्रॉइड स्टूडियो को फिर से शुरू किया गया, पूरे बिल्ड निर्देशिका को भी मिटा दिया।

Result: 
Information:Gradle tasks [:Application:assembleRelease] 
:Application:preBuild UP-TO-DATE 
:Application:preReleaseBuild UP-TO-DATE 
:Application:checkReleaseManifest 
:Application:preDebugBuild UP-TO-DATE 
:Application:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE 
:Application:prepareComAndroidSupportCardviewV72300Library UP-TO-DATE 
:Application:prepareComAndroidSupportGridlayoutV72300Library UP-TO-DATE 
:Application:prepareComAndroidSupportSupportV42300Library UP-TO-DATE 
:Application:prepareComGithubLzyzsdCircleprogress110Library UP-TO-DATE 
:Application:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE 
:Application:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE 
:Application:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE 
:Application:prepareComGoogleAndroidGmsPlayServicesNearby780Library UP-TO-DATE 
:Application:prepareComTheartofdevEdmodoAndroidImageCropper104Library UP-TO-DATE 
:Application:prepareComViewpagerindicatorLibrary241Library UP-TO-DATE 
:Application:prepareMeLeolinShortcutBadger1010Library UP-TO-DATE 
:Application:prepareNetDanlewAndroidJoda281Library UP-TO-DATE 
:Application:prepareReleaseDependencies 
:Application:compileReleaseAidl UP-TO-DATE 
:Application:compileReleaseRenderscript UP-TO-DATE 
:Application:generateReleaseBuildConfig UP-TO-DATE 
:Application:generateReleaseAssets UP-TO-DATE 
:Application:mergeReleaseAssets UP-TO-DATE 
:Application:generateReleaseResValues UP-TO-DATE 
:Application:generateReleaseResources UP-TO-DATE 
:Application:mergeReleaseResources UP-TO-DATE 
:Application:processReleaseManifest UP-TO-DATE 
:Application:processReleaseResources UP-TO-DATE 
:Application:generateReleaseSources UP-TO-DATE 
:Application:processReleaseJavaRes UP-TO-DATE 
:Application:compileReleaseJavaWithJavac UP-TO-DATE 
:Application:compileReleaseNdk UP-TO-DATE 
:Application:compileReleaseSources UP-TO-DATE 
:Application:lintVitalRelease 
:Application:proguardRelease UP-TO-DATE 
:Application:dexRelease UP-TO-DATE 
:Application:validateExternalOverrideSigning 
:Application:packageRelease FAILED 
Error:Execution failed for task ':Application:packageRelease'. 
> Unable to compute hash of C:\Users\rafal_000\Projekty\Application\build\intermediates\classes-proguard\release\classes.jar 
Information:BUILD FAILED 
Information:Total time: 6.694 secs 
Information:1 error 
Information:0 warnings 
Information:See complete output in console 
+2

'./gradlew स्वच्छ इकट्ठा करें' कोशिश करें और देखें कि क्या आपको अपनी प्रोजेक्ट चेतावनी मिलती है तो – iagreen

+0

मुझे Gradlew उपयोगिता को इंगित करने के लिए धन्यवाद! ऐसा लगता है कि एंड्रॉइड स्टूडियो द्वारा आंतरिक रूप से कुछ इस्तेमाल किया जाता है? यह मुझे एड्रॉइड स्टूडियो में निर्माण करते समय चेतावनी दिखाई नहीं दे रहा है। जावा पर्यावरण चर के साथ एक समस्या थी और एक और बात मुझे याद है। मुझे पता नहीं है कि इसे एक उत्तर के रूप में कैसे चिह्नित करें या आपको कोई अंक असाइन करें। – Rafal

उत्तर

1

जैसा कि इग्रीन ने अपनी टिप्पणी में उल्लेख किया है; मैंने अधिक विस्तृत त्रुटियों के लिए gradlew कमांड लाइन उपयोगिता का उपयोग किया। यह पता चला कि JAVA_HOME चर के साथ एक समस्या थी। हल किया।

+1

कौन सा आदेश gradlew? – Caipivara

+0

यह आदेश: './gradlew connectedDevDebugAndroidTest --stacktrace' –

संबंधित मुद्दे