Code:
setContentView(R.layout.splashscreen);
Thread timer = new Thread() {
#Override
public void run() {
// TODO Auto-generated method stub
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
intent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com/"));
startActivity(intent);
}
}
};
timer.start();
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
this.finish();
}
}
As you guys can see, this a very simple program which will show a splash screen and then will open the url in the browser. Everything is fine up to here. Now by using the back button I exit from the app. But as soon as I try to press the installed app icon, the system gives me a toast saying "app is not installed on your phone".
When I check the running services, its always there and my logcat says: "Launcher does not have permission to launch the intent".
So my 1st question: Why my app is running all the time, although I have called the finish() in the onPause() method?
Q2. What this logcat message indicates?
Here is my manifest (guess you're thinking that I haven't added the uses-permission for internet but I had):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.xyz.main"
android:versionCode="1"
android:versionName="1.0.1" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name" android:permission="android.permission.INTERNET" android:description="#string/appdescription">
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is the logcat:
04-29 23:17:56.745: I/ActivityManager(68): Starting activity: Intent {act=android.intent.action.MAIN cat[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }
04-29 23:17:56.745: W/ActivityManager(68): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity } from ProcessRecord{45cfc0f8 240:com.android.launcher/10025} (pid=240, uid=10025) requires android.permission.INTERNET
04-29 23:17:56.785: E/Launcher(240): Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }. Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity. tag=ApplicationInfo(title=ePost) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity }
04-29 23:17:56.785: E/Launcher(240): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.vayyoo.epost.main/.SplashActivity } from ProcessRecord{45cfc0f8 240:com.android.launcher/10025} (pid=240, uid=10025) requires android.permission.INTERNET
04-29 23:17:56.785: E/Launcher(240): at android.os.Parcel.readException(Parcel.java:1247)
04-29 23:17:56.785: E/Launcher(240): at android.os.Parcel.readException(Parcel.java:1235)
04-29 23:17:56.785: E/Launcher(240): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
04-29 23:17:56.785: E/Launcher(240): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
04-29 23:17:56.785: E/Launcher(240): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.Launcher.startActivityForResult(Launcher.java:1053)
04-29 23:17:56.785: E/Launcher(240): at android.app.Activity.startActivity(Activity.java:2923)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.Launcher.startActivitySafely(Launcher.java:1462)
04-29 23:17:56.785: E/Launcher(240): at com.android.launcher2.AllApps2D.onItemClick(AllApps2D.java:178)
04-29 23:17:56.785: E/Launcher(240): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
04-29 23:17:56.785: E/Launcher(240): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
04-29 23:17:56.785: E/Launcher(240): at android.os.Handler.handleCallback(Handler.java:587)
04-29 23:17:56.785: E/Launcher(240): at android.os.Handler.dispatchMessage(Handler.java:92)
04-29 23:17:56.785: E/Launcher(240): at android.os.Looper.loop(Looper.java:123)
04-29 23:17:56.785: E/Launcher(240): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-29 23:17:56.785: E/Launcher(240): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 23:17:56.785: E/Launcher(240): at java.lang.reflect.Method.invoke(Method.java:521)
04-29 23:17:56.785: E/Launcher(240): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-29 23:17:56.785: E/Launcher(240): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-29 23:17:56.785: E/Launcher(240): at dalvik.system.NativeStart.main(Native Method)
04-29 23:17:59.855: W/KeyCharacterMap(240): No keyboard for id 0
04-29 23:17:59.855: W/KeyCharacterMap(240): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
If you are using Ice Cream Sandwich,(I remember reading this somewhere in SO) not only does the permission have to be in its own tag the application cannot have the attribute "android.permission.INTERNET" at the same time.. so just remove this from application node and try...
Try removing the:
android:permission="android.permission.INTERNET"
From this part:
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name" android:permission="android.permission.INTERNET" android:description="#string/appdescription">
But leave it in the other part of your manifest.
Related
my android app was running fine until I added some classes and edited the manifest file.
Now, when I try to run or debug the app on my android emulator with android 2.2, the app crashes and I get a ClassNotFoundException as follows:
D/AndroidRuntime( 275): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 275): CheckJNI is ON
D/AndroidRuntime( 275): --- registering native functions ---
I/ActivityManager( 59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=de.bastian.gpstracker/.MainActivity }
I/ActivityManager( 59): Start proc de.bastian.gpstracker for activity de.bastian.gpstracker/.MainActivity: pid=281 uid=10036 gids={}
D/AndroidRuntime( 275): Shutting down VM
D/jdwp ( 275): adbd disconnected
D/AndroidRuntime( 281): Shutting down VM
W/dalvikvm( 281): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 281): FATAL EXCEPTION: main
E/AndroidRuntime( 281): java.lang.RuntimeException: Unable to instantiate application de.bastian.gpstracker: java.lang.ClassNotFoundException: de.bastian.gpstracker in loader dalvik.system.PathClassLoader[/data/app/de.bastian.gpstracker-1.apk]
E/AndroidRuntime( 281): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
E/AndroidRuntime( 281): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
E/AndroidRuntime( 281): at android.app.ActivityThread.access$3000(ActivityThread.java:125)
E/AndroidRuntime( 281): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
E/AndroidRuntime( 281): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 281): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 281): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 281): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 281): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 281): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 281): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 281): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 281): Caused by: java.lang.ClassNotFoundException: de.bastian.gpstracker in loader dalvik.system.PathClassLoader[/data/app/de.bastian.gpstracker-1.apk]
E/AndroidRuntime( 281): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 281): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 281): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 281): at android.app.Instrumentation.newApplication(Instrumentation.java:942)
E/AndroidRuntime( 281): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
E/AndroidRuntime( 281): ... 11 more
W/ActivityManager( 59): Force finishing activity de.bastian.gpstracker/.MainActivity
D/dalvikvm( 149): GC_FOR_MALLOC freed 4092 objects / 248904 bytes in 134ms
W/ActivityManager( 59): Activity pause timeout for HistoryRecord{43fa91d0 de.bastian.gpstracker/.MainActivity}
I/ActivityManager( 59): Displayed activity com.android.launcher/com.android.launcher2.Launcher: 12561 ms (total 12561 ms)
W/ActivityManager( 59): Activity destroy timeout for HistoryRecord{43fa91d0 de.bastian.gpstracker/.MainActivity}
D/KeyguardViewMediator( 59): pokeWakelock(5000)
D/KeyguardViewMediator( 59): pokeWakelock(5000)
I/ARMAssembler( 59): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x325a10:0x325bd8] in 590637 ns
I/ARMAssembler( 59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x3261f0:0x3262ac] in 261841 ns
W/WindowManager( 59): No window to dispatch pointer action 1
I/Process ( 281): Sending signal. PID: 281 SIG: 9
I/ActivityManager( 59): Process de.bastian.gpstracker (pid 281) has died.
I guess it's something wrong with my project configuration. Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.bastian.gpstracker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="de.bastian.gpstracker" >
<activity
android:name="de.bastian.gpstracker.MainActivity"
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>
To be honest, I do not remember the last changes I made to this file, but, to me, everything seems to be fine here.
While searching for a sultion, I also came along the link Android Activity ClassNotFoundException - tried everything, which describes the same problem, but has a solution no applicable to my case as I am only working with a single project.
In the error log above, I noticed that the file name of the apk created ends on a '-1'. Maybe that's an error, maybe that's simply how eclipse/adt handles things. Also, I noticed that, when I try to run/debug the project, multiple class files with names MainActivity.class, MainActivity$1.class, MainActivity$2.class are created, although I only have a single MainActivity.java file (and no MainActivity$2.file or anything like that).
It would be great if someone had an idea of what's going wrong here.
You are setting the application node to reference a nonexistent class
de.bastian.gpstracker
Refers to the package name, no class whatsoever. Since gpstracker is the last thing in that string, the class loader assumes that gpstracker is a class, tries to load it and fails.
So write the name of the Application class (which extends Application).
Eg
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="de.bastian.gpstracker.MyApplicationClass" >
If you don't have a class that extends Application, then take out the android:name attribute for this node so it looks just like:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Change your application tag in manifest to this:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="de.bastian.gpstracker.MainActivity"
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>
Remove the name attribute from the application tag.
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException. Remove it and it should work:
I am making a game using LibGdx framwork.This is working fine for dekstop but when try to run for android
give exception:-
12-03 10:39:46.687: E/AndroidRuntime(9487): FATAL EXCEPTION: main
12-03 10:39:46.687: E/AndroidRuntime(9487): java.lang.NoClassDefFoundError: com.inoXmobile.glowjump.SuperJumper
12-03 10:39:46.687: E/AndroidRuntime(9487): at com.inoXmobile.glowjump.GlowJupmAndroid.onCreate(GlowJupmAndroid.java:35)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.os.Looper.loop(Looper.java:130)
12-03 10:39:46.687: E/AndroidRuntime(9487): at android.app.ActivityThread.main(ActivityThread.java:3687)
12-03 10:39:46.687: E/AndroidRuntime(9487): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 10:39:46.687: E/AndroidRuntime(9487): at java.lang.reflect.Method.invoke(Method.java:507)
12-03 10:39:46.687: E/AndroidRuntime(9487): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-03 10:39:46.687: E/AndroidRuntime(9487): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-03 10:39:46.687: E/AndroidRuntime(9487): at dalvik.system.NativeStart.main(Native Method)I
have put these jars and so file in android project libs folder:-
**1- gdx.jar
2-gdx-backend-android.jar
3-armeabi
4-armeabi-v7a**
My Android Activity is:-
public class GlowJupmAndroid extends AndroidApplication {
/** Called when the activity is first created. */
private PowerManager.WakeLock wl;
Bundle next;
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.initialize(new SuperJumper(), false);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
}
#Override
protected void onResume() {
super.onResume();
wl.acquire();
}
#Override
protected void onPause() {
super.onPause();
wl.release();
}
}
and my manifest file is this:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.inoXmobile.glowjump"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<application android:icon="#drawable/icon" android:debuggable="true" android:label="#string/app_name">
<activity android:name=".GlowJupmAndroid"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
please anyone suggest me why this exception occure many time I have been try to remove project and try to run ,clean and and new jar download from cod.google,but it is not working.
This looks like the ADT 17 problem. A good explanation can be found here, but the simplest approach is probably to follow the steps here.
Hey this is the weirdest problem i've ever encoutered,
I have 2 projects that's exactly the same each in a different project with a different package name.
Now i'm trying to run the 2nd project and i get a NullPointerException and when i press the error for it to send me to the line of code, it loads the same activity but in a different project.
Any idea why that happens?
This is my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="shibby.koteret"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name=".TenKoteretActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/chosen_image" android:name="selectedImageActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
Which is exactly the same in both projects besides package name and main activity name.
This is the logcat :
06-26 21:02:38.324: E/AndroidRuntime(5237): FATAL EXCEPTION: main
06-26 21:02:38.324: E/AndroidRuntime(5237): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1886, result=-1, data=Intent { dat=content://media/external/images/media/45 }} to activity {shibby.koteret/shibby.koteret.selectedImageActivity}: java.lang.NullPointerException
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.access$2000(ActivityThread.java:117)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.os.Looper.loop(Looper.java:123)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-26 21:02:38.324: E/AndroidRuntime(5237): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 21:02:38.324: E/AndroidRuntime(5237): at java.lang.reflect.Method.invoke(Method.java:507)
06-26 21:02:38.324: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-26 21:02:38.324: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-26 21:02:38.324: E/AndroidRuntime(5237): at dalvik.system.NativeStart.main(Native Method)
06-26 21:02:38.324: E/AndroidRuntime(5237): Caused by: java.lang.NullPointerException
06-26 21:02:38.324: E/AndroidRuntime(5237): at shibby.koteret.selectedImageActivity.onActivityResult(selectedImageActivity.java:196)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
06-26 21:02:38.324: E/AndroidRuntime(5237): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
06-26 21:02:38.324: E/AndroidRuntime(5237): ... 11 more
I don't think it's related, but as asked this is the relavent Java code (Errors on setContentView):
setContentView(R.layout.chosen_image);
ImageView imageView = (ImageView)this.findViewById(R.id.chosenImage2);
imageView.setImageBitmap(bitmap);
What i've checked :
The 2nd project packages the activity to the write project
I am not importing any thing from the 1st project package
Could this be an Eclipse error only? Anyone ever seen such a problem?
I was thinking, as the error is on an XML file, could it be somehow related to the R?
Well, what worked for me was i closed the 1st project and then Eclipse sent me to the right NullPointerException.
Still no idea why that happened, but that did the trick for me.
04-25 14:16:30.931: E/AndroidRuntime(6638): FATAL EXCEPTION: main
04-25 14:16:30.931: E/AndroidRuntime(6638): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.exclusive26.igale/com.exclusive26.igale.Push_Activity}: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread.deliverResults(ActivityThread.java:2553)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread.access$2000(ActivityThread.java:121)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.os.Looper.loop(Looper.java:130)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread.main(ActivityThread.java:3701)
04-25 14:16:30.931: E/AndroidRuntime(6638): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 14:16:30.931: E/AndroidRuntime(6638): at java.lang.reflect.Method.invoke(Method.java:507)
04-25 14:16:30.931: E/AndroidRuntime(6638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
04-25 14:16:30.931: E/AndroidRuntime(6638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
04-25 14:16:30.931: E/AndroidRuntime(6638): at dalvik.system.NativeStart.main(Native Method)
04-25 14:16:30.931: E/AndroidRuntime(6638): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ContextImpl.startService(ContextImpl.java:867)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.content.ContextWrapper.startService(ContextWrapper.java:336)
04-25 14:16:30.931: E/AndroidRuntime(6638): at com.google.android.c2dm.C2DMessaging.register(C2DMessaging.java:54)
04-25 14:16:30.931: E/AndroidRuntime(6638): at com.exclusive26.igale.Push_Activity.register(Push_Activity.java:124)
04-25 14:16:30.931: E/AndroidRuntime(6638): at com.exclusive26.igale.Push_Activity.onActivityResult(Push_Activity.java:58)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
04-25 14:16:30.931: E/AndroidRuntime(6638): at android.app.ActivityThread.deliverResults(ActivityThread.java:2549)
04-25 14:16:30.931: E/AndroidRuntime(6638): ... 11 more
The intent does have the proper permission in manifest:
MANIFEST:
<permission
android:name="com.exclusive26.igale.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.exclusive26.igale.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.exclusive26.igale.c2dm.permission.RECEIVE"/>
...
...
<activity android:name=".Push_Activity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
...
...
<service android:name=".C2DMReceiver" />
<receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.exclusive26.igale" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.exclusive26.igale" />
</intent-filter>
</receiver>
chk out the following code in Push_Activity.java :
com.google.android.c2dm.C2DMessaging.register( this, com.exclusive26.igale.Config.C2DM_SENDER );
parameters sent correctly (Push_Activity context and some email address <-- static final String)
inside C2DMessaging.register :
public static void register(Context context,
String senderId) {
Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
registrationIntent.setPackage(GSF_PACKAGE);
registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
PendingIntent.getBroadcast(context, 0, new Intent(), 0));
registrationIntent.putExtra(EXTRA_SENDER, senderId);
context.startService(registrationIntent);
// TODO: if intent not found, notification on need to have GSF
}
in the startService() i get the exception. No idia how to solve this.
please shed some light on the subject. Many Thanx!
Just for future users with this error:
manifest file should look like this:
<permission
android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
instead of
<permission
android:name="YOUR_PACKAGE.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />
<uses-permission android:name="YOUR_PACKAGE.permission.RECEIVE" />
I spend about 5 hours to found out what was wrong in my project :)
Maybe I'm missing something but the error shows "com.google.android.c2dm.permission.RECEIVE" and the manifest contains "com.google.android.c2dm.permission.SEND" so I don't see a perfect match.
The code was correct. I created a new project, copied the code and no problem anymore
This error also can be provide, if we use some resource's names incorrectly in our Activity Java file. I also got the same error, but I did not use any services or permission yet. Problem was at onCreate() method with wrong resource id.
I am trying to bind a service which is included in a Library project with the following lines:
Intent i = new Intent();
i.setClassName("de.ring0", "de.ring0.ToolkitService");
bindService(i, this, Context.BIND_AUTO_CREATE);
The binding process fails with the debug output below. According to the Android developer documentation the options in the two manifest files should be correct.
AndroidManifest.xml Library Project
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ring0">
<uses-sdk android:minSdkVersion="8" />
<application android:debuggable="true">
<service android:name="de.ring0.ToolkitService" android:exported="true" android:enabled="true"/>
</application>
</manifest>
AndroidManifest.xml Main Project
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ring0.example.tactilecompass"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="true">
<activity android:name=".TactileCompassActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="de.ring0.ToolkitService" />
</application>
</manifest>
Debug Log from emulator
W/ActivityManager( 59): Permission denied: checkComponentPermission() reqUid=10036
W/ActivityManager( 59): Permission Denial: Accessing service ComponentInfo{de.ring0/de.ring0.ToolkitService} from pid=2994, uid=10037 requires null
W/dalvikvm( 2994): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 2994): FATAL EXCEPTION: main
E/AndroidRuntime( 2994): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.ring0.example.tactilecompass/de.ring0.example.tactilecompass.TactileCompassActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=de.ring0/.ToolkitService }
E/AndroidRuntime( 2994): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 2994): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 2994): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 2994): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 2994): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2994): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 2994): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 2994): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2994): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 2994): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 2994): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 2994): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2994): Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=de.ring0/.ToolkitService }
E/AndroidRuntime( 2994): at android.app.ContextImpl.bindService(ContextImpl.java:874)
E/AndroidRuntime( 2994): at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
E/AndroidRuntime( 2994): at de.ring0.example.tactilecompass.TactileCompassActivity.onCreate(TactileCompassActivity.java:28)
E/AndroidRuntime( 2994): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2994): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 2994): ... 11 more
W/ActivityManager( 59): Process de.ring0.example.tactilecompass has crashed too many times: killing!
W/ActivityManager( 59): Force finishing activity de.ring0.example.tactilecompass/.TactileCompassActivity
I/Process ( 59): Sending signal. PID: 2994 SIG: 9
Use:
new Intent(this, de.ring0.ToolkitService.class);