大家好你能帮我解决这个问题,我不知道为什么问题是actionbar,我试图从eclipse导入这个项目,所以很难解决这么多项目的麻烦,我试着删除库v4支持,但它不起作用
问题android.view.InflateException
简短代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.depan);
SharedPreferences settings = getSharedPreferences(
LoginActivity.PREFS_NAME, 0);
String userName = settings.getString("user_name", "");
TextView vw = (TextView) findViewById(R.id.tvName);
vw.setText(userName);
TextView tvcopyright = (TextView) findViewById(R.id.depan_copyright);
tvcopyright.setMovementMethod(LinkMovementMethod.getInstance());
targetUrl = Config.getEndPointUrl();
ctx = this.getApplicationContext();
final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
// actionBar.setHomeAction(new IntentAction(this, createIntent(this),
// R.drawable.ic_title_home_demo));
actionBar.setTitle(R.string.app_name);
LinearLayout lyUpdate = (LinearLayout) findViewById(R.id.mainLayoutUpdate);
if (!AppInfo.needupdate) {
lyUpdate.setVisibility(View.GONE);
} else {
Button btnUpdate = (Button) findViewById(R.id.btnUpdateApp);
btnUpdate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
String url = targetUrl + "/getapp.json?userid="
+ UserInfo.username;
// url =
// "http://10.0.2.2/nestleconfect/data/user/NestleConfectMobile.apk";
// String type =
// "application/vnd.android.package-archive";
Log.i("ncdebug", "update: " + url);
Update(url);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(ctx, e.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
public void Update(String apkurl) {
try {
URL url = new URL(apkurl);
HttpURLConnection c = (HttpURLConnection) url
.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
String PATH = Environment.getExternalStorageDirectory()
+ "/download/";
File file = new File(PATH);
file.mkdirs();
File outputFile = new File(file, "app.apk");
FileOutputStream fos = new FileOutputStream(outputFile);
InputStream is = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
}
fos.close();
is.close();
Intent promptInstall = new Intent(Intent.ACTION_VIEW);
promptInstall.setDataAndType(Uri.fromFile(new File(
Environment.getExternalStorageDirectory()
+ "/download/app.apk")),
"application/vnd.android.package-archive");
startActivity(promptInstall);
} catch (IOException e) {
Toast.makeText(getApplicationContext(),
"Update error! " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
});
}
// db update
LinearLayout lyDbUpdate = (LinearLayout) findViewById(R.id.mainLayoutDbUpdate);
if (!AppInfo.dbNeedUpdate) {
lyDbUpdate.setVisibility(View.GONE);
} else {
Button btnDbUpdate = (Button) findViewById(R.id.btnDbUpdateApp);
btnDbUpdate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(ctx, DbUpdateActivity.class);
startActivity(intent);
finish();
}
});
}
Intent intent = new Intent(this, PeriodicTaskService.class);
View view = findViewById(R.id.message_btn);
AppInfo.contextmain = ctx;
AppInfo.messagebtn = view;
startService(intent);
String currentDateString = new SimpleDateFormat("yyyy-M-d")
.format(new Date());
AppInfo.date = currentDateString;
Log.i("ncdebug", "userid(main): " + UserInfo.username + ",name="
+ UserInfo.name);
}
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar" />
<LinearLayout
android:id="@+id/mainLayoutUpdate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#efefef"
android:orientation="vertical"
android:paddingBottom="3dip"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:paddingTop="3dip" >
<Button
android:id="@+id/btnUpdateApp"
style="@style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_blue"
android:clickable="true"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="Update Ke Versi Terbaru"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
这是日志:
stack=java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inarts.mobile.merch.md/com.inarts.mobile.merch.md.MainActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.markupartist.android.widget.ActionBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.markupartist.android.widget.ActionBar
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2166)
at com.inarts.mobile.merch.md.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.markupartist.android.widget.ActionBar
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
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.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2166)
at com.inarts.mobile.merch.md.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
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.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2166)
at com.inarts.mobile.merch.md.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/markupartist/android/widget/actionbar/R$layout;
at com.markupartist.android.widget.ActionBar.<init>(ActionBar.java:57)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
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.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2166)
at com.inarts.mobile.merch.md.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.markupartist.android.widget.actionbar.R$layout" on path: DexPathList[[dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-support-annotations-24.2.0_172ab3f548c6de548a79bebb7324b06edd4ccef2-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.inarts.mobile.merch.md/files/instant-run/dex/slice-maps_b9
08-25 06:14:39.749 9239-9239/com.inarts.mobile.merch.md D/Error: ERR: TOTAL BYTES WRITTEN: 61712
08-25 06:19:39.756 9239-9239/com.inarts.mobile.merch.md I/Process: Sending signal. PID: 9239 SIG: 9
答案 0 :(得分:0)
你如何和/或在哪里获得&#34; com.markupartist.android.widget.ActionBar&#34;的定义?
这看起来不像标准小部件,并且由于项目为您构建并在运行时崩溃,我的猜测是它没有被包含在您的项目中并与其一起部署。
尝试暂时切换回标准ActionBar,验证它是否正常工作,然后跳回到您正在使用的自定义ActionBar小部件。
添加ADB日志也可能有所帮助。