深度链接错误android

时间:2014-03-20 11:34:12

标签: android runtime-error deep-linking

我正在尝试构建一个手电筒应用程序但是当我试图运行它时,应用程序停止并给了我这个错误:

 03-20 12:18:39.590      437-455/system_process I/PackageManager﹕ Removing non-system package:com.example.flashlight
03-20 12:18:39.840      437-455/system_process I/PackageManager﹕ Running dexopt on: com.example.flashlight
03-20 12:18:46.340  24099-24099/com.example.flashlight E/Trace﹕ error opening trace file: No such file or directory (2)
03-20 12:18:46.360  24099-24099/com.example.flashlight W/dalvikvm﹕ Refusing to reopen boot DEX '/system/framework/hwframework.jar'
03-20 12:18:46.760  24099-24099/com.example.flashlight W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41d7e438)

这是我的代码:

public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Camera cam = android.hardware.Camera.open();
        Camera.Parameters parameters = cam.getParameters();
       ToggleButton toggleButton = (ToggleButton)findViewById(R.id.toggleButton);
        try {
            if (toggleButton.isChecked()){
                parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
            } else {
                parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
            }
        } catch (Exception e){
            e.printStackTrace();
        }

我的main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <ToggleButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New ToggleButton"
            android:id="@+id/toggleButton" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/>
</RelativeLayout>

和我的manifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.flashlight"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-sdk android:targetSdkVersion="16"
            android:minSdkVersion="9"/>

    <uses-permission android:name="android.permission.FLASHLIGHT"/>

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <activity android:name="MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

据我所知,深层链接错误与互联网有关,但我在应用程序中没有这样的东西。 请帮忙,因为我无法弄清楚这段代码有什么问题。

1 个答案:

答案 0 :(得分:1)

您没有添加使用camera.添加权限的权限,然后重试。

添加这些

<uses-permission android:name="android.permission.CAMERA" />
 <uses-feature android:name="android.hardware.camera" />
 <uses-feature android:name="android.hardware.camera.autofocus" />

供参考,请参阅此处:http://developer.android.com/reference/android/hardware/Camera.html