Disclaimer...I think I've gone through all of the related posts on this topic and so far, none of them have fixed my problem. That being said, if I missed something, feel free to point me in the proper direction.
Environment:
-newly configured Eclipse Indigo
-ADT 18
-GWT 2.4
-App Engine SDK 1.6.4
I'm attempting to create a standard, no frills boilerplate "App Engine Connected Android Project" to begin learning how things are handled between App Engine and Android.
After completing the File > New > App Engine Connected Android project (with a functional C2DM role email and password) I get the MyTasks-Android and MyTasks-AppEngine projects in Eclipse.
Knowing the whole lib versus libs issue with ADT17+, I change the lib folder in the MyTasks-Android project to libs and update the build path for the three jars (c2dm.jar, requestfactory-client.jar and validation-api-1.0.0.GA.jar). I also add the MyTasks-AppEngine project to the build path.
Once that's all done, I try to run the App-Android project on my device.
I am able to select my Android account, "allow" it to access my account and I see the "say hello" button. Upon clicking the button, I get the following error in Eclipse:
05-01 22:13:22.965: E/dalvikvm(17457): Could not find class 'com.mytasks.client.MyRequestFactory', referenced from method com.mytasks.MyTasksActivity$2$1.doInBackground
05-01 22:13:22.965: W/dalvikvm(17457): VFY: unable to resolve const-class 315 (Lcom/mytasks/client/MyRequestFactory;) in Lcom/mytasks/MyTasksActivity$2$1;
05-01 22:13:22.965: D/dalvikvm(17457): VFY: replacing opcode 0x1c at 0x000a
05-01 22:13:22.973: W/dalvikvm(17457): threadid=11: thread exiting with uncaught exception (group=0x40a291f8)
05-01 22:13:22.989: E/AndroidRuntime(17457): FATAL EXCEPTION: AsyncTask #1
05-01 22:13:22.989: E/AndroidRuntime(17457): java.lang.RuntimeException: An error occured while executing doInBackground()
05-01 22:13:22.989: E/AndroidRuntime(17457): at android.os.AsyncTask$3.done(AsyncTask.java:278)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.lang.Thread.run(Thread.java:856)
05-01 22:13:22.989: E/AndroidRuntime(17457): Caused by: java.lang.NoClassDefFoundError: com.mytasks.client.MyRequestFactory
05-01 22:13:22.989: E/AndroidRuntime(17457): at com.mytasks.MyTasksActivity$2$1.doInBackground(MyTasksActivity.java:145)
05-01 22:13:22.989: E/AndroidRuntime(17457): at com.mytasks.MyTasksActivity$2$1.doInBackground(MyTasksActivity.java:1)
05-01 22:13:22.989: E/AndroidRuntime(17457): at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-01 22:13:22.989: E/AndroidRuntime(17457): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
I've been working on this all day and so far, no luck. So, if anyone has any suggestions, I would definitely appreciate the assistance.
Thanks!
EDIT - 5/2/2012 - added setHelloWorldScreenContent from MyTasksActivity class. Specifically, failing at: MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);
Again, this is a vanilla wizard-generated App Engine Connected Android project - the only change I made was adding the MyTasks-AppEngine to the MyTasks-Android build path and changing lib to libs, then readding the three jars to the build path.
private void setHelloWorldScreenContent() {
setContentView(R.layout.hello_world);
final TextView helloWorld = (TextView) findViewById(R.id.hello_world);
final Button sayHelloButton = (Button) findViewById(R.id.say_hello);
sayHelloButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
sayHelloButton.setEnabled(false);
helloWorld.setText(R.string.contacting_server);
// Use an AsyncTask to avoid blocking the UI thread
new AsyncTask<Void, Void, String>() {
private String message;
#Override
protected String doInBackground(Void... arg0) {
MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);
final HelloWorldRequest request = requestFactory.helloWorldRequest();
Log.i(TAG, "Sending request to server");
request.getMessage().fire(new Receiver<String>() {
#Override
public void onFailure(ServerFailure error) {
message = "Failure: " + error.getMessage();
}
#Override
public void onSuccess(String result) {
message = result;
}
});
return message;
}
#Override
protected void onPostExecute(String result) {
helloWorld.setText(result);
sayHelloButton.setEnabled(true);
}
}.execute();
}
});
}
I faced the same issue. I also just changed the folder name from lib to libs and added back the 3 jars in build path in andorid project and it worked.
I just spent 4 hours on it, the standard lib->libs didnt help me, at the end the solution was compile with jdk 1.6 not 1.7, it means you have to compile even the shared libraries from appengine (well logically) compile with 1.6
Related
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NoClassDefFoundError: org.apache.http.entity.mime.HttpMultipartMode
at org.apache.http.entity.mime.MultipartEntity.<init>(MultipartEntity.java:91)
at com.greencubes.greendesk.AndroidMultiPartEntity.<init>(AndroidMultiPartEntity.java:19)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.uploadFile(FirstFragment.java:244)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:233)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:211)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
If you are using a library, you need to put it into /libs folder.
download httpmime, httpcore and httpclient library from http://hc.apache.org/downloads.cgi
Hope this will help as i have the same jar files in the studio.
If you are using Eclipse then add all the jar files to build path.
Thanks,
Apache HTTP client was removed in Lollipop. It's recommended to use HttpUrlConnection instead.
If you have to use it you can add:
android {
useLibrary 'org.apache.http.legacy'
}
to your build.gradle file.
I am getting this issue most of the time in samsung devices while sending sms.
Android version
Android 4.0.3 - 4.0.4
This is the error report I'm getting
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1333)
at android.os.Parcel.readException(Parcel.java:1281)
at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:644)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:149)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:99)
at com.msh7.utilities.SMSSender$SMSProgressTask.doInBackground(SMSSender.java:87)
at com.msh7.utilities.SMSSender$SMSProgressTask.doInBackground(SMSSender.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
On line 87, I have this code
sms.sendTextMessage(destinationNumber, null, msg, sentPI, deliveredPI);
and all this method is inside the AsyncTask's doInBackground() method.
Could anyone please help me in this?
*Note : My App sends sms in the background and it's not a default sms app.
I guess it's due to over size limit of text. Max allowed characters are 159. So you have to divide message into parts and send it.
Dude you are getting NullPointerException. Seems like you have not initialized sms object.
Please check..
I am trying to use spring in my android app as client of my spring mvc REST application. I think I have a problem to put correct jars in classpath of my android app. I put the image of jars in libs folder of my android app. I found many related question on SO. But none of them helped me. That is why i am asking here again.
Here is how I am calling my webservice referenced from here :
#Override
protected SowResult doInBackground(Void... params) {
System.out.println("URLLLL : "+URL);
RestTemplate rest = new RestTemplate();
rest.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
SowResult result = rest.getForObject(URL, SowResult.class);
return result;
}
And the exception I am getting:
FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
Caused by: java.lang.NoSuchMethodError: org.codehaus.jackson.map.ObjectMapper.getTypeFactory
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType(MappingJacksonHttpMessageConverter.java:166)
at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.canRead(MappingJacksonHttpMessageConverter.java:101)
at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:542)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:474)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:237)
at com.inovarge.shoponway.resttasks.UserRestTask.doInBackground(UserRestTask.java:30)
at com.inovarge.shoponway.resttasks.UserRestTask.doInBackground(UserRestTask.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 4 more
The exception indicates that you are missing a required Jackson dependency. First, I recommend using MappingJackson2HttpMessageConverter instead of the MappingJacksonHttpMessageConverter which you've configured:
rest.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
Next, MappingJackson2HttpMessageConverter depends on the Jackson 2 library for its functionality, which requires the following files be on your classpath:
jackson-databind-2.3.2.jar
jackson-annotations-2.3.2.jar
jackson-core-2.3.2.jar
You already have jackson-databind-2.3.2.jar in your libs folder, so you need to download the other two jars.
Lastly, I highly recommend using a dependency management system like the Gradle plugin in Android's New Build System. It will handle downloading all the transitive dependencies for you instead of having to manually do that.
This question already has answers here:
RuntimeException: Unable to instantiate application
(14 answers)
Closed 8 years ago.
So I get this error from time to time. It's at the application launching from the Run button in Eclipse. this occurs once every 4-5 times.
Anyone has an idea what's going on.
I really appreciate it!
05-01 18:08:31.109: W/dalvikvm(15491): threadid=1: thread exiting with uncaught exception (group=0x40a311f8)
05-01 18:08:31.109: E/AndroidRuntime(15491): FATAL EXCEPTION: main
05-01 18:08:31.109: E/AndroidRuntime(15491): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.os.Looper.loop(Looper.java:137)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-01 18:08:31.109: E/AndroidRuntime(15491): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 18:08:31.109: E/AndroidRuntime(15491): at java.lang.reflect.Method.invoke(Method.java:511)
05-01 18:08:31.109: E/AndroidRuntime(15491): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-01 18:08:31.109: E/AndroidRuntime(15491): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-01 18:08:31.109: E/AndroidRuntime(15491): at dalvik.system.NativeStart.main(Native Method)
05-01 18:08:31.109: E/AndroidRuntime(15491): Caused by: java.lang.NullPointerException
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
05-01 18:08:31.109: E/AndroidRuntime(15491): ... 11 more
Looked into the ICS source code - It seems like for whatever reason the Package Manager can't get your package info - it could just be an eclipse/ADT bug where eclipse holds some kind of lock on the file, but whatever it is, it doesn't seem like something that you could cause with your code. I would suggest running a clean, uninstalling the app from the emulator/device, or if those don't work, you might try a fresh eclipse workspace.
Another thing that might be an issue is if you're using a Library project - try unlinking the two, cleaning, and then linking them back up again - but thats it for my bag o' tricks :)
UPDATE: yorkw gives a better explanation for why this occurs and its resolution here: RuntimeException: Unable to instantiate application
This is (unsurprisingly*) a bug in Eclipse/ADT/adb. I managed to fix it by uninstalling my app from the emulator. Hopefully it won't come back, but I'm not going to hold my breath.
*Seriously, Eclipse & ADT seem to be the buggiest pieces of software I've ever used. In only one day I've run into at least four different very annoying bugs! (This one, ddms broken pipe, workspace in use but it isn't, dex out of memory.) It's embarrassingly shoddy. Thank god we have stackoverflow!
Edit: I spoke too soon. The bug returns as soon as you run the app a second time.
I struggled with this error too.The error occurs inconsistently. Found out it was a library dependency that was not included in the build path for API level 16 (android-support-v4)
I also get this error when running my app on 4.x or above both emulator and actual device, but the error does not prevent my app to be launched, so I simply ignore it.
It also happens if you're trying to call new Intent(getActivity(), ActivityXY.class) when activity was finished and garabage collected. It's usually an indicator that you forgot to cancel some asynchronous operations when the activity/fragment was destroyed
This is an error from the .project file in your project. You can open other .project files on a project without errors for comparison. Almost, you can see wrong with <buildCommand> tag in this file.
I'm new to Android and App Engine, I'm trying to create an App Engine Connected Android Project, following the steps described here:
http://code.google.com/intl/es-ES/eclipse/docs/appengine_connected_android.html
but I'm not able to go through the "Say Hello" step (Run & Debug:7) using C2DM, since it prompts a SocketException ("Address family not supported by protocol") and sometimes a RuntimeException when debugging it locally... I don't get it, because I didn't customize the project yet, but after some debugging I saw that it was complaining about some libraries (included at the project creation) not having a source attachment... The most annoying part is that it complains about ThreadPoolExecutor.class, which belongs to java.util.concurrent in the Android 2.2 JAR... Weird, but anyway I attached the library to its source and it keeps complaining about the same class ("The source attachment does not contain the source for the file ThreadPoolExecutor.class")...
It seems to crash in the Util.getRequestFactory() method, at the execution of the first line. Here it calls a method in RequestFactorySource, which belongs to the requestfactory-client library, included at the project creation but again, without a source attachment... By the way, after executing that method call, the "task" variable is valued null, is it normal?
I guess it is about a small error in the configuration or something, but I've been struggling with it for days and I already don't know what to do, so any help would be appreciated :)
EDIT: I'm attaching the logcat output, I hope this makes it easier to find the bug. After googling I found out that it is a common error in the C2DM sample project, but I didn't get any appropiate solution.
I/C2dmftwActivity( 333): onCreate
I/ActivityManager( 58): Displayed activity com.c2dmftw/.C2dmftwActivity: 1281
ms (total 1281 ms)
D/dalvikvm( 126): GC_EXPLICIT freed 997 objects / 54032 bytes in 83ms
W/dalvikvm( 333): threadid=7: thread exiting with uncaught exception (group=0x4
001d800)
E/AndroidRuntime( 333): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime( 333): java.lang.RuntimeException: An error occured while exec
uting doInBackground()
E/AndroidRuntime( 333): at android.os.AsyncTask$3.done(AsyncTask.java:20
0)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerSet
Exception(FutureTask.java:273)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask.setException(
FutureTask.java:124)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerRun
(FutureTask.java:307)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask.run(FutureTas
k.java:137)
E/AndroidRuntime( 333): at java.util.concurrent.ThreadPoolExecutor.runWo
rker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 333): at java.util.concurrent.ThreadPoolExecutor$Worke
r.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 333): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 333): Caused by: java.lang.RuntimeException: The RequestFacto
ry ValidationTool must be run for the com.c2dmftw.client.MyRequestFactory Reques
tFactory type
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.impl
.Deobfuscator$Builder.load(Deobfuscator.java:59)
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.InPr
ocessRequestFactory.<init>(InProcessRequestFactory.java:80)
E/AndroidRuntime( 333): at com.google.web.bindery.requestfactory.vm.Requ
estFactorySource.create(RequestFactorySource.java:43)
E/AndroidRuntime( 333): at com.c2dmftw.Util.getRequestFactory(Util.java:
158)
E/AndroidRuntime( 333): at com.c2dmftw.C2dmftwActivity$2$1.doInBackgroun
d(C2dmftwActivity.java:144)
E/AndroidRuntime( 333): at com.c2dmftw.C2dmftwActivity$2$1.doInBackgroun
d(C2dmftwActivity.java:1)
E/AndroidRuntime( 333): at android.os.AsyncTask$2.call(AsyncTask.java:18
5)
E/AndroidRuntime( 333): at java.util.concurrent.FutureTask$Sync.innerRun
(FutureTask.java:305)
E/AndroidRuntime( 333): ... 4 more
W/ActivityManager( 58): Force finishing activity com.c2dmftw/.C2dmftwActivit
y
W/GTalkService( 170): [GTalkConnection.13] doConnect: caught XMPPError connecti
ng to mtalk.google.com:5228.: (502)
W/GTalkService( 170): -- caused by: java.net.SocketException: The operation t
imed out
I think I had the same problem. The Validation library was missing and after adding it manually it worked.
To add it or to check if it's included do:
Right click on your project > Properties > Java Build Path > Libraries Tab > Add External JARs
Then browser to your GWT installation folder. If you installed it with eclipse it's in eclipse/plugins/com.google.gwt.eclipse.sdkbundle_/gwt-/validation-api-1.0.0.GA.jar
Clean and build your workspace and try it again.
This could happen on the client GWT side too. If that happens you have to do the same but use your GAE project and add the same jar
This is the problem
Caused by: java.lang.RuntimeException: The RequestFacto
ry ValidationTool must be run for the com.c2dmftw.client.MyRequestFactory Reques
tFactory type
If you are using GWT 2.4+, you will have to run a validation tool. You can configure Eclipse to do this for you, here is how:
http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation