2014-09-23 176 views
0

我是Android新手。我正在使用android studio並連接到設備,4.04,api 14.我創建了一個默認的登錄活動。它拋出了以下異常:Android異常:啓動登錄活動時的運行時異常

Launching application: com.noatta.www.noatta_14/com.noatta.www.noatta_14.LoginActivity. 
DEVICE SHELL COMMAND: am start -n "com.noatta.www.noatta_14/com.noatta.www.noatta_14.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.noatta.www.noatta_14/.LoginActivity } 
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.noatta.www.noatta_14/.LoginActivity } from null (pid=16079, uid=2000) not exported from uid 10127 
at android.os.Parcel.readException(Parcel.java:1332) 
at android.os.Parcel.readException(Parcel.java:1286) 
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1691) 
at com.android.commands.am.Am.runStart(Am.java:451) 
at com.android.commands.am.Am.run(Am.java:107) 
at com.android.commands.am.Am.main(Am.java:80) 
at com.android.internal.os.RuntimeInit.finishInit(Native Method) 
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:260) 
at dalvik.system.NativeStart.main(Native Method) 

清單文件

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.noatta.www.noatta_14" > 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".LoginActivity" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="adjustResize|stateHidden" > 
     </activity> 

     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
    </application> 
    <!-- To access Google+ APIs: --> 
    <uses-permission android:name="android.permission.INTERNET" /> 

    <!-- 
    To retrieve OAuth 2.0 tokens or invalidate tokens to disconnect a user. This disconnect 
    option is required to comply with the Google+ Sign-In developer policies 
    --> 
    <uses-permission android:name="android.permission.USE_CREDENTIALS" /> 

    <!-- To retrieve the account name (email) as part of sign-in: --> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 

    <!-- To auto-complete the email text field in the login form with the user's emails --> 
    <uses-permission android:name="android.permission.READ_PROFILE" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 

</manifest> 

任何人有關於如何防止讀取異常的建議嗎?

回答

2

你缺少意向過濾器和異常狀態您在AndroidManifest.xml中

<activity 
     android:name=".LoginActivity" 
     android:label="@string/app_name" 
     android:windowSoftInputMode="adjustResize|stateHidden" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
失蹤的 android:exported="true"
3

你在活動定義缺失<intent-filter>

<activity 
    android:name=".LoginActivity" 
    android:label="@string/app_name" 
    android:windowSoftInputMode="adjustResize|stateHidden" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity>