运行持续存在的问题的Android应用 [英] Continuing problems running Android Apps
本文介绍了运行持续存在的问题的Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直有一个非常困难的时期与Android应用程序。我使用的Eclipse,V 4.2.0,运行API版本7.下面是一个程序,我有困难的LogCat中输出。这是我的code:
清单
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.deadEddie.counter
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途-SDK
安卓的minSdkVersion =7
机器人:targetSdkVersion =15/>
<应用
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名称=。MainActivity
机器人:标签=@字符串/ title_activity_main>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
< /舱单>
布局(activity_main.xml)
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:后台=#000000>
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:文字颜色=@字符串/彩色
机器人:TEXTSIZE =30dp
机器人:文本=@字符串/文本
机器人:TEXTSTYLE =黑体
机器人:重力=中心
机器人:ID =@ + ID / tvDisplay
/>
<按钮
机器人:ID =@ + ID / btnAdd
机器人:layout_width =250dp
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ btn1Title
机器人:layout_gravity =中心
/>
<按钮
机器人:ID =@ + ID / btnSubtract
机器人:layout_width =250dp
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ btn2Title
机器人:layout_gravity =中心
/>
< / LinearLayout中>
MainActivity.java
包com.deadEddie.counter;
进口android.os.Bundle;
进口android.app.Activity;
进口android.view.View;
进口android.widget.Button;
进口android.widget.TextView;
公共类MainActivity扩展活动
{
INT计数器;
按钮添加;
扣减;
TextView的显示;
@覆盖
公共无效的onCreate(包savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
计数器= 0;
添加=(按钮)findViewById(R.id.btnAdd);
减=(按钮)findViewById(R.id.btnSubtract);
显示器=(TextView中)findViewById(R.id.tvDisplay);
add.setOnClickListener(新View.OnClickListener()
{
@覆盖
公共无效的onClick(视图v)
{
// TODO自动生成方法存根
反++;
display.setText(计数器=+计数器);
}
});
subtract.setOnClickListener(新View.OnClickListener()
{
@覆盖
公共无效的onClick(视图v)
{
// TODO自动生成方法存根
计数器 - ;
display.setText(计数器=+计数器);
}
});
}
}
LogCat中输出:
08-06 13:23:37.538:E /进程vold(26):错误打开开关名称路径/ SYS /班/开关/测试(没有这样的文件或目录)
08-06 13:23:37.538:E /进程vold(26):错误引导开关/ SYS /班/开关/测试(没有这样的文件或目录)
08-06 13:23:37.538:E /进程vold(26):错误打开开关名称路径/ SYS /班/开关/测试2'(没有这样的文件或目录)
08-06 13:23:37.538:E /进程vold(26):错误引导开关/ SYS /班/开关/测试2'(没有这样的文件或目录)
08-06 13:23:46.518:E / BatteryService(51):usbOnlinePath未找到
08-06 13:23:46.518:E / BatteryService(51):batteryVoltagePath未找到
08-06 13:23:46.518:E / BatteryService(51):batteryTemperaturePath未找到
08-06 13:23:46.528:E / SurfaceFlinger(51):无法打开/ SYS /电源/ wait_for_fb_sleep或/ SYS /电源/ wait_for_fb_wake
08-06 13:23:49.848:E / EventHub(51):无法获取驱动程序版本的/ dev /输入/ mouse0,而不是一台打字机
08-06 13:23:49.848:E / EventHub(51):无法获取驱动程序版本的/ dev /输入/小鼠,而不是一台打字机
08-06 13:23:50.638:E /系统(51):未能启动核心服务
08-06 13:23:50.638:E /系统(51):java.lang.SecurityException异常
08-06 13:23:50.638:E /系统(51):在android.os.BinderProxy.transact(本机方法)
08-06 13:23:50.638:E /系统(51):在android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
08-06 13:23:50.638:E /系统(51):在android.os.ServiceManager.addService(ServiceManager.java:72)
08-06 13:23:50.638:E /系统(51):在com.android.server.ServerThread.run(SystemServer.java:176)
08-06 13:23:50.638:E / AndroidRuntime(51):崩溃日志跳过,没有登记服务
08-06 13:23:56.035:E / ActivityThread(95):未能找到android.server.checkin供应商信息
08-06 13:23:56.774:E / ActivityThread(95):未能找到android.server.checkin供应商信息
08-06 13:23:56.844:E / ActivityThread(95):未能找到android.server.checkin供应商信息
08-06 13:23:58.464:E /进程vold(26):无法启动volume/ SD卡(卷不绑定)
08-06 13:23:58.604:E / MediaPlayerService(30):无法打开FD内容://设置/系统/ notification_sound
08-06 13:23:58.614:E / MediaPlayer的(51):无法创建媒体播放器
08-06 13:24:03.963:E / AndroidRuntime(192):错误:线程附加失败
08-06 13:24:05.833:E / AndroidRuntime(203):错误:线程附加失败
08-06 13:24:06.043:E / JDWP(216):无法发送REQ到调试器:断管(27 -1)
08-06 13:24:06.043:E / JDWP(216):无法发送REQ到调试器:断管(27 -1)
08-06 13:24:06.043:E / JDWP(216):无法发送回复调试器:管道中断
08-06 13:24:06.115:E / AndroidRuntime(216):未捕获的处理程序:由于未捕获的异常螺纹主力退出
08-06 13:24:06.133:E / AndroidRuntime(216):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.deadEddie.counter / com.deadEddie.counter.MainActivity}:android.view.InflateException:二进制XML文件行#7:错误充气类<未知>
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread.access $ 2200(ActivityThread.java:119)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1863)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.os.Handler.dispatchMessage(Handler.java:99)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.os.Looper.loop(Looper.java:123)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread.main(ActivityThread.java:4363)
08-06 13:24:06.133:E / AndroidRuntime(216):在java.lang.reflect.Method.invokeNative(本机方法)
08-06 13:24:06.133:E / AndroidRuntime(216):在java.lang.reflect.Method.invoke(Method.java:521)
08-06 13:24:06.133:E / AndroidRuntime(216):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860)
08-06 13:24:06.133:E / AndroidRuntime(216):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-06 13:24:06.133:E / AndroidRuntime(216):在dalvik.system.NativeStart.main(本机方法)
08-06 13:24:06.133:E / AndroidRuntime(216):android.view.InflateException:二进制XML文件中的行#7:产生的原因错误充气类<未知>
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.createView(LayoutInflater.java:513)
08-06 13:24:06.133:E / AndroidRuntime(216):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-06 13:24:06.133:E / AndroidRuntime(216):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.Activity.setContentView(Activity.java:1622)
08-06 13:24:06.133:E / AndroidRuntime(216):在com.deadEddie.counter.MainActivity.onCreate(MainActivity.java:20)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-06 13:24:06.133:E / AndroidRuntime(216):11 ...更多
08-06 13:24:06.133:E / AndroidRuntime(216):由:java.lang.reflect.InvocationTargetException
08-06 13:24:06.133:E / AndroidRuntime(216):在android.widget.TextView< INIT>(TextView.java:320)
08-06 13:24:06.133:E / AndroidRuntime(216):在java.lang.reflect.Constructor.constructNative(本机方法)
08-06 13:24:06.133:E / AndroidRuntime(216):在java.lang.reflect.Constructor.newInstance(Constructor.java:446)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.view.LayoutInflater.createView(LayoutInflater.java:500)
08-06 13:24:06.133:E / AndroidRuntime(216):22 ...更多
08-06 13:24:06.133:E / AndroidRuntime(216):由:android.content.res.Resources $ NotFoundException:从绘制资源ID#0x7f040006文件#CCFF00:需要.xml扩展
08-06 13:24:06.133:E / AndroidRuntime(216):在android.content.res.Resources.loadColorStateList(Resources.java:1820)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.content.res.TypedArray.getColorStateList(TypedArray.java:289)
08-06 13:24:06.133:E / AndroidRuntime(216):在android.widget.TextView< INIT>(TextView.java:627)
08-06 13:24:06.133:E / AndroidRuntime(216):26 ...更多
08-06 13:24:06.173:E / dalvikvm(216):无法打开堆栈跟踪文件/data/anr/traces.txt':权限被拒绝
08-06 13:29:06.424:E / gralloc(51):[注销]处理0x52d470仍处于锁定状态(状态= 40000001)
解决方案
我想你需要将你的颜色声明出来的strings.xml,并把它colors.xml内
colors.xml
< XML版本=1.0编码=UTF-8&GT?;
<资源>
<颜色名称=myColor>#ccff00< /彩色>
< /资源>
然后在你的布局是指它是这样的:
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =中心
机器人:文字颜色=@色/ myColor
机器人:TEXTSIZE =30dp
机器人:文本=@字符串/文本
机器人:TEXTSTYLE =黑体
机器人:重力=中心
机器人:ID =@ + ID / tvDisplay
/>
I have been having a very difficult time with android apps. I'm using Eclipse, V 4.2.0, and running API version 7. Below is the LogCat output of one program I'm having difficulties. This is my code:
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deadEddie.counter"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
layout (activity_main.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@string/color"
android:textSize="30dp"
android:text="@string/text"
android:textStyle="bold"
android:gravity="center"
android:id="@+id/tvDisplay"
/>
<Button
android:id="@+id/btnAdd"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/btn1Title"
android:layout_gravity="center"
/>
<Button
android:id="@+id/btnSubtract"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/btn2Title"
android:layout_gravity="center"
/>
</LinearLayout>
MainActivity.java
package com.deadEddie.counter;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity
{
int counter;
Button add;
Button subtract;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
counter = 0;
add = (Button) findViewById(R.id.btnAdd);
subtract = (Button) findViewById(R.id.btnSubtract);
display = (TextView) findViewById(R.id.tvDisplay);
add.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
counter ++;
display.setText("Counter = " + counter);
}
});
subtract.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
counter --;
display.setText("Counter = "+ counter);
}
});
}
}
LogCat output:
08-06 13:23:37.538: E/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory)
08-06 13:23:37.538: E/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory)
08-06 13:23:37.538: E/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory)
08-06 13:23:37.538: E/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory)
08-06 13:23:46.518: E/BatteryService(51): usbOnlinePath not found
08-06 13:23:46.518: E/BatteryService(51): batteryVoltagePath not found
08-06 13:23:46.518: E/BatteryService(51): batteryTemperaturePath not found
08-06 13:23:46.528: E/SurfaceFlinger(51): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
08-06 13:23:49.848: E/EventHub(51): could not get driver version for /dev/input/mouse0, Not a typewriter
08-06 13:23:49.848: E/EventHub(51): could not get driver version for /dev/input/mice, Not a typewriter
08-06 13:23:50.638: E/System(51): Failure starting core service
08-06 13:23:50.638: E/System(51): java.lang.SecurityException
08-06 13:23:50.638: E/System(51): at android.os.BinderProxy.transact(Native Method)
08-06 13:23:50.638: E/System(51): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
08-06 13:23:50.638: E/System(51): at android.os.ServiceManager.addService(ServiceManager.java:72)
08-06 13:23:50.638: E/System(51): at com.android.server.ServerThread.run(SystemServer.java:176)
08-06 13:23:50.638: E/AndroidRuntime(51): Crash logging skipped, no checkin service
08-06 13:23:56.035: E/ActivityThread(95): Failed to find provider info for android.server.checkin
08-06 13:23:56.774: E/ActivityThread(95): Failed to find provider info for android.server.checkin
08-06 13:23:56.844: E/ActivityThread(95): Failed to find provider info for android.server.checkin
08-06 13:23:58.464: E/vold(26): Cannot start volume '/sdcard' (volume is not bound)
08-06 13:23:58.604: E/MediaPlayerService(30): Couldn't open fd for content://settings/system/notification_sound
08-06 13:23:58.614: E/MediaPlayer(51): Unable to to create media player
08-06 13:24:03.963: E/AndroidRuntime(192): ERROR: thread attach failed
08-06 13:24:05.833: E/AndroidRuntime(203): ERROR: thread attach failed
08-06 13:24:06.043: E/jdwp(216): Failed sending req to debugger: Broken pipe (-1 of 27)
08-06 13:24:06.043: E/jdwp(216): Failed sending req to debugger: Broken pipe (-1 of 27)
08-06 13:24:06.043: E/jdwp(216): Failed sending reply to debugger: Broken pipe
08-06 13:24:06.115: E/AndroidRuntime(216): Uncaught handler: thread main exiting due to uncaught exception
08-06 13:24:06.133: E/AndroidRuntime(216): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.deadEddie.counter/com.deadEddie.counter.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.os.Looper.loop(Looper.java:123)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread.main(ActivityThread.java:4363)
08-06 13:24:06.133: E/AndroidRuntime(216): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 13:24:06.133: E/AndroidRuntime(216): at java.lang.reflect.Method.invoke(Method.java:521)
08-06 13:24:06.133: E/AndroidRuntime(216): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-06 13:24:06.133: E/AndroidRuntime(216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-06 13:24:06.133: E/AndroidRuntime(216): at dalvik.system.NativeStart.main(Native Method)
08-06 13:24:06.133: E/AndroidRuntime(216): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
08-06 13:24:06.133: E/AndroidRuntime(216): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-06 13:24:06.133: E/AndroidRuntime(216): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.Activity.setContentView(Activity.java:1622)
08-06 13:24:06.133: E/AndroidRuntime(216): at com.deadEddie.counter.MainActivity.onCreate(MainActivity.java:20)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-06 13:24:06.133: E/AndroidRuntime(216): ... 11 more
08-06 13:24:06.133: E/AndroidRuntime(216): Caused by: java.lang.reflect.InvocationTargetException
08-06 13:24:06.133: E/AndroidRuntime(216): at android.widget.TextView.<init>(TextView.java:320)
08-06 13:24:06.133: E/AndroidRuntime(216): at java.lang.reflect.Constructor.constructNative(Native Method)
08-06 13:24:06.133: E/AndroidRuntime(216): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
08-06 13:24:06.133: E/AndroidRuntime(216): ... 22 more
08-06 13:24:06.133: E/AndroidRuntime(216): Caused by: android.content.res.Resources$NotFoundException: File #CCFF00 from drawable resource ID #0x7f040006: .xml extension required
08-06 13:24:06.133: E/AndroidRuntime(216): at android.content.res.Resources.loadColorStateList(Resources.java:1820)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.content.res.TypedArray.getColorStateList(TypedArray.java:289)
08-06 13:24:06.133: E/AndroidRuntime(216): at android.widget.TextView.<init>(TextView.java:627)
08-06 13:24:06.133: E/AndroidRuntime(216): ... 26 more
08-06 13:24:06.173: E/dalvikvm(216): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
08-06 13:29:06.424: E/gralloc(51): [unregister] handle 0x52d470 still locked (state=40000001)
解决方案
I think you need to move your color declaration out of strings.xml and put it inside of colors.xml
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="myColor">#ccff00</color>
</resources>
Then inside your layout refer to it like this:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/myColor"
android:textSize="30dp"
android:text="@string/text"
android:textStyle="bold"
android:gravity="center"
android:id="@+id/tvDisplay"
/>
这篇关于运行持续存在的问题的Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文