I try to use Google Contacts Data API on Android and more specifically the ContactsService class but the application crash as soon as I try to instantiate ContactsService class.
I do not have this problem with a normal Java application.
For example, below code is working fine
public class TestJava {
public static void main(String[] args) {
ContactsService myService = new ContactsService("TestApp");
System.out.println("OK");
}
}
However, below Android app crashes (I put the permission for Internet in the manifest)
public class TestAndroidActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ContactsService myService = new ContactsService("TestApp");
System.out.println("OK");
}
}
Does anyone know if Google Contacts Data API is working on Android?
Did I miss a permission in the manifest?
Thanks in advance.
Edit:
I used two projects in Eclipse to test above code: a Java project and an Android project.
Both projects share the same libraries and only the Android project is crashing.
Here the error message:
09-10 12:12:43.928: INFO/AndroidRuntime(326): NOTE: attach of thread 'Binder Thread #3' failed
09-10 12:12:44.409: WARN/dalvikvm(332): Unable to resolve superclass of Lcom/google/gdata/client/contacts/ContactsService; (1133)
09-10 12:12:44.459: WARN/dalvikvm(332): Link of class 'Lcom/google/gdata/client/contacts/ContactsService;' failed
09-10 12:12:44.459: ERROR/dalvikvm(332): Could not find class 'com.google.gdata.client.contacts.ContactsService', referenced from method test34.pkg.Tests34Activity.onCreate
09-10 12:12:44.469: WARN/dalvikvm(332): VFY: unable to resolve new-instance 1142 (Lcom/google/gdata/client/contacts/ContactsService;) in Ltest34/pkg/Tests34Activity;
09-10 12:12:44.469: DEBUG/dalvikvm(332): VFY: replacing opcode 0x22 at 0x0008
09-10 12:12:44.469: DEBUG/dalvikvm(332): VFY: dead code 0x000a-0016 in Ltest34/pkg/Tests34Activity;.onCreate (Landroid/os/Bundle;)V
09-10 12:12:44.609: DEBUG/AndroidRuntime(332): Shutting down VM
09-10 12:12:44.609: WARN/dalvikvm(332): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): FATAL EXCEPTION: main
09-10 12:12:44.639: ERROR/AndroidRuntime(332): java.lang.NoClassDefFoundError: com.google.gdata.client.contacts.ContactsService
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at test34.pkg.Tests34Activity.onCreate(Tests34Activity.java:15)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.os.Looper.loop(Looper.java:123)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at java.lang.reflect.Method.invoke(Method.java:521)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 12:12:44.639: ERROR/AndroidRuntime(332): at dalvik.system.NativeStart.main(Native Method)
09-10 12:12:44.659: WARN/ActivityManager(59): Force finishing activity test34.pkg/.Tests34Activity
09-10 12:12:45.159: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450b53a0 test34.pkg/.Tests34Activity}
09-10 12:12:55.548: WARN/ActivityManager(59): Activity destroy timeout for HistoryRecord{450b53a0 test34.pkg/.Tests34Activity}
I think you getting this type of error
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
Have you added google-collect-1.0-rc1.jar file? if not then I am sure you got the error, this is the dependent file.
you can download from this file from this site and download it and add in your project.
Related
I just loaded my app created by cocos2dx-3.10 and when I open with it an AVD (again I haven't done any modifications to the app) the app crashes and gives the error: Unfortunately, libcocos2dx has crashed.
here is what I get in my android Monitor:
03-05 18:34:56.668 1435-1435/? D/dalvikvm: Not late-enabling CheckJNI (already on)
03-05 18:34:56.989 1435-1435/com.trying.name E/Trace: error opening trace file: No such file or directory (2)
03-05 18:34:57.419 1435-1435/com.trying.name D/AndroidRuntime: Shutting down VM
03-05 18:34:57.419 1435-1435/com.trying.name W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xb2f2b288)
03-05 18:34:57.518 1435-1435/com.trying.name E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:263)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-05 18:35:11.559 1435-1435/? I/Process: Sending signal. PID: 1435 SIG: 9
I am new in Android Development. I am working on cordova platform
I have created a sample hello world app and getting this error when i am trying to open it in genymotion. ALthough the app compile succesfully but when i run it in genymotion it just shows the prompt with text "Unfortunately "APP" has stopped."
The Error log shows.
01-12 08:16:04.867 2073-2073/com.technoserves.crudnew D/dalvikvm﹕ Late-enabling CheckJNI
01-12 08:16:06.107 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Unable to resolve superclass of Lcom/technoserves/crudnew/CordovaApp; (14)
01-12 08:16:06.119 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Link of class 'Lcom/technoserves/crudnew/CordovaApp;' failed
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew D/AndroidRuntime﹕ Shutting down VM
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa6142908)
01-12 08:16:06.155 2073-2073/com.technoserves.crudnew E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.technoserves.crudnew/com.technoserves.crudnew.CordovaApp}: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
01-12 08:16:22.399 2073-2073/com.technoserves.crudnew I/Process﹕ Sending signal. PID: 2073 SIG: 9
I have updated my cordova to resolve but still same error however a few days ago it was working fine and i have build some apps.
First download Cordova jar file from following link:
http://www.java2s.com/Code/JarDownload/cordova/cordova-1.8.1.jar.zip
after that extract the folder and put cordova-1.8.1 inside your libs folder of project in eclipse
And right click on your project--> properties and Select Android from left pane and scroll to bottom remove the cordova library if added.
then clean and build your project.
I have instantiated a fragment type that extends CameraFragment (and implements TabListener), and I am trying to call the autoFocus() from the the parent Activity. Calling autoFocus() from the fragment that extends CameraFragment works fine, but calling it from the parent Activity results in an NPE. I am listening for a onKeyDown() event in the main Activity, which works as expected as per the logcat. Here is my NPE trace:
09-10 10:00:16.410: D/app(5283): onKeyDown: 80
09-10 10:00:16.415: D/AndroidRuntime(5283): Shutting down VM
09-10 10:00:16.415: W/dalvikvm(5283): threadid=1: thread exiting with uncaught exception (group=0x40f7b2a0)
09-10 10:00:16.425: E/AndroidRuntime(5283): FATAL EXCEPTION: main
09-10 10:00:16.425: E/AndroidRuntime(5283): java.lang.NullPointerException
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.commonsware.cwac.camera.CameraFragment.autoFocus(CameraFragment.java:96)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.me.app.appCameraFragment.callAutoFocus(cameraFragment.java:232)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.me.app.MainTabActivity.onKeyDown(MainTabActivity.java:264)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.KeyEvent.dispatch(KeyEvent.java:2705)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.app.Activity.dispatchKeyEvent(Activity.java:2423)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2019)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3851)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3799)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2934)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.os.Looper.loop(Looper.java:137)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.app.ActivityThread.main(ActivityThread.java:4921)
09-10 10:00:16.425: E/AndroidRuntime(5283): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 10:00:16.425: E/AndroidRuntime(5283): at java.lang.reflect.Method.invoke(Method.java:511)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
09-10 10:00:16.425: E/AndroidRuntime(5283): at dalvik.system.NativeStart.main(Native Method)
I'm not sure what version of the code you are working on, but line 96 is a closing brace in the current CameraFragment.
The only way autoFocus() can crash with a NullPointerException is if cameraView is null, and the only way cameraView should be null is if onCreateView() has not yet been called. You need the fragment to be visible and fully created before you request auto-focus.
Alright, I've been going thru posts left and right trying to figure out this error.. I've managed to fix a few errors, but this is just driving me nuts.. it has almost no information.. or atleast none that makes any sense to me.
D/dalvikvm(431): Trying to load lib /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8
D/dalvikvm(431): Added shared lib /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8
D/dalvikvm(431): No JNI_OnLoad found in /data/data/com.hyperlinkup.manglerbt/lib/libventrilo_interface.so 0x405156c8, skipping init
D/dalvikvm(431): GC_EXTERNAL_ALLOC freed 61K, 53% free 2565K/5379K, external 1027K/1038K, paused 89ms
W/dalvikvm(431): No implementation found for native Lcom/hyperlinkup/manglerbt/VentriloInterface;.debuglevel (I)I
D/AndroidRuntime(431): Shutting down VM
W/dalvikvm(431): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(431): FATAL EXCEPTION: main
E/AndroidRuntime(431): java.lang.UnsatisfiedLinkError: debuglevel
E/AndroidRuntime(431): at com.hyperlinkup.manglerbt.VentriloInterface.debuglevel(Native Method)
E/AndroidRuntime(431): at com.hyperlinkup.manglerbt.ServerList.onCreate(ServerList.java:96)
E/AndroidRuntime(431): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime(431): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime(431): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(431): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime(431): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(431): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(431): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(431): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(431): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(431): at dalvik.system.NativeStart.main(Native Method)
I/Process(431): Sending signal. PID: 431 SIG: 9
I'm trying to rework the Mangler app to use Bluetooth recording (via startBluetoothSco), but I want to make sure the original is working before incorporating the bluetooth functionality.. Any help I can get on this matter would be greatly appreciated.
edit: thinking maybe my issue is with jni_wrappers.c.. first 3 #include's are unresolved.. original build was on linux system it would appear, so it's looking for jni.h, stdint.h and ventrilo3.h
Answer is in the Logcat Stacktrace itself
No implementation found for native Lcom/hyperlinkup/manglerbt/VentriloInterface;.debuglevel (I)I D/AndroidRuntime(431): Shutting down VM
There is a Native method called debuglevel in VentriloInterface. You have not implemented that method. So, the VM throws java.lang.UnsatisfiedLinkError.
I included a jar file in my Android project as explained in How can I use external JARs in an Android project?. With both methods described by MannyNS and Vinayak B. in this post I get the error "Could not find class 'test.libraryCalc.Calc" which is the class provided by the library. The following code illustrates the problem:
Example class provided via library: Calc.java
package test.libraryCalc;
public class Calc {
public int add(int a, int b){
return a + b;
}
}
LibraryTestActivity.java
package test.library;
import test.libraryCalc.Calc;
import android.app.Activity;
import android.os.Bundle;
public class LibraryTestActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Calc calc = new Calc();
int c = calc.add(3, 4);
}
}
I exported the jar file containing Calc.java to LibraryTest\libs\calc.jar
and added a reference to it using the "Add JARs..." button in the Java Build Path of LibraryTest
The library shows up in the Referenced libraries in LibraryTest
LibraryTest has no build problems but when running it on the emulator the following is shown in LogCat:
12-27 14:01:33.965: E/dalvikvm(747): Could not find class 'test.libraryCalc.Calc', referenced from method test.library.LibraryTestActivity.onCreate
12-27 14:01:33.965: W/dalvikvm(747): VFY: unable to resolve new-instance 13 (Ltest/libraryCalc/Calc;) in Ltest/library/LibraryTestActivity;
12-27 14:01:33.995: D/dalvikvm(747): VFY: replacing opcode 0x22 at 0x0008
12-27 14:01:33.995: D/dalvikvm(747): VFY: dead code 0x000a-0013 in Ltest/library/LibraryTestActivity;.onCreate (Landroid/os/Bundle;)V
12-27 14:01:34.065: D/AndroidRuntime(747): Shutting down VM
12-27 14:01:34.065: W/dalvikvm(747): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-27 14:01:34.075: E/AndroidRuntime(747): FATAL EXCEPTION: main
12-27 14:01:34.075: E/AndroidRuntime(747): java.lang.NoClassDefFoundError: test.libraryCalc.Calc
12-27 14:01:34.075: E/AndroidRuntime(747): at test.library.LibraryTestActivity.onCreate(LibraryTestActivity.java:14)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.os.Looper.loop(Looper.java:123)
12-27 14:01:34.075: E/AndroidRuntime(747): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 14:01:34.075: E/AndroidRuntime(747): at java.lang.reflect.Method.invokeNative(Native Method)
12-27 14:01:34.075: E/AndroidRuntime(747): at java.lang.reflect.Method.invoke(Method.java:521)
12-27 14:01:34.075: E/AndroidRuntime(747): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-27 14:01:34.075: E/AndroidRuntime(747): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-27 14:01:34.075: E/AndroidRuntime(747): at dalvik.system.NativeStart.main(Native Method)
12-27 14:06:34.170: I/Process(747): Sending signal. PID: 747 SIG: 9
What needs to be done to get this working? Thanks for all suggestions.
I think that the problem is that you try to add jar that contains Android code. You cannot do this. To include Android code you should create Android library. Simply create an Android project and in the project-properties Android section set that this is library project. After that you'll be able to add this library to your projects. For more about Android libraries you can read here.
Update: I've tried your code now. It works in my case. The only difference that I've made is during export of Jar I've checked Export Java source files and resources. Hope this will help you. Try it!