当前位置: 首页 > 知识库问答 >
问题:

在Android Studio中无法生成已签名的APK,'java.io.ioException'

司徒经纶
2023-03-14

我在Android Studio中生成签名的APK有一个问题。几天前它还很好,我不知道哪里出了问题。我在尝试fgenerate签名APK的任何项目中都得到了这个错误:

buildTypes {
    debug {
        shrinkResources false // This must be first
        minifyEnabled false   // This must be after shrinkResources
        multiDexEnabled true
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules-debug.pro"
    }
    release {
        shrinkResources true
        minifyEnabled true
        useProguard true
        multiDexEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
    }
}
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes Exceptions
-repackageclasses ''

-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 * extends android.app.
-keep public class com.android.vending.licensing.ILicensingService

-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
-keep class com.google.common.cache.LocalCache$ReferenceEntry

-dontnote com.android.vending.licensing.ILicensingService


-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}


-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class **.R$* {
  public static <fields>;
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.* { *; }
-keepattributes *Annotation,Signature
-dontwarn in.mylo.pregnancy.baby.app.**
-keep class in.mylo.pregnancy.baby.app.shapeimageview.**{ *; }

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep interface com.actionbarsherlock.** { *; }

-keep class butterknife.*
-keepclasseswithmembernames class * {
 @butterknife.* <methods>; }
-keepclasseswithmembernames class * {
 @butterknife.* <fields>; }


-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe

-dontwarn java.lang.ClassValue
-dontwarn com.google.j2objc.annotations.Weak
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement


-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

-dontwarn com.firebase.**
-dontnote com.firebase.client.core.GaePlatform

-keep class com.firebase.** { *; }

-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }

-dontwarn com.clevertap.android.sdk.**


-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontnote okhttp3.**

-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
    public static <fields>;
}

-dontwarn android.support.**

-dontwarn com.google.android.gms.**

-dontwarn com.fasterxml.**
-dontwarn okio.**
-dontwarn com.caverock.**
-dontwarn com.github.siyamed.shapeimageview.**


-dontwarn retrofit.**
-keep class retrofit.** { *; }
-dontwarn sun.misc.Unsafe
-dontwarn com.octo.android.robospice.retrofit.RetrofitJackson**
-dontwarn retrofit.appengine.UrlFetchClient
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}
-keep class com.google.gson.** { *; }
-keep class com.google.inject.** { *; }
-keep class org.apache.http.** { *; }
-keep class org.apache.james.mime4j.** { *; }
-keep class javax.inject.** { *; }
-keep class retrofit.** { *; }
-keep class retrofit2.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn retrofit.**
-dontwarn retrofit2.**

-dontwarn sun.misc.**

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
   long producerIndex;
   long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
   long producerNode;
   long consumerNode;
}

-keep class in.mylo.pregnancy.baby.app.retrofit.** { *; }

-keep interface org.parceler.Parcel
-keep @org.parceler.Parcel class * { *; }
-keep class **$$Parcelable { *; }

-keepnames public class * extends io.realm.RealmObject
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.** { *; }
-dontwarn javax.**
-dontwarn io.realm.**

-keepnames public class * extends io.realm.RealmObject


-dontwarn com.google.android.gms.location.**
-dontwarn com.google.android.gms.gcm.**
-dontwarn com.google.android.gms.iid.**

-keep class com.google.android.gms.gcm.** { *; }
-keep class com.google.android.gms.iid.** { *; }
-keep class com.google.android.gms.location.** { *; }

-keep class com.moe.pushlibrary.activities.** { *; }
-keep class com.moengage.locationlibrary.GeofenceIntentService
-keep class com.moe.pushlibrary.InstallReceiver
-keep class com.moengage.push.MoEPushWorker
-keep class com.moe.pushlibrary.providers.MoEProvider
-keep class com.moengage.receiver.MoEInstanceIDListener
-keep class com.moengage.worker.MoEGCMListenerService
-keep class com.moe.pushlibrary.models.** { *;}
-keep class com.moengage.core.GeoTask
-keep class com.moengage.location.GeoManager
-keep class com.moengage.inapp.InAppManager
-keep class com.moengage.push.PushManager
-keep class com.moengage.inapp.InAppController


-dontwarn com.moengage.location.GeoManager
-dontwarn com.moengage.core.GeoTask
-dontwarn com.moengage.receiver.*
-dontwarn com.moengage.worker.*
-dontwarn com.moengage.inapp.ViewEngine

-keep class com.delight.**  { *; }

-dontwarn com.google.android.gms.location.**
-keep class com.moe.** { *; }
-keep class com.moengage.** { *; }
-keep class com.delight.** { *; }

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



-keep class com.facebook.** {
   *;
}



-dontwarn android.databinding.**
-keep class android.databinding.** { *; }

共有1个答案

吕学
2023-03-14

您是否试图将proguard用于发布版本?

release {
    shrinkResources false
    minifyEnabled false
    useProguard false
    multiDexEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
}

如果这样做有效,您应该修复我们的proguard配置

 类似资料:
  • 我正在尝试生成签名APK。但由于生成时的lint错误而无法生成。我检查了我的lint报告,它在我的XML文件中显示错误。 林特在组装释放目标时发现致命错误。要继续,要么修复lint识别的问题,要么修改构建脚本,如下所示:...android{lintOptions{checkReleaseBuilds false//或者,如果您愿意,您可以继续检查版本构建中的错误,//但即使发现错误,也可以继续构

  • 我在生成签名apk时遇到麻烦。屏幕上显示的Lint错误以下错误显示所有com.android.support库都必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到的版本28.0.0, 27.1.0。示例包括“com.android.support:动画-矢量-绘图:28.0.0”和“com.android.support:exif界面:27.1.0” 构建中的依赖关系。gradle文件

  • 我正在尝试构建我的第一个签名APK以供发布,但出现了一些错误。看起来效果很好,但现在我就是无法生成APK。我做了研究,但什么也没找到。 Gradle版本:4.8,Android插件版本3.1.4,这是我的应用程序Gradle屏幕截图:link 这来自assembleDebug: 我曾经有过布局和不赞成使用的功能的其他问题,但我解决了它。其中一个就这样消失了,但我什么也没做:-) 我已经尝试过的事情

  • 将android studio更新到3.0版(windows)后,我无法生成已签名的APK。 构建完成后,我会收到以下消息: 单击“定位”会将我带到应用程序文件夹,但找不到APK。 发生了什么变化?

  • 通过以下命令提到留档,我试图生成签名apk android和得到以下错误 按照此链接生成生产apk http://facebook.github.io/react-native/docs/signed-apk-android.html 生成后通过以下命令构建apk成功生成 但是在安装apk启动后崩溃,并出现以下错误。