我正在尝试在我的Android手机上安装应用程序。它说这是成功的,但我没有在手机上看到它。 这是我的xml清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adr"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<receiver android:name=".AdrBroadcastReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.adr.intent.action.SERVICE">
</action>
</intent-filter>
</receiver>
<service android:name=".Adr">
<intent-filter>
<action android:name="com.adr.intent.action.SERVICE">
</action>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>>
</service>
</application>
</manifest>
编辑代码:现在我从logcat收到错误。应用程序显示但是一旦我点击它就说不幸的是,adr已经停止了。我现在在logcat中收到了很多东西。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adr"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name=".YourActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name=".AdrBroadcastReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.adr.intent.action.SERVICE">
</action>
</intent-filter>
</receiver>
<service android:name=".Adr">
<intent-filter>
<action android:name="com.adr.intent.action.SERVICE">
</action>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>>
</service>
</application>
</manifest>
这是我在logcat中得到的 -
06-27 16:38:45.814: D/AndroidRuntime(5324): Shutting down VM
06-27 16:38:45.814: W/dalvikvm(5324): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-27 16:38:45.864: E/AndroidRuntime(5324): FATAL EXCEPTION: main
06-27 16:38:45.864: E/AndroidRuntime(5324): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.adr/com.adr.YourActivity}: java.lang.ClassNotFoundException: Didn't find class "com.adr.YourActivity" on path: /data/app/com.adr-1.apk
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.os.Looper.loop(Looper.java:137)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-27 16:38:45.864: E/AndroidRuntime(5324): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 16:38:45.864: E/AndroidRuntime(5324): at java.lang.reflect.Method.invoke(Method.java:511)
06-27 16:38:45.864: E/AndroidRuntime(5324): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-27 16:38:45.864: E/AndroidRuntime(5324): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-27 16:38:45.864: E/AndroidRuntime(5324): at dalvik.system.NativeStart.main(Native Method)
06-27 16:38:45.864: E/AndroidRuntime(5324): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.adr.YourActivity" on path: /data/app/com.adr-1.apk
06-27 16:38:45.864: E/AndroidRuntime(5324): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-27 16:38:45.864: E/AndroidRuntime(5324): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-27 16:38:45.864: E/AndroidRuntime(5324): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-27 16:38:45.864: E/AndroidRuntime(5324): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-27 16:38:45.864: E/AndroidRuntime(5324): ... 11 more
答案 0 :(得分:1)
你的意思是你的应用程序没有显示在应用程序菜单中?这是因为应用程序中没有活动,只有接收者和服务。宣布MAIN和LAUNCHER服务无济于事。
答案 1 :(得分:0)
<activity android:name=".YourActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
在应用程序之后声明此活动,您没有声明任何活动,这就是为什么没有显示图标。确保将您的应用名称,应用图标添加到上面的活动中。
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme" >
<activity
android:name="com.style.me.Smaller"
android:largeHeap="true"
android:configChanges="locale|orientation|keyboard|screenSize|keyboardHidden"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>