Android 应用程序在调试模式下工作,但在发布模式下不工作
我有一个应用程序,现在我要发布它。 我已经创建了一个apk文件并安装了它,但是当我向服务器发送登录请求时,它返回null 奇怪的是,当我用调试构建启动我的应用程序时,它工作得很好问题仅发生在释放模式。因此,我认为问题来自阅读后的proguard 这是我到目前为止所做的Android 应用程序在调试模式下工作,但在发布模式下不工作,android,proguard,android-proguard,Android,Proguard,Android Proguard,我有一个应用程序,现在我要发布它。 我已经创建了一个apk文件并安装了它,但是当我向服务器发送登录请求时,它返回null 奇怪的是,当我用调试构建启动我的应用程序时,它工作得很好问题仅发生在释放模式。因此,我认为问题来自阅读后的proguard 这是我到目前为止所做的 添加了所需的所有proguard规则。(改装,Okhttp3,滑动)-未工作 使用Build菜单中的[Build apk(s)]创建一个apk,并对其进行测试-工作正常,但处于调试状态 任何帮助都将不胜感激 这是我的build.g
defaultConfig {
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:gridlayout-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:animated-vector-drawable:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation 'com.squareup:otto:1.3.8'
implementation 'com.github.nisrulz:recyclerviewhelper:26.0.0'
implementation 'jp.wasabeef:recyclerview-animators:2.2.7'
implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
implementation 'com.blankj:utilcode:1.9.6'
implementation 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
implementation 'com.j256.ormlite:ormlite-core:5.0'
implementation 'com.j256.ormlite:ormlite-android:5.0'
implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.1.3'
implementation 'com.akexorcist:RoundCornerProgressBar:2.0.3'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.daimajia.easing:library:2.0@aar'
implementation 'com.daimajia.androidanimations:library:2.3@aar'
implementation files('libs/opencsv-3.8.jar')
implementation('tk.zielony:carbon:0.15.0.1') {
exclude group: 'com.android.support', module: 'animated-vector-drawable'
exclude group: 'com.android.support', module: 'gridlayout-v7'
}
implementation 'com.github.QuadFlask:colorpicker:0.0.13'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
implementation 'com.liulishuo.filedownloader:library:1.6.9'
implementation 'org.jsoup:jsoup:1.11.2'
implementation project(':typekit')
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
compile('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
transitive = true;
}
}
这是我的proguard-rules.pro文件
-dontwarn com.google.android.gms.common.GooglePlayServicesUtil
-ignorewarnings
-keep class * {
public private *;
}
# Retrofit
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain service method parameters.
-keepclassmembernames,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# OkHttp 3
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
# Glide
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-dontwarn com.google.android.gms.common.GooglePlayServicesUtil
-忽视警告
-上课*{
公私营*;
}
#改造
#保留泛型类型信息以供转换器和适配器反射使用。
-保留署名
#保留服务方法参数。
-keepclassmembernames,AllowFusion接口*{
@2.http.*;
}
#忽略用于构建工具的注释。
-dontwarn org.codehaus.mojo.animal_sniffer.ignorejrrequirement
#OkHttp 3
-dontwarn okhttp3**
-唐特沃恩·奥基奥**
-dontwarn javax.annotation**
#资源使用相对路径加载,因此必须保留此类的包。
#滑翔
-keepnames类okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keep public类*实现com.bumptech.glide.module.GlideModule
-保持公共类*扩展com.bumptech.glide.module.AppGlideModule
-保持公共枚举com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$**{
**[]美元价值;
公众*;
}
我犯了一个愚蠢的错误
我错过了一条前进的规则。哪个是奥托巴士的
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
我只搜索了github。没有关于proguard的章节。我在Square的博客上找到的
如果您的代码似乎受到proguard的影响,请检查两次并搜索更多 我在gradle.properties中添加了下面的一行,之后它工作得很顺利
android.enableR8 = false
您是否为调试模式和发布模式指向相同的URL?请禁用proguard并生成发布版本,然后重试。如果仍不起作用,则可能不是proguard问题。这是因为您在pro gaurd中遗漏了一些libs规则,您可以转到构建变体-->将应用更改为发布,然后运行应用并检查日志,您将在pro gaurd中找到缺失的规则。我尝试了在没有proguard的情况下发布构建,但仍然不起作用。无论如何,我发现了我的问题并解决了它!您在改装时使用哪种转换器?而且,这些行在我看来非常糟糕:-ignorewarnings
,-keep class*{public private*;}