Android Cannot access accelerometer - android

in my android application it does not seem to let me use the accelerometer. when i call it in a statement the application crashes. the statement that seems to be causing the crash is:
SensorManager sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
The application is simple as is only calls the accelerometer and runs when this statement is absent, the above statment is called before the onCreate method and the log cat is below
05-24 20:08:46.990: E/AndroidRuntime(1149): FATAL EXCEPTION: main
05-24 20:08:46.990: E/AndroidRuntime(1149): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.b00348312.workout/com.b00348312.workout.WorkoutAppActivity}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.os.Looper.loop(Looper.java:123)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-24 20:08:46.990: E/AndroidRuntime(1149): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 20:08:46.990: E/AndroidRuntime(1149): at java.lang.reflect.Method.invoke(Method.java:521)
05-24 20:08:46.990: E/AndroidRuntime(1149): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-24 20:08:46.990: E/AndroidRuntime(1149): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-24 20:08:46.990: E/AndroidRuntime(1149): at dalvik.system.NativeStart.main(Native Method)
05-24 20:08:46.990: E/AndroidRuntime(1149): Caused by: java.lang.IllegalStateException: System services not available to Activities before onCreate()
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.Activity.getSystemService(Activity.java:3526)
05-24 20:08:46.990: E/AndroidRuntime(1149): at com.b00348312.workout.WorkoutAppActivity.<init>(WorkoutAppActivity.java:25)
05-24 20:08:46.990: E/AndroidRuntime(1149): at java.lang.Class.newInstanceImpl(Native Method)
05-24 20:08:46.990: E/AndroidRuntime(1149): at java.lang.Class.newInstance(Class.java:1429)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-24 20:08:46.990: E/AndroidRuntime(1149): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-24 20:08:46.990: E/AndroidRuntime(1149): ... 11 more
from the logcat i cannot figure out the cause of this problem when this statement worked in a different programme.

Thats a double negative? lol Cut the code where ure calling the system service and paste inside your onCreate
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//PLACE YOUR ACCEL CODE IN HERE
}

You have to grab the SensorManager after onCreate is called.
"System services not available to Activities before onCreate()"

Related

Decompiled and imported into Eclipse and got instantiation error

I am a newbie to Android App programming. I decompiled an APK and imported into Eclipse. I ran it on an Android emulator and I got the message below on Logcat. Can someone give me an idea where to start looking. The app works on the Android phone. Thanks.
11-24 13:41:39.046: D/AndroidRuntime(363): Shutting down VM
11-24 13:41:39.046: W/dalvikvm(363): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-24 13:41:39.126: E/AndroidRuntime(363): FATAL EXCEPTION: main
11-24 13:41:39.126: E/AndroidRuntime(363): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.breakeven/com.breakeven.BreakEvenCalculatorActivity}: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.os.Looper.loop(Looper.java:123)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:41:39.126: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:41:39.126: E/AndroidRuntime(363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:41:39.126: E/AndroidRuntime(363): at dalvik.system.NativeStart.main(Native Method)
11-24 13:41:39.126: E/AndroidRuntime(363): Caused by: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:41:39.126: E/AndroidRuntime(363): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-24 13:41:39.126: E/AndroidRuntime(363): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-24 13:41:39.126: E/AndroidRuntime(363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-24 13:41:39.126: E/AndroidRuntime(363): ... 11 more
11-24 13:43:41.106: I/Process(363): Sending signal. PID: 363 SIG: 9
11-24 13:44:17.136: D/AndroidRuntime(393): Shutting down VM
11-24 13:44:17.136: W/dalvikvm(393): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-24 13:44:17.206: E/AndroidRuntime(393): FATAL EXCEPTION: main
11-24 13:44:17.206: E/AndroidRuntime(393): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.breakeven/com.breakeven.BreakEvenCalculatorActivity}: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.os.Looper.loop(Looper.java:123)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:44:17.206: E/AndroidRuntime(393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:44:17.206: E/AndroidRuntime(393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:44:17.206: E/AndroidRuntime(393): at dalvik.system.NativeStart.main(Native Method)
11-24 13:44:17.206: E/AndroidRuntime(393): Caused by: java.lang.ClassNotFoundException: com.breakeven.BreakEvenCalculatorActivity in loader dalvik.system.PathClassLoader[/data/app/com.breakeven-1.apk]
11-24 13:44:17.206: E/AndroidRuntime(393): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-24 13:44:17.206: E/AndroidRuntime(393): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-24 13:44:17.206: E/AndroidRuntime(393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-24 13:44:17.206: E/AndroidRuntime(393): ... 11 more
11-24 13:44:23.546: I/Process(393): Sending signal. PID: 393 SIG: 9
11-24 13:49:28.816: D/AndroidRuntime(403): Shutting down VM
11-24 13:49:28.816: W/dalvikvm(403): threadid=1: thread exiting with uncaught exception (group=0x40015560)

NoClassDefFoundError Due to Google Maps v2

I have recently had to update my SDK and ADT and since then I have been having loads of trouble with existing applications. My problem is that with one of my applications I am getting the following error:
05-24 09:13:49.234: E/AndroidRuntime(7064): FATAL EXCEPTION: main
05-24 09:13:49.234: E/AndroidRuntime(7064): java.lang.NoClassDefFoundError: com.taxi.cabfind.Map_Location
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.taxi.cabfind.Pickup_Address$5.onClick(Pickup_Address.java:239)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.view.View.performClick(View.java:4204)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.view.View$PerformClick.run(View.java:17355)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Handler.handleCallback(Handler.java:725)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.os.Looper.loop(Looper.java:137)
05-24 09:13:49.234: E/AndroidRuntime(7064): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-24 09:13:49.234: E/AndroidRuntime(7064): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 09:13:49.234: E/AndroidRuntime(7064): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-24 09:13:49.234: E/AndroidRuntime(7064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-24 09:13:49.234: E/AndroidRuntime(7064): at dalvik.system.NativeStart.main(Native Method)
This is occurring when I am trying to load up a fragment activity that contains maps v2.
This is confusing to me because in another application that I have, there is maps v2 code inside this app and this app has no problems with it. I have checked all the settings and made sure that everything matches, but I am still getting this crash.
Can someone please help.
EDIT
In changing the project and placing the google-play-services-lib.jar file in the libs folder I am now getting the following error
05-24 09:35:27.169: E/AndroidRuntime(11672): FATAL EXCEPTION: main
05-24 09:35:27.169: E/AndroidRuntime(11672): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Activity.setContentView(Activity.java:1881)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.taxi.cabfind.Map_Location.onCreate(Map_Location.java:81)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Activity.performCreate(Activity.java:5104)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.os.Looper.loop(Looper.java:137)
05-24 09:35:27.169: E/AndroidRuntime(11672): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-24 09:35:27.169: E/AndroidRuntime(11672): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 09:35:27.169: E/AndroidRuntime(11672): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-24 09:35:27.169: E/AndroidRuntime(11672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-24 09:35:27.169: E/AndroidRuntime(11672): at dalvik.system.NativeStart.main(Native Method)
This is now exactly the same as my other project that is working, I am really confused at why this one isn't working
You should not place the jar in libs folder.
You should google play services library project in your android project.
Import library project into workspace and eclipse.
Right click on your android project. goto properties. Choose android. click add. Browse the library project and add the same.
Now if you have updated adt to rev 22.
java.lang.ClassNotFoundException after changing nothing in the project but upgrading eclipse android sdk
to check if its a library project. right click on your google play services library goto properties choose android. You will see Is Library check box checked
After adding it looks similar to the one below
I upgrate SDK and ADT(ver22) yesterday just like you .
And have same error
I try this and it's work ...

Android project does not run when target sdk is changed

Currently project target sdk is google api level 14 and it runs well. If I changed target sdk to google api level 16 in android manifest file and run the project then it shows message unfortunately, app has stopped. Again if I change it back to level 14 then it runs.Can anyone tell me the what can be the reason?
EDIT : logcat details
05-24 10:57:09.709: E/Trace(981): error opening trace file: No such file or directory (2)
05-24 10:57:11.108: E/AndroidRuntime(981): FATAL EXCEPTION: main
05-24 10:57:11.108: E/AndroidRuntime(981): java.lang.RuntimeException: Unable to create application com.sentry.android.hmi.SentryApp: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{41321b58 981:com.sentry.android/u0a48} (pid=981, uid=10048) requires android.permission.READ_CALL_LOG or android.permission.WRITE_CALL_LOG
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Looper.loop(Looper.java:137)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-24 10:57:11.108: E/AndroidRuntime(981): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 10:57:11.108: E/AndroidRuntime(981): at java.lang.reflect.Method.invoke(Method.java:511)
05-24 10:57:11.108: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-24 10:57:11.108: E/AndroidRuntime(981): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-24 10:57:11.108: E/AndroidRuntime(981): at dalvik.system.NativeStart.main(Native Method)
05-24 10:57:11.108: E/AndroidRuntime(981): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.CallLogProvider from ProcessRecord{41321b58 981:com.sentry.android/u0a48} (pid=981, uid=10048) requires android.permission.READ_CALL_LOG or android.permission.WRITE_CALL_LOG
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Parcel.readException(Parcel.java:1425)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.os.Parcel.readException(Parcel.java:1379)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2354)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4219)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:1703)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1099)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.query(ContentResolver.java:354)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.content.ContentResolver.query(ContentResolver.java:313)
05-24 10:57:11.108: E/AndroidRuntime(981): at com.sentry.android.hmi.SentryApp.onCreate(SentryApp.java:116)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
05-24 10:57:11.108: E/AndroidRuntime(981): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
05-24 10:57:11.108: E/AndroidRuntime(981): ... 10 more
You have to add the following line to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
If you are just reading this log, change the line to:
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
Put this line above of your <application> tag. Or, if you have other permission entries as well, where those others are.
Those permissions were added with the API-Level 16. See for example the documentation to the value READ_CALL_LOG.

Refering from one android project to another Eclipse

I've tried this for 2 hours now and I dont seem to get it to work. I want to build a framework for my application, in another project. First of I'm just trying to reach a class from that other project. The code compiles but fails at runtime, at the line where i instantiate an object from a class from the framework.
05-24 18:04:01.645: E/dalvikvm(16927): Could not find class 'frame.test.Hello', referenced from method moduleLogin.activity.Login.loginClick
05-24 18:04:01.645: W/dalvikvm(16927): VFY: unable to resolve new-instance 190 (Lframe/test/Hello;) in LmoduleLogin/activity/Login;
05-24 18:04:02.715: W/dalvikvm(16927): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.view.View$1.onClick(View.java:2154)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.view.View.performClick(View.java:2538)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.view.View$PerformClick.run(View.java:9152)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.os.Handler.handleCallback(Handler.java:587)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.os.Looper.loop(Looper.java:130)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.app.ActivityThread.main(ActivityThread.java:3691)
05-24 18:04:02.720: E/AndroidRuntime(16927): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927): at java.lang.reflect.Method.invoke(Method.java:507)
05-24 18:04:02.720: E/AndroidRuntime(16927): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
05-24 18:04:02.720: E/AndroidRuntime(16927): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
05-24 18:04:02.720: E/AndroidRuntime(16927): at dalvik.system.NativeStart.main(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927): Caused by: java.lang.reflect.InvocationTargetException
05-24 18:04:02.720: E/AndroidRuntime(16927): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 18:04:02.720: E/AndroidRuntime(16927): at java.lang.reflect.Method.invoke(Method.java:507)
05-24 18:04:02.720: E/AndroidRuntime(16927): at android.view.View$1.onClick(View.java:2149)
05-24 18:04:02.720: E/AndroidRuntime(16927): ... 11 more
05-24 18:04:02.720: E/AndroidRuntime(16927): Caused by: java.lang.NoClassDefFoundError: frame.test.Hello
05-24 18:04:02.720: E/AndroidRuntime(16927): at moduleLogin.activity.Login.loginClick(Login.java:49)
05-24 18:04:02.720: E/AndroidRuntime(16927): ... 14 more
I know there is a lot on this topic, but I've have searched for hours without any posts solving this problem. Most of the topics are how to reference to another project. But since my code is compiling it should be referenced?
And does both projects needs to be Android projects? Should the framework project be a library? Thanks for any help!
if the library project is an android project , you need to make it a library one by choosing it from the project properties , and then to reference it via the same place but on the project that uses it.
don't forget that there are some rules when you use a library project . see my post here for more information.
if the library project is java , its exactly as using other java projects.
This is a long shot, but it worked for me (having also spent hours on this, after reading all the same posts you did...)
If you are confident that you have correctly configured the project references, this could be a result of a silent build failure.
In my case, the problem arose due to incompatibilities between the build environments for my two projects. In Project "A", which was pure Java, the following line compiled without error in Project A's build environment:
if ((int) d.get("good")) == 0) {....
It turns out that this was not legal in the (Android) Project "B", which required an object cast:
if ((Integer) d.get("good")) == 0) {....
However, the only indication that I got of the error was the same as what you experienced, a "VFY: Unable to resolve..." error.
I found the error in a painful way: By copying the code from Project "A" into Project "B," finding the errors, and fixing them in Project "A." There is probably a more intelligent way than mine to find such incompatibilities, such as by tweaking the settings in both projects to match exactly.

Android call problem

I am using the codes below but my app force closes independently which one use. These are from several examples found on the net but none of them is working:
The semes2 variable is a phone number retrieved from the ContactsContract and is not null (verified by Toast msg).
Uri uri = Uri.fromParts("tel", semes2, null);
Intent callIntent = new Intent(Intent.ACTION_CALL, uri);
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
or
Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:6365551212"));
startActivity(dialIntent);
or
Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel://" + semes2));
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialIntent);
In the manifest i have <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
What am i missing?
Edit: logcat:
05-24 05:46:17.404: ERROR/AndroidRuntime(272): FATAL EXCEPTION: main
05-24 05:46:17.404: ERROR/AndroidRuntime(272): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel://+36301111111 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43f8e500 272:com.bfarago.nevnap/10048} (pid=272, uid=10048) requires android.permission.CALL_PHONE
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.os.Parcel.readException(Parcel.java:1247)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.os.Parcel.readException(Parcel.java:1235)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.app.Activity.startActivityForResult(Activity.java:2817)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.app.Activity.startActivity(Activity.java:2923)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at com.bfarago.nevnap.MainActivity$1$1$1.onClick(MainActivity.java:1363)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:874)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.widget.ListView.performItemClick(ListView.java:3382)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.os.Handler.handleCallback(Handler.java:587)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.os.Looper.loop(Looper.java:123)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at java.lang.reflect.Method.invoke(Method.java:521)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-24 05:46:17.404: ERROR/AndroidRuntime(272): at dalvik.system.NativeStart.main(Native Method)
05-24 05:46:17.564: WARN/ActivityManager(58): Force finishing activity com.bfarago.nevnap/.MainActivity
05-24 05:46:18.224: WARN/ActivityManager(58): Activity pause timeout for HistoryRecord{44011768 com.bfarago.nevnap/.MainActivity}
05-24 05:46:19.754: INFO/Process(272): Sending signal. PID: 272 SIG: 9
05-24 05:46:19.816: INFO/ActivityManager(58): Process com.bfarago.nevnap (pid 272) has died.
05-24 05:46:19.844: WARN/ActivityManager(58): Scheduling restart of crashed service com.bfarago.nevnap/.UpdateService in 5000ms
05-24 05:46:19.864: INFO/WindowManager(58): WIN DEATH: Window{43fac220 com.bfarago.nevnap/com.bfarago.nevnap.MainActivity paused=false}
05-24 05:46:19.864: INFO/WindowManager(58): WIN DEATH: Window{440383a8 com.bfarago.nevnap/com.bfarago.nevnap.MainActivity paused=false}
05-24 05:46:19.954: WARN/InputManagerService(58): Got RemoteException sending setActive(false) notification to pid 272 uid 10048
05-24 05:46:21.110: WARN/NotificationService(58): Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy#43edd2c0 in package com.bfarago.nevnap
05-24 05:46:21.114: WARN/ActivityManager(58): setProcessForeground called on unknown pid: 272
05-24 05:46:24.944: INFO/ActivityManager(58): Start proc com.bfarago.nevnap for service com.bfarago.nevnap/.UpdateService: pid=286 uid=10048 gids={1015}
05-24 05:46:29.200: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{44011768 com.bfarago.nevnap/.MainActivity}
05-24 05:46:30.605: DEBUG/dalvikvm(162): GC_EXPLICIT freed 2438 objects / 143352 bytes in 192ms
Found the solution. Instead of ACTION_CALL i should have used ACTION_DIAL. I can also remove the // after tel:, it doesn't matter. So e.g.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + semes2));
startActivity(intent);
However, the 2nd example is still force closes even though it has ACTION DIAL.
You should include the following permission android.permission.CALL_PHONE in your android manifest file :
<uses-permission android:name="android.permission.CALL_PHONE"/>

Categories

Resources