InflateException仅在签名的apk中

时间:2016-07-03 23:00:25

标签: android apk proguard android-proguard signed-apk

java.lang.RuntimeException: Unable to start activity ComponentInfo{muhammad.ibrahim.alkady.al_quran_al_kareem.radio/muhammad.ibrahim.alkady.al_quran_al_kareem.radio.activities.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #126: Binary XML file line #126: Error inflating class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #126: Binary XML file line #126: Error inflating class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:740)
at android.view.LayoutInflater.inflate(<Xposed>)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.a.ag.b(Unknown Source)
at android.support.v7.a.u.setContentView(Unknown Source)
at muhammad.ibrahim.alkady.al_quran_al_kareem.radio.activities.MainActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
t android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
Caused by: android.view.InflateException: Binary XML file line #126: Binary XML file line #126: Error inflating class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:740)
at android.view.LayoutInflater.inflate(<Xposed>)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at muhammad.ibrahim.alkady.al_quran_al_kareem.radio.fragments.MainFragment.a(Unknown Source)
at android.support.v4.b.u.b(Unknown Source)
at android.support.v4.b.ag.a(Unknown Source)
at android.support.v4.b.ag.b(Unknown Source)
at android.support.v4.b.ag.a(Unknown Source)
at android.support.v4.b.ag.a(Unknown Source)
at android.support.v4.b.ac.a(Unknown Source)
at android.support.v4.b.x.a(Unknown Source)
at android.support.v4.b.s.onCreateView(Unknown Source)
at android.support.v4.b.x.onCreateView(Unknown Source)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:754)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:740) 
at android.view.LayoutInflater.inflate(<Xposed>) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.a.ag.b(Unknown Source) 
at android.support.v7.a.u.setContentView(Unknown Source) 
at muhammad.ibrahim.alkady.al_quran_al_kareem.radio.activities.MainActivity.onCreate(Unknown Source) 
at android.app.Activity.performCreate(Activity.java:6251) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
Caused by: android.view.InflateException: Binary XML file line #126: Error inflating class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController
at android.view.LayoutInflater.createView(LayoutInflater.java:628)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.Layout

的build.gradle

    apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "muhammad.ibrahim.alkady.al_quran_al_kareem.radio"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 10
        versionName "1.9"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies { compile fileTree(include: ['*.jar'], dir: 'libs')
    apt 'com.jakewharton:butterknife-compiler:8.1.0'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.jakewharton:butterknife:8.1.0'
    compile 'com.google.android.exoplayer:exoplayer:r1.5.9'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'jp.wasabeef:recyclerview-animators:2.2.3'
    compile 'com.sothree.slidinguppanel:library:3.3.0'
    compile('com.afollestad:sectioned-recyclerview:0.2.2') {
        transitive = true
    }
    compile('com.mikepenz:aboutlibraries:5.7.0@aar') {
        transitive = true
    }
}

此异常仅在签名的apk中引发。当安装未签名的apk没有引发错误。从搜索它似乎解决方案是修改proguard-rules.pro但不幸的是我不知道如何做到这一点。请帮助。 感谢

2 个答案:

答案 0 :(得分:0)

看起来下面的类已被混淆,但是被某些布局引用:

muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController

你可以保持这样:

-keep class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.MiniMediaController

将小部件包中的所有视图类(以及它们的公共方法)保留在一起可能会更好:

-keep class muhammad.ibrahim.alkady.al_quran_al_kareem.radio.widget.** extends android.view.View {
   public <methods>;
}

答案 1 :(得分:0)

将类MiniMediaController构造函数从protected更改为public可以在有或没有pro-guard规则的情况下解决问题。