我得到了错误
Unable to start activity ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Run Code Online (Sandbox Code Playgroud)
当我通过肖像和横向模式切换时.我正在使用片段.我的xml是:
<LinearLayout android:id="@+id/mainLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView android:id="@+id/android:list"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<fragment android:id="@+id/fragmentDetails"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
class="de.androidbuch.activiti.task.TaskDetailsFragment"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如果我通过横向和纵向模式切换一切正常.但是当我点击我的片段(我可以看到我的片段)然后切换到另一种模式时,我得到了错误.知道怎么解决吗?在这里找到了一些答案,但这些都没有帮助我...
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): FATAL EXCEPTION: main
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): java.lang.RuntimeException: Unable to start activity
ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3097)
06-21 14:55:05.600: ERROR/AndroidRuntime(7636): at android.app.ActivityThread.access$1600(ActivityThread.java:123)
06-21 …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用了这里描述的一段代码
http://lexandera.com/2009/01/extracting-html-from-a-webview/
我创建.apk文件,将其安装在我的设备上,它正常工作.如果我尝试使用proguard的混淆项目失败,则不会到达MyJavaScriptInterface的方法showHTML(String html).
关于那个我的proguard配置
-keep public class com.mypackage.MyClass.MyJavaScriptInterface
-keep public class * implements com.mypackage.MyClass.MyJavaScriptInterface
-keepclassmembers class * implements com.mypackage.MyClass.MyJavaScriptInterface {
<methods>;
}
Run Code Online (Sandbox Code Playgroud)
根据这个答案Android proguard Javascript Interface问题.
解决了.
正如Eric建议的那样,我改变了这样的Proguard配置文件:
-keep public class com.mypackage.MyClass$MyJavaScriptInterface
-keep public class * implements com.mypackage.MyClass$MyJavaScriptInterface
-keepclassmembers class com.mypackage.MyClass$MyJavaScriptInterface {
<methods>;
}
Run Code Online (Sandbox Code Playgroud)
现在我的项目完美无缺.
对于API 17+,您还需要保留@JavascriptInterface注释:
-keepattributes JavascriptInterface
Run Code Online (Sandbox Code Playgroud)
http://developer.android.com/reference/android/webkit/JavascriptInterface.html