android studio 混淆 找不到 sendBroadcast 40C

在混淆代码是,报如下错误,
can't find referenced method 'void sendBroadcast(android.content.Intent)'

如果不混淆,是找得到的,而且在混淆配置文件里面加了-dontwarn android.content.** -keep class android.content.** {*;}

4个回答

在混淆代码是,包如下错误,如果不混淆,是找得到的,而且在混淆配置文件proguard-rules.pro里面加了-dontwarn java.content.** -keep class java.content.** {*;}
can't find referenced method 'void sendBroadcast(android.content.Intent)'

混淆添加的不正确:Android 4大组件,view,序列化类,枚举,监听方法不能混淆,正确混淆格式如下
#---------------------------------1.实体类---------------------------------
#如:-keep class com.ex..entity.** { ; }
#---------------------------------2.第三方包-------------------------------
#如eventbus
-keepclassmembers class *
{
@ org.greenrobot.eventbus.Subscribe ;
}
-keep enum org.greenrobot.eventbus.ThreadMode {*; }
#如gson
-keep class com.google.gson.stream.** { *; }

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

-keep public class com.tencent.bugly.**{*;}
如#rocoofix
-keep class com.dodola.rocoofix.** {*;}
-keep class com.lody.legend.** {*;}
-keep class com.AMBE.** {*;}
#如okhttp
-dontwarn okhttp3.**
-keep class okhttp3.**{*;}
#如okio
-dontwarn okio.**
-keep class okio.**{*;}
#---------------------------------3.与js互相调用的类------------------------
#如-keepclasseswithmembers class com.demo.login.bean.ui.MainActivity$JSInterface {

;

#}
#---------------------------------4.反射相关的类和方法-----------------------
#如-keep class com.baolan.blrecode.patch.** {*;}
#---------------------------------5.基本不用动区域--------------------------------------------
#---------------------------------基本指令区---------------------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-printmapping proguardMapping.txt
-optimizations !code/simplification/cast,!field/*,!class/merging/*
-keepattributes Annotation,InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
#---------------------------------默认保留区----------------------
-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.view.View
-keep public class com.android.vending.licensing.ILicensingService
-keep class android.support.** {*;}

-keepclasseswithmembernames class * {
native ;
}
-keepclassmembers class * extends android.app.Activity{
public void (android.view.View);
}
-keepclassmembers enum * {
public static *
[] values();
public static ** valueOf(java.lang.String);
}
-keep public class * extends android.view.View{
*** get*();
void set*(***);
public (android.content.Context);
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet);
public (android.content.Context, android.util.AttributeSet, int);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator ;
}
-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();
}
-keep class *
.R$* {
;
}
-keepclassmembers class * {
void *(
*On*Event);
}

#---------------------------------6webview---------------------------
-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
public *;
}
-keepclassmembers class * extends android.webkit.WebViewClient {
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
public boolean *(android.webkit.WebView, java.lang.String);
}
-keepclassmembers class * extends android.webkit.WebViewClient {
public void *(android.webkit.WebView, jav.lang.String);
}

You shouldn't add any -keep options for this issue; the Android SDK already specifies the basic Android-related -keep options for you.

qq_31476705
qq_31476705 如果不加 -keep选项,这么会有很多告警,build 会失败
一年多之前 回复

在田面天价context 就可以解决了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!