2015-09-05 9 views
5

sorunsuz çalışıyor Çok garip bir durum. Projemi oluşturabilir, projemi temizleyebilir ve kurabilirim ve hatta hata ayıklama modunu kullanarak fiziksel aygıtta bile çalışabilirim. Google Analytics web sayfasında istediğim tüm verileri de aldım.Google Analytics'i ekledikten sonra APK üretilemiyor, ancak hata ayıklama modunda

Üzgünüz, Android Studio sürüm sürümüdür, .apk dosyası oluşturmuyor. Tam olarak Add Analytics to Your Android App, resmi eğitmen'u takip ettim ve birçok cevap arandı, fakat bu tam olarak sorun hala var. İşte

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

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 

    defaultConfig { 
     applicationId "com.comname.appname" 
     minSdkVersion 11 
     targetSdkVersion 23 
     versionCode 18 
     versionName "2.7" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      zipAlignEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 


dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile files('libs/achartengine-1.1.0.jar') 
    compile files('libs/SalatCalculator.jar') 
    compile 'com.android.support:appcompat-v7:23.0.0' 
    compile 'com.android.support:support-v4:23.0.0' 
    compile 'com.google.android.gms:play-services-analytics:7.8.0' 
} 

Gradle kurmak rapordur:

Benim build.gradle şöyle

Information:Gradle tasks [:app:assembleRelease] 
:app:preBuild UP-TO-DATE 
:app:preReleaseBuild UP-TO-DATE 
:app:checkReleaseManifest 
:app:preDebugBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics780Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE 
:app:prepareReleaseDependencies 
:app:compileReleaseAidl 
:app:compileReleaseRenderscript 
:app:generateReleaseBuildConfig 
:app:generateReleaseAssets UP-TO-DATE 
:app:mergeReleaseAssets 
:app:generateReleaseResValues UP-TO-DATE 
:app:processReleaseGoogleServices 
:app:generateReleaseResources 
:app:mergeReleaseResources 
:app:processReleaseManifest 
:app:processReleaseResources 
:app:generateReleaseSources 
:app:processReleaseJavaRes UP-TO-DATE 
:app:compileReleaseJavaWithJavac 
Note: D:\D\AndroidStudio\AppName\app\src\main\java\com\comname\AppName\util\NotificationGenerator.java uses or overrides a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
:app:compileReleaseNdk UP-TO-DATE 
:app:compileReleaseSources 
:app:proguardRelease 
Warning:com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair 
Warning:com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.client.utils.URLEncodedUtils 
Warning:com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair 
Warning:com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair 
Warning:com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.client.utils.URLEncodedUtils 
Warning:com.google.android.gms.analytics.internal.zzj: can't find referenced class org.apache.http.NameValuePair 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpEntity 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpResponse 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.StatusLine 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.methods.HttpGet 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.conn.ClientConnectionManager 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.impl.client.DefaultHttpClient 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.params.BasicHttpParams 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.methods.HttpGet 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.impl.client.DefaultHttpClient 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.params.BasicHttpParams 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpEntity 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpResponse 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.StatusLine 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.conn.ClientConnectionManager 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.HttpResponse 
Warning:com.google.android.gms.internal.zzqt: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.tagmanager.zzby: can't find referenced class org.apache.http.impl.client.DefaultHttpClient 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.Header 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntity 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpHost 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpResponse 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.StatusLine 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.ClientProtocolException 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.message.BasicHttpEntityEnclosingRequest 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpHost 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.message.BasicHttpEntityEnclosingRequest 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntity 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpResponse 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.StatusLine 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient 
Warning:com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest 
Warning:there were 61 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) 
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:dexRelease 
:app:validateExternalOverrideSigning 
:app:packageRelease FAILED 
Error:Execution failed for task ':app:packageRelease'. 
> Unable to compute hash of D:\D\AndroidStudio\AppName\app\build\intermediates\classes-proguard\release\classes.jar 

Ayrıca, bu dosya için Lint yayınlanmış olan ve herhangi göstermemiş Note: D:\D\AndroidStudio\AppName\app\src\main\java\com\comname\AppName\util\NotificationGenerator.java uses or overrides a deprecated API. ilgili böyle bir uyarı.

cevap

8

Sorun, proguard ile ilişkilidir, sadece serbest bırakma profilinde (minifyEnabled true) etkinleştirilmiş bir koruyucu mevcuttur. false bu özelliğini ayarlayarak

  1. Devre Dışı Proguard:

    İki seçeneğiniz vardır. Bu seçenek gerçekten uygulaması serbest bırakacaksanız, tavsiye edilmez.

  2. Proguard'a Analytics ile doğru şekilde çalışmak için kurallar ekleyin. Bu kurallar dosyasına proguard-rules.pro eklenmelidir ve bu bir örnektir:

    -keep class com.google.android.gms.** { *; } 
    -dontwarn com.google.android.gms.** 
    

Daha Android Developers Page yılında ProGuard hakkında bilgiler ve official project page

yardımcı olur Umut.

+0

hangisi? –

+0

Ayrıca, şimdi .apk dosyası oluşturuldu, dosya boyutunda neredeyse 1 MB artış görüyorum. Uygun mu? –

+0

1MB'lık artış, devre dışı bırakma seçeneğini doğru seçtiğinizden mi? Proguard'ın kullanılmayan kodu ve diğer optimizasyonları da ortadan kaldırdığı için mantıklıdır. – sabadow

0

Google'ın sorunu çözmesi için daha fazla tercih ettiğim bir çözüm daha var. Eksik sınıflar ekleyebilir ve bazı ClassNotFoundException olabileceği konusunda endişelenmeyin.

Yani sadece bu gradle config ekleyin: Eğer önermek bu iki seçenekten

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