在使用proguard files().list()收缩我的发布apk后,没有返回任何文件(在调试模式下会返回)。我使用快速入门示例进行登录。没有错误消息。登录似乎成功。
下面是我的proguard.cfg:
-optimizationpasses 1
#-dontoptimize
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!class/unboxing/enum
-dontwarn android.support.v4.**
-dontwarn com.google.**
#-keep public class com.google.**
#-keep public class android.**
#-keep class com.google.android.gms.** { *; }
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
#-keep public class * extends android.app.Activity
#-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
#-keep public class pub.devrel.easypermissions.**
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
这是用于检索文件的代码:
private List<String> getDataFromApi() throws Exception {
// Get a list of up to 10 files.
lib.setgstatus("getDataFromApi Start");
List<String> fileInfo = new ArrayList<String>();
FileList result = mService.files().list()
.setPageSize(10)
.setFields("nextPageToken, files(id, name)")
.execute();
lib.setgstatus(result.toString());
List<File> files = result.getFiles();
if (files != null) {
lib.setgstatus("getDataFromApi files.size:" + files.size());
for (File file : files) {
fileInfo.add(String.format("%s (%s)\n",
file.getName(), file.getId()));
}
}
else
{
lib.setgstatus("getDataFromApi files is null");
}
lib.setgstatus("getDataFromApi Finish");
return fileInfo;
}
toString()返回一个有效的JSON结果,但是files为null。
这是我的版本。gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "org.de.jmg.jmgphotouploader"
minSdkVersion 11
targetSdkVersion 24
}
signingConfigs {
release {
keyAlias 'jmgphotouploader'
keyPassword '****'
storeFile file('/pub/keystore')
storePassword '****'
}
debug {
keyAlias 'jmgphotouploader'
keyPassword '****'
storeFile file('/pub/keystore')
storePassword '****'
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
//shrinkResources true
//proguardFile 'proguard.cfg'
}
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFile 'proguard.cfg'
//proguardFile getDefaultProguardFile('proguard-android.txt')
//proguardFiles getDefaultProguardFile('proguard-android.txt') ,'proguard.cfg'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile project(':src')
compile project(':utilities')
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'pub.devrel:easypermissions:0.1.5'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-drive:v3-rev47-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
}
3条答案
按热度按时间wwtsj6pe1#
添加just
到proguard.cfg工作!
b4wnujal2#
检查相关的issue。
导出签名的APK时,Proguard是否有可能启动?如果您依赖即变量名将JSONMap到POJO,则可能会在没有适当的Proguard排除/规则的情况下刹车。查看您的
project.properties
文件并以proguard.config=<file_name>
的形式注解掉任何行。之后,导出另一个签名的APK并重新测试。确保将
minifyEnabled true
添加到build.gradle
文件中的适当构建类型中,以启用此documentation上所述的ProGuard代码收缩。kiz8lqtg3#
对我有效的是:
This issue和this proguard rules file一样有用