我有一个非常奇怪的问题。当我从eclipse运行应用程序时,一切似乎都很好。但是,一旦在设备上安装了apk,单击该图标将返回一条消息“未安装应用程序”。我收到了以下Logcat读数:
08-07 08:06:43.183: E/Launcher(502): Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dsi.ant.HCAApplication/.WelcomeActivity }. Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity. tag=ApplicationInfo(title=Health Creation Australia) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dsi.ant.HCAApplication/.WelcomeActivity }
08-07 08:06:43.183: E/Launcher(502): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dsi.ant.HCAApplication/.WelcomeActivity } from ProcessRecord{4203f5b0 502:com.android.launcher/u0a13} (pid=502, uid=10013) requires android.permission.ACCESS_NETWORK_STATE
08-07 08:06:43.183: E/Launcher(502): at android.os.Parcel.readException(Parcel.java:1425)
08-07 08:06:43.183: E/Launcher(502): at android.os.Parcel.readException(Parcel.java:1379)
08-07 08:06:43.183: E/Launcher(502): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1761)
08-07 08:06:43.183: E/Launcher(502): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1411)
08-07 08:06:43.183: E/Launcher(502): at android.app.Activity.startActivityForResult(Activity.java:3351)
08-07 08:06:43.183: E/Launcher(502): at android.app.Activity.startActivity(Activity.java:3518)
08-07 08:06:43.183: E/Launcher(502): at com.android.launcher2.Launcher.startActivity(Launcher.java:1952)
08-07 08:06:43.183: E/Launcher(502): at com.android.launcher2.Launcher.startActivitySafely(Launcher.java:1970)
08-07 08:06:43.183: E/Launcher(502): at com.android.launcher2.AppsCustomizePagedView.onClick(AppsCustomizePagedView.java:597)
08-07 08:06:43.183: E/Launcher(502): at android.view.View.performClick(View.java:4088)
08-07 08:06:43.183: E/Launcher(502): at android.view.View$PerformClick.run(View.java:16984)
08-07 08:06:43.183: E/Launcher(502): at android.os.Handler.handleCallback(Handler.java:615)
08-07 08:06:43.183: E/Launcher(502): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 08:06:43.183: E/Launcher(502): at android.os.Looper.loop(Looper.java:137)
08-07 08:06:43.183: E/Launcher(502): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-07 08:06:43.183: E/Launcher(502): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 08:06:43.183: E/Launcher(502): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 08:06:43.183: E/Launcher(502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-07 08:06:43.183: E/Launcher(502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 08:06:43.183: E/Launcher(502): at dalvik.system.NativeStart.main(Native Method)
由此我认为这是一个权限问题,但我相信我拥有所有正确的权限集:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="020400"
android:versionName="2.4.1"
package="com.dsi.ant.HCAApplication">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="false"
/>
<uses-permission android:name="com.dsi.ant.permission.ANT" />
<uses-permission android:name="com.dsi.ant.permission.ANT_ADMIN" /><application android:label="@string/app_name" android:icon="@drawable/hca_logo" android:permission="android.permission.ACCESS_NETWORK_STATE">
<activity android:label="@string/app_name" android:name="com.dsi.ant.HCAApplication.TakeMeasurements" android:launchMode="singleTask" android:screenOrientation="sensorLandscape">
</activity>
<service android:name="com.dsi.ant.HCAApplication.ANTPlusService" android:label="@string/app_name" android:exported="false" />
<activity android:name="com.dsi.ant.HCAApplication.FairwellActivity" android:label="Fairwell" android:screenOrientation="sensorLandscape"></activity>
<activity android:name="com.dsi.ant.HCAApplication.ScreenSaver" android:label="Health Creation Australia" android:screenOrientation="sensorLandscape"></activity>
<activity android:name="com.dsi.ant.HCAApplication.WelcomeActivity" android:label="@string/app_name" android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
如果你能以任何方式帮助我,我会非常感激,因为我不知所措。
答案 0 :(得分:1)
从应用程序代码中删除此行
<application
android:permission="android.permission.ACCESS_NETWORK_STATE">
</application>
答案 1 :(得分:0)
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
</application>
答案 2 :(得分:0)
只需使用以下
替换您的清单代码即可<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dsi.ant.HCAApplication"
android:versionCode="020400"
android:versionName="2.4.1" >
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.dsi.ant.permission.ANT" />
<uses-permission android:name="com.dsi.ant.permission.ANT_ADMIN" />
<application
android:label="@string/app_name"
android:permission="android.permission.ACCESS_NETWORK_STATE" >
<activity
android:name="com.dsi.ant.HCAApplication.TakeMeasurements"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="sensorLandscape" >
</activity>
<service
android:name="com.dsi.ant.HCAApplication.ANTPlusService"
android:exported="false"
android:label="@string/app_name" />
<activity
android:name="com.dsi.ant.HCAApplication.FairwellActivity"
android:label="Fairwell"
android:screenOrientation="sensorLandscape" >
</activity>
<activity
android:name="com.dsi.ant.HCAApplication.ScreenSaver"
android:label="Health Creation Australia"
android:screenOrientation="sensorLandscape" >
</activity>
<activity
android:name="com.dsi.ant.HCAApplication.WelcomeActivity"
android:label="@string/app_name"
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
希望它会对你有所帮助。
答案 3 :(得分:0)
在清单中查找导出标记的这一行并使其成为
android:exported =“ true”