当我试图在活动中启动一个片段时,我得到了以下异常。这似乎是一个常见的问题,我拥有答案中建议的所有必要的权限。痕迹不是很有帮助。
Process: com.eazysystems.transdoc, PID: 11129
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxx.xxxx/com.xxxx.xxxx.view.ViewRecordActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.eazysystems.transdoc.view.ViewRecordActivity.onCreate(ViewRecordActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.support.v4.app.Fragment.isSupportFragmentClass(Fragment.java:455)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2135)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(AppCompatDelegateImplV7.java:838)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(AppCompatDelegateImplV11.java:34)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:826)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.eazysystems.transdoc.view.ViewRecordActivity.onCreate(ViewRecordActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
此外,异常发生在setContentView(R.layout.activity\u view\u记录)
。我试图使应用程序尽可能简单,但它得到了同样的例外
public class ViewRecordActivity extends AppCompatActivity {
private static String RECORD_ID = "RECORD_ID";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_record);
/*Bundle extras = getIntent().getExtras();
Integer recordId = extras.getInt(RECORD_ID);*/
ViewRecordFragment viewRecordFragment = ViewRecordFragment.newInstance(1);
//viewRecordFragment.setArguments(getIntent().getExtras());
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager
.beginTransaction()
.replace(R.id.view_record_fragment, viewRecordFragment
).commit();
}
public static class ViewRecordFragment extends Fragment {
private static String RECORD_ID = "RECORD_ID";
public ViewRecordFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/*gridview = (GridView) getActivity().findViewById(R.id.image_grid_view);*/
//Integer recordId = getArguments().getInt(RECORD_ID);
//loadImageResourcesAsync(recordId);
return inflater.inflate(R.layout.fragment_view_record, container, false);
}
public static ViewRecordFragment newInstance(Integer recordId) {
ViewRecordFragment fragment = new ViewRecordFragment();
//fragment.loadImageResourcesAsync(recordId);
/*Bundle bundle = new Bundle();
bundle.putInt(RECORD_ID, recordId);
fragment.setArguments(bundle);*/
return fragment;
}
private void loadImageResourcesAsync(Integer recordId) {
new LoadImageResourcesAsync(getActivity()).execute(recordId);
}
}
}
活动的布局如下。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/view_record_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view_record_fragment"
android:name="com.xxx.xxx.view.ViewRecordActivity$ViewRecordFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_view_record" />-->
</LinearLayout>
非常感谢您的帮助。
在布局中添加片段的基本方法如下所示。你必须提到片段的类名。
<fragment android:name="com.example.android.fragments.HeadlinesFragment"
android:id="@+id/headlines_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
我在尝试运行我的应用程序时收到了以下错误:无法启动活动ComponentInfo-二进制XML文件行#8:错误inflating类 以下是logcat消息: 下面是活动代码 匹配选项XML 非常感谢您的帮助。谢谢
试图进入一个整合了谷歌地图的新活动,我从标题中得到了一个错误。上述活动课: 以及相应的XML文件 这也是货单 我在这里处理什么?
我遇到了这个错误,你能帮我一下吗。 主要活动。Java语言 XML文件 LogCat输出 我真的不知道会发生什么,我可以构建项目,但当我在手机或模拟器上运行应用程序时,我得到了这个!如果有人知道解决方案,那就太棒了!
我有两天的时间研究这个问题,并尝试了所有的解决方案,但没有任何效果。以下是我的代码: LogCat: 以下是我的主要活动。Java语言 程序包com。我mystatus; 活动_Main。xml 显示xml: 请帮忙。
问题内容: 在添加异步任务之前,我已经对代码进行了一些更改,我的应用程序可以正常运行其远程服务器上的身份验证用户名和密码,但是在登录成功消息消失后无法启动其他活动。有人建议我现在添加一个异步任务,但是我输入正确的用户名和密码后它将停止工作。当我输入错误的用户名和密码时,其工作正常将显示错误的用户名密码消息。如果有人能够知道会出现什么错误,请帮助我。 码- 日志猫 QuestionnActivi