Wen i install my apk file on android device and after installation wen i hit the open button my application does not start and shows force close.
The logcat output of my application is shown below :
09-28 12:14:57.651: INFO/ActivityManager(124): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen }
09-28 12:14:57.660: WARN/ActivityManager(124): Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen } from ProcessRecord{44ffa660 1130:com.android.packageinstaller/10026} (pid=1130, uid=10026) requires android.permission.WRITE_CONTACTS
09-28 12:14:57.672: DEBUG/AndroidRuntime(1130): Shutting down VM
09-28 12:14:57.672: WARN/dalvikvm(1130): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): FATAL EXCEPTION: main
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen } from ProcessRecord{44ffa660 1130:com.android.packageinstaller/10026} (pid=1130, uid=10026) requires android.permission.WRITE_CONTACTS
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.os.Parcel.readException(Parcel.java:1247)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.os.Parcel.readException(Parcel.java:1235)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.app.Activity.startActivityForResult(Activity.java:2817)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.app.Activity.startActivity(Activity.java:2923)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at com.android.packageinstaller.InstallAppProgress.onClick(InstallAppProgress.java:224)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.view.View.performClick(View.java:2408)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.view.View$PerformClick.run(View.java:8816)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.os.Handler.handleCallback(Handler.java:587)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.os.Looper.loop(Looper.java:123)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at java.lang.reflect.Method.invoke(Method.java:521)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130): at dalvik.system.NativeStart.main(Native Method)
09-28 12:14:57.740: WARN/ActivityManager(124): Force finishing activity com.android.packageinstaller/.InstallAppProgress
Please help me by guiding me about what I have done wrong
EDIT :
The permissions in my manifest are :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<!-- <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> -->
<application android:icon="#drawable/biz_logo"
android:permission="android.permission.WRITE_CONTACTS">
After this also it is behaving same
Looks like you need to add the permission
android.permission.WRITE_CONTACTS
to your manifest file.
Barry
The logcat output has everything you need to know :-)
Your app basically is writing contacts but it does not have permissions to do so (in Android, applications need to be given permissions explicitly for various operations).
Edit the file AndroidManifest.xml to include the following line/XML element:
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
within the
<manifest>
XML element, and then rebuild, reinstall and rerun.
For more information, take a look here: http://developer.android.com/guide/topics/manifest/uses-permission-element.html
yes i rebuilt it.my mistake was i have written in manifest <uses-permission android:name="android.permission.WRITE_CONTACTS" /> and also inside the application tag like this
<application android:icon="#drawable/logo"
android:permission="android.permission.WRITE_CONTACTS">
so i was getting force close.
This permission should be written only once in the manifest file
Related
please i tried coding an android app using eclipse luna. I am writing a client gcm codes to push notifications. I have finished without any compiling errors, but wen i execute it on the mobile phone, the app crashes. Please below is the log i have been getting. Thanks for helping
05-23 23:07:27.303: D/AndroidRuntime(18211): Shutting down VM
05-23 23:07:27.303: W/dalvikvm(18211): threadid=1: thread exiting with uncaught exception (group=0x41f522a0)
05-23 23:07:27.303: E/AndroidRuntime(18211): FATAL EXCEPTION: main
05-23 23:07:27.303: E/AndroidRuntime(18211): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.prgguru.example/com.prgguru.example.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.prgguru.example/com.prgguru.example.HomeActivity}; have you declared this activity in your AndroidManifest.xml? 05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.os.Looper.loop(Looper.java:137)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-23 23:07:27.303: E/AndroidRuntime(18211): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 23:07:27.303: E/AndroidRuntime(18211): at java.lang.reflect.Method.invoke(Method.java:511)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-23 23:07:27.303: E/AndroidRuntime(18211): at dalvik.system.NativeStart.main(Native Method)
05-23 23:07:27.303: E/AndroidRuntime(18211): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activityclass {com.prgguru.example/com.prgguru.example.HomeActivity}; have you declared this activity in your AndroidManifest.xml?
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivityForResult(Activity.java:3428)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivityForResult(Activity.java:3389)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivity(Activity.java:3599)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.startActivity(Activity.java:3567)
05-23 23:07:27.303: E/AndroidRuntime(18211): at com.prgguru.example.MainActivity.onCreate(MainActivity.java:61)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Activity.performCreate(Activity.java:5188)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-23 23:07:27.303: E/AndroidRuntime(18211): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
05-23 23:07:27.303: E/AndroidRuntime(18211): ... 11 more
05-23 23:07:27.343: D/dalvikvm(18211): GC_CONCURRENT freed 224K, 13% free 7212K/8199K, paused 12ms+2ms, total 35ms
below is also my manifest file. this is how i make the manifest file
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prgguru.example"
android:versionCode="1"
android:versionName="1.0" >
<!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="22" />
<!-- GCM connects to Internet Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.prgguru.example.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.prgguru.example.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- Main activity. -->
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Register Activity -->
<activity
android:name=".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>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.prgguru.example" />
</intent-filter>
</receiver>
<service android:name=".GCMNotificationIntentService" />
</application>
</manifest>`
Whenever you make a new Activity and are going to display it you need to add a reference to it in your AndroidManifest.xml
For example you can simply do
<activity name="your.package.activityname" />
For more information see, Declaring class names in the documentation.
I have installed SDK and when I am executing a sample application in eclipse I am getting an error while logging into salesforce like this
Unsafe JavaScript attempt to access frame with URL https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dl86Hcy6qEKtWNqzXVErZDlmcRQs0D_HBE55MLVuP3x8t5wXkyHYyrVx2Xb5JoWzyVOJrnTqMMaWy_Sfo0mo2n3jvu8IfPosBnmPsp1pafeNjQPGSngZvcMpAyNsTC62PxX8rVEu.GK3O6Y3FWwqTYFhIu97eeHIM4ca76Rj0rms8wRYPaZ_Bn7qxXKSKMr9ZfcNx3ypToLFS0IGq51_Ud09ujxJLb4N82smXIx37QNpk1hMmwZSSg7NYgF6VRdhQDfWZxb85wCOHMy9aNm0zOes_XhH3xWqL28AvaSP4_NC4esWw_0TkP51agEmNZuFoz64RqwxExwiKtXhaNBbhTTaePLkdlCT6aXnmIMTSkoekmQZqjCBsU74H8dgWjZHbZTpBhWXVbM5sr0f3JnWlmpKAJWYXym7s%253D%26display%3Dtouch%26sdtd%3D1&display=touch&sdtd=1
from frame with URL https://www.salesforce.com/login-messages/messages.html?r=https%3A%2F%2Flogin.salesforce.com%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dl86Hcy6qEKtWNqzXVErZDlmcRQs0D_HBE55MLVuP3x8t5wXkyHYyrVx2Xb5JoWzyVOJrnTqMMaWy_Sfo0mo2n3jvu8IfPosBnmPsp1pafeNjQPGSngZvcMpAyNsTC62PxX8rVEu.GK3O6Y3FWwqTYFhIu97eeHIM4ca76Rj0rms8wRYPaZ_Bn7qxXKSKMr9ZfcNx3ypToLFS0IGq51_Ud09ujxJLb4N82smXIx37QNpk1hMmwZSSg7NYgF6VRdhQDfWZxb85wCOHMy9aNm0zOes_XhH3xWqL28AvaSP4_NC4esWw_0TkP51agEmNZuFoz64RqwxExwiKtXhaNBbhTTaePLkdlCT6aXnmIMTSkoekmQZqjCBsU74H8dgWjZHbZTpBhWXVbM5sr0f3JnWlmpKAJWYXym7s%253D%26display%3Dtouch%26sdtd%3D1&noroundedcorner. Domains, protocols and ports must match.
Execeptions:
11-11 11:23:07.239: E/AndroidRuntime(366): java.lang.NoSuchMethodError: java.lang.String.isEmpty
11-11 11:23:07.239: E/AndroidRuntime(366): at com.salesforce.androidsdk.ui.OAuthWebviewHelper$BaseFinishAuthFlowTask.onPostExecute(OAuthWebviewHelper.java:378)
11-11 11:23:07.239: E/AndroidRuntime(366): at com.salesforce.androidsdk.ui.OAuthWebviewHelper$BaseFinishAuthFlowTask.onPostExecute(OAuthWebviewHelper.java:1)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.os.AsyncTask.finish(AsyncTask.java:417)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.os.AsyncTask.access$300(AsyncTask.java:127)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.os.Looper.loop(Looper.java:123)
11-11 11:23:07.239: E/AndroidRuntime(366): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-11 11:23:07.239: E/AndroidRuntime(366): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 11:23:07.239: E/AndroidRuntime(366): at java.lang.reflect.Method.invoke(Method.java:521)
11-11 11:23:07.239: E/AndroidRuntime(366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-11 11:23:07.239: E/AndroidRuntime(366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-11 11:23:07.239: E/AndroidRuntime(366): at dalvik.system.NativeStart.main(Native Method)
I think this is a security related error is any permissions required to login through mobile.
You can ignore those errors/exceptions. If you are trying to import sample applications provided by salesforce sdk, you must be able to login as you will be navigated to login page when you run your app.
As far as permissions are concerned, you need following common permissions we use in Android applications
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
But still no luck with creating our own application and running.
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 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);
I have recently taken up Android Development and I was looking to using the WebView display webpages. I picked up from the sample that was given on Google site and for some reason the emulator kept saying page was not available. I searched in StackOverflow and found links relating to WebViewClient. I tried that also but no luck there, I have checked multiple times about the manifest entry for internet permission and its there. As a test I ran the browser available within the emulator and sure enough my firewall popped up a question on whether to allow it access or not. The pop up never came to me when I was running it from program. The code that I have is what is there Google pages
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
mWebView.setWebViewClient(new HelloWebViewClient());
private class HelloWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
I tried loading simple html directly using loadData and it worked fine. I am at loss as to what is happening and how this can be resolved. I would appreciate any help on this.
Adding the Android Manifest here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
</application>
</manifest>
To check if its just a WebView thingy, I tried accessing the internet using httpGet and httpResonse classes and got the same problem, the code was not able to connect to the given site. It failed stating the below
05-10 00:37:53.191: WARN/System.err(294): java.net.UnknownHostException: feeds.feedburner.com
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByName(InetAddress.java:242)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-10 00:37:53.280: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-10 00:37:53.291: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-10 00:37:53.301: WARN/System.err(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:43)
05-10 00:37:53.301: WARN/System.err(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:37:53.309: WARN/System.err(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:37:53.322: WARN/System.err(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:37:53.330: WARN/System.err(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:37:53.340: WARN/System.err(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:37:53.361: WARN/System.err(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:37:53.361: WARN/System.err(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:37:53.372: WARN/System.err(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:37:53.401: WARN/System.err(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:37:56.773: WARN/ActivityManager(58): Launch timeout has expired, giving up wake lock!
05-10 00:37:58.083: WARN/ActivityManager(58): Activity idle timeout for HistoryRecord{44fc9108 com.example.hellowebview/.HelloWebView}
05-10 00:38:06.300: DEBUG/KeyguardViewMediator(58): pokeWakelock(5000)
05-10 00:38:06.651: INFO/ARMAssembler(58): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3724c8:0x3725d4] in 7266287 ns
05-10 00:38:06.720: INFO/ARMAssembler(58): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x371380:0x371548] in 1486222 ns
05-10 00:38:30.430: DEBUG/AndroidRuntime(294): Shutting down VM
05-10 00:38:30.430: WARN/dalvikvm(294): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): FATAL EXCEPTION: main
05-10 00:38:30.752: ERROR/AndroidRuntime(294): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellowebview/com.example.hellowebview.HelloWebView}: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): Caused by: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:51)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): ... 11 more
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am not sure what is the significance of this but would appreciate if anyone could elaborate.
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
mWebView = (WebView) findViewById(R.id.webview);
WebSettings setting =mWebView.getSettings();
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
mWebView.loadUrl("http://www.google.com");
Use this code .shouldOverrideUrlLoading() not use compulsary.use this code and please reply me this code work or not
Your code looks fine. I would make sure internet is working correctly on the emulator by browsing a few pages on the Android Browser. I have had problems before where the emulator would lose network access.