这是我的错误:
12-03 20:25:30.767 19809-19809/com.app.test E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.app.test, PID: 19809
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1878)
at com.app.test.CameraManager.TakePicture(CameraManager.java:107)
at com.app.test.DesignerFragment.CameraAction(DesignerFragment.java:808)
at com.app.test.MainActivity.CameraAction(MainActivity.java:1031)
at com.app.test.MainActivity$3.onClick(MainActivity.java:297)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.test"
android:versionCode="43"
android:versionName="3.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- <uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
-->
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<!--<uses-feature android:name="android.hardware.camera.front" android:required="false" />-->
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.location" />
<uses-feature android:name="android.hardware.camera.setParameters" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal"/>
<uses-feature android:name="android.hardware.camera.flash"/>
<!--
IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission
android:name="com.app.test.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.app.test.permission.C2D_MESSAGE" />
<application
android:name="com.app.application.GlobalApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_ENABLED"
android:value="true" />
<!-- Google Analytics Version v4 needs this value for easy tracking -->
<!--
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
-->
<!--
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
-->
<activity
android:name="com.parse.ui.ParseLoginActivity"
android:label="@string/app_name"
android:launchMode="singleTop" >
<meta-data
android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_ENABLED"
android:value="true" />
<!-- <meta-data -->
<!-- android:name="com.parse.ui.ParseLoginActivity.PARSE_LOGIN_EMAIL_AS_USERNAME" -->
<!-- android:value="true"/> -->
<meta-data
android:name="com.parse.ui.ParseLoginActivity.FACEBOOK_LOGIN_ENABLED"
android:value="true" />
<meta-data
android:name="com.parse.ui.ParseLoginActivity.TWITTER_LOGIN_ENABLED"
android:value="true" />
</activity>
<!-- <activity -->
<!-- android:name="com.app.test.MainActivity" -->
<!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
<!-- android:label="@string/app_name" -->
<!-- android:screenOrientation="portrait" > -->
<!-- </activity> -->
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="@string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="@string/parse_client_key" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.app.test.notification_icon"
android:resource="@drawable/ic_launcher" />
<activity
android:name=".DispatchActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".IntroActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".UserSettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/PreferenceScreen" >
</activity>
<activity
android:name=".EditProfileActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName=".EditProfileActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".ChangePasswordActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName=".ChangePasswordActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".PaymentDetailsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName=".PaymentDetailsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<activity
android:name=".PurchaseActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.app.gallery.GalleryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.app.feed.FeedActivityV2"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.app.feed.SearchActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName="com.app.feed.FeedActivityV2"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.app.feed.SuggestedUserActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName="com.app.feed.FeedActivityV2"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.app.comments.CommentsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName="com.app.feed.FeedActivityV2"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.app.notifications.NotificationsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:parentActivityName="com.app.feed.FeedActivityV2"
android:screenOrientation="portrait" >
</activity>
<service
android:name="com.paypal.android.sdk.payments.PayPalService"
android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
<activity android:name="com.paypal.android.sdk.payments.PayPalProfileSharingActivity" />
<activity android:name="com.paypal.android.sdk.payments.ProfileSharingConsentActivity" />
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<provider
android:name="com.app.utility.ContentProvider"
android:authorities="com.app"
android:enabled="true"
android:exported="true" >
</provider>
<activity
android:name=".PaymentProcessingActivity"
android:label="@string/title_activity_payment_processing" >
</activity>
<activity
android:name="com.app.utility.WrapperWeb"
android:label="@string/title_activity_wrapper_web" >
</activity>
<service android:name="com.parse.PushService" />
<!-- Custom Receiver -->
<receiver
android:name=".Receiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<!-- End Custom Receiver -->
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!-- IMPORTANT: Change "com.parse.tutorials.pushnotifications" to match your app's package name. -->
<category android:name="com.app.test" />
</intent-filter>
</receiver>
<!-- replace @drawable/push_icon with your push icon identifier -->
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />
<activity
android:name="com.app.feed.FeedActivitySingle"
android:label="@string/title_activity_feed_activity_single"
android:parentActivityName="com.app.gallery.GalleryActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.app.gallery.GalleryActivity" />
</activity>
</application>
</manifest>
我一直在讨厌为什么这不起作用。每次启动时,前置摄像头都会关闭应用程序。怎么可能出错?我的清单出了什么问题?
答案 0 :(得分:1)
您可以发布启动相机的代码吗? 我现在能看到的是你声明了一个不存在的权限:
<uses-permission android:name="android.hardware.camera.autofocus" />
有一些功能声明有拼写错误:
<used-feature android:name="android.hardware.location" />
<used-feature android:name="android.hardware.camera.setParameters" />
你可以尝试修复它们,看看它是否有帮助。您可以看到可用于声明here
的所有功能的列表答案 1 :(得分:0)
我确保根据要求将所有权限设置为false:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera.setParameters" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-permission android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal"/>
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
我还修正了k3v1n3ud3上面建议的一些拼写错误。