I am trying to show one image from web service by consuming it.Well its working
fine.If i test my project with android versions like 2 - 3 versions its working fine.But it is not supporting over 4.0 and above. Why?
How to overcome this issue?
Following is my code,
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(img_url).getContent());
imgvw.setImageBitmap(bitmap);
Logcat
03-23 14:59:17.696: I/System.out(386): Intent { cmp=com.example.png/.tab_cameraActivity }
03-23 14:59:17.696: I/System.out(386): LB 3
03-23 14:59:17.716: D/AndroidRuntime(386): Shutting down VM
03-23 14:59:17.716: W/dalvikvm(386): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 14:59:17.736: E/AndroidRuntime(386): FATAL EXCEPTION: main
03-23 14:59:17.736: E/AndroidRuntime(386): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.png/com.example.png.tab_cameraActivity}: android.os.NetworkOnMainThreadException
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1577)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:130)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:342)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:680)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.widget.TabHost.setCurrentTab(TabHost.java:349)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:149)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:556)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.view.View.performClick(View.java:3100)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.view.View$PerformClick.run(View.java:11644)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.os.Handler.handleCallback(Handler.java:587)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:92)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:126)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:3997)
03-23 14:59:17.736: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 14:59:17.736: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 14:59:17.736: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 14:59:17.736: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 14:59:17.736: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
03-23 14:59:17.736: E/AndroidRuntime(386): Caused by: android.os.NetworkOnMainThreadException
03-23 14:59:17.736: E/AndroidRuntime(386): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
03-23 14:59:17.736: E/AndroidRuntime(386): at java.net.InetAddress.lookupHostByName(InetAddress.java:481)
03-23 14:59:17.736: E/AndroidRuntime(386): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:281)
03-23 14:59:17.736: E/AndroidRuntime(386): at java.net.InetAddress.getAllByName(InetAddress.java:249)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:304)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:292)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:274)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:217)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:76)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:153)
03-23 14:59:17.736: E/AndroidRuntime(386): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
03-23 14:59:17.736: E/AndroidRuntime(386): at com.example.png.tab_cameraActivity.getImagesDetails(tab_cameraActivity.java:73)
03-23 14:59:17.736: E/AndroidRuntime(386): at com.example.png.tab_cameraActivity.onCreate(tab_cameraActivity.java:57)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 14:59:17.736: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
03-23 14:59:17.736: E/AndroidRuntime(386): ... 18 more
You are getting exception.
NetworkOnMainThreadException: The exception that is thrown when an application attempts to perform a networking operation on its main thread.
so you have to use AsyncTask.
Here is example of AsyncTask.
http://android-developers.blogspot.in/2009/05/painless-threading.html
Chances are that you execute this code inside the UI Thread. This is prohibited in Android HoneyComb and above. You should consider using an AsyncTask or an Android Service to perform this request. Different options are available to help you with that. As a contributor of RoboSpice, I believe this library would help.
Related
Been struggling with andEngine and Google Game services integration for some time now. So I thought i would try my luck here.
I have done the steps described in multiple posts and blogs like this:
Issues in integrating Google Play Game Services Leaderboard in AndEngine Game
Using android studios and gradle
I have added BaseGameUtils(Android Sample), and extended the AndEngine BaseGameActivity and renamed GoogleBaseGameActivity. And then I have replaced BaseGameActivtiy with GoogleBaseGameActivity in my GameActivty(mainActivity)
The game runs before I do the extending and renaming.
MainActivity:
public class GameActivity extends GoogleBaseGameActivity
BaseGameActivity in BaseGameUtils(Google):
import org.andengine.ui.activity.BaseGameActivity;
public abstract class GoogleBaseGameActivity extends BaseGameActivity implements GameHelper.GameHelperListener
Logcat:
03-23 10:36:15.006 15860-15860/com.tdt4240.a19.mazegame I/Process﹕ Sending signal. PID: 15860 SIG: 9
03-23 10:51:33.826 17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ No implementation found for native Ldalvik/system/VMRuntime;.pauseGc:(Ljava/lang/String;)I
03-23 10:51:33.826 17012-17012/com.tdt4240.a19.mazegame E/ActivityThread﹕ Pause GC
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Native method not found: dalvik.system.VMRuntime.pauseGc:(Ljava/lang/String;)I
at dalvik.system.VMRuntime.pauseGc(Native Method)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
03-23 10:51:33.831 17012-17012/com.tdt4240.a19.mazegame I/PersonaManager﹕ getPersonaService() name persona_policy
03-23 10:51:33.856 17012-17012/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateEngineOptions() called
03-23 10:51:33.881 17012-17012/com.tdt4240.a19.mazegame I/PersonaManager﹕ getPersonaService() name persona_policy
03-23 10:51:33.896 17012-17012/com.tdt4240.a19.mazegame W/PopupManager﹕ You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
03-23 10:51:33.906 17012-17012/com.tdt4240.a19.mazegame I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzg
03-23 10:51:33.906 17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ VFY: unable to resolve virtual method 515: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
03-23 10:51:33.906 17012-17012/com.tdt4240.a19.mazegame D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
03-23 10:51:33.971 17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
03-23 10:51:33.976 17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
03-23 10:51:33.981 17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
03-23 10:51:33.981 17012-17012/com.tdt4240.a19.mazegame E/﹕ Device driver API match
Device driver API version: 23
User space API version: 23
03-23 10:51:33.981 17012-17012/com.tdt4240.a19.mazegame E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Mon Feb 10 15:44:10 KST 2014
03-23 10:51:34.036 17012-17012/com.tdt4240.a19.mazegame D/OpenGLRenderer﹕ Enabling debug mode 0
03-23 10:51:34.141 17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onPopulateScene() called
03-23 10:51:34.141 17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateScene() called
03-23 10:51:34.141 17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateResources() called
03-23 10:51:34.336 17012-17012/com.tdt4240.a19.mazegame D/AndroidRuntime﹕ Shutting down VM
03-23 10:51:34.336 17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41d0dc08)
03-23 10:51:34.336 17012-17012/com.tdt4240.a19.mazegame E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.tdt4240.a19.mazegame, PID: 17012
java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
at com.google.android.gms.common.internal.zzk$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzk$zza.zzi(Unknown Source)
at com.google.android.gms.common.internal.zzk$zzc.zzjg(Unknown Source)
at com.google.android.gms.common.internal.zzk$zzb.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
03-23 10:51:34.416 17012-17026/com.tdt4240.a19.mazegame D/dalvikvm﹕ GC_EXPLICIT freed 1537K, 32% free 5498K/8056K, paused 3ms+8ms, total 74ms
03-23 10:51:34.481 17012-17026/com.tdt4240.a19.mazegame D/dalvikvm﹕ GC_EXPLICIT freed 40K, 32% free 5494K/8056K, paused 6ms+3ms, total 50ms
03-23 10:56:34.371 17012-17012/com.tdt4240.a19.mazegame I/Process﹕ Sending signal. PID: 17012 SIG: 9
This happens when the app id is incorrect or at the wrong spot. For me I had to change my manifest from:
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="000000000000" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
to actually referencing it in the string.xml file. So it changed to this:
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
And then I put my app id in the strings class. I don't know why this was the case but that is what fixed it for me.
I have this exception:
java.lang.NullPointerException
at android.webkit.WebViewClassic.requestFocus(WebViewClassic.java:10003)
at android.webkit.WebView.requestFocus(WebView.java:2133)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2338)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2338)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:2382)
at android.view.ViewGroup.requestFocus(ViewGroup.java:2341)
at android.view.View.requestFocus(View.java:6538)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1899)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1110)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4918)
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:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
But it doesn't tell me what line it happened on or anything else. Any idea how to debug this?
Thanks,
Alex
I am trying to generate a dynamic table problematically It's working properly above API > 11 but its showing some error like this
05-06 12:35:30.303: E/AndroidRuntime(386): FATAL EXCEPTION: main
05-06 12:35:30.303: E/AndroidRuntime(386): java.lang.NoClassDefFoundError: android.app.ActionBar$LayoutParams
05-06 12:35:30.303: E/AndroidRuntime(386): at com.ica.icacounselor.Follow_ups_list_third_level.populateTable(Follow_ups_list_third_level.java:105)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.ica.icacounselor.Follow_ups_list_third_level.onCreate(Follow_ups_list_third_level.java:65)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:123)
05-06 12:35:30.303: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-06 12:35:30.303: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 12:35:30.303: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:507)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 12:35:30.303: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 12:35:30.303: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
My code follows
//--------------------------------------------------------------------------------------------------
// Creating Table Header
//--------------------------------------------------------------------------------------------------
TableRow followup_tr_head = new TableRow(this);
followup_tr_head.setId(10);
followup_tr_head.setBackgroundResource(R.drawable.list_header);
followup_tr_head.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
final TextView time_name_title = new TextView(this);
time_name_title.setId(20);
time_name_title.setText("Time");
time_name_title.setTextColor(Color.WHITE);
time_name_title.setPadding(5,5,5,5);
followup_tr_head.addView(time_name_title);// add the column to the table row here
time_name_title.setTextSize(12);
final TextView student_name_title = new TextView(this);
student_name_title.setId(20);
student_name_title.setText("Student Name");
student_name_title.setTextColor(Color.WHITE);
student_name_title.setPadding(5,5,5,5);
followup_tr_head.addView(student_name_title);// add the column to the table row here
student_name_title.setTextSize(12);
the ActionBar is presented in API 11. You can't use it in lower API levels.
Yes you can't use ActionBar below API level 11.
To use actionbar in lower api levels use ActionBarSherlock
I had imported import android.app.ActionBar.LayoutParams;
I should import android.widget.TableRow.LayoutParams;
I just did one of those auto updates of the Android SDK (API 15 r3) and associated SDK tools.
Eclipse updates for the plugin as well.
Now nothing I run works. Every application gives the same type of initialization error:
ExceptionInInitialization error.
I am unable to revert; re-installs, workspace cleanouts, etc. I cannot get rid of it.
Unfortunately it seems the previous versions that I had were overwritten and unrecoverable.
Does anyone have any idea what went so bad? (I don't know if I will ever dare to do an
auto update again. Comrades at work have also suffered the same catastrophe.
HERE IS A STACK TRACE WHICH I NEGLECTED TO ADD.
03-23 18:24:36.578: E/AndroidRuntime(3090): FATAL EXCEPTION: main
03-23 18:24:36.578: E/AndroidRuntime(3090): java.lang.ExceptionInInitializerError
03-23 18:24:36.578: E/AndroidRuntime(3090): at com.lampreynetworks.ahd.oilbath.MeasurementLogActivity.onCreate(MeasurementLogActivity.java:66)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.Activity.performCreate(Activity.java:4465)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.os.Looper.loop(Looper.java:137)
03-23 18:24:36.578: E/AndroidRuntime(3090): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-23 18:24:36.578: E/AndroidRuntime(3090): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 18:24:36.578: E/AndroidRuntime(3090): at java.lang.reflect.Method.invoke(Method.java:511)
03-23 18:24:36.578: E/AndroidRuntime(3090): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-23 18:24:36.578: E/AndroidRuntime(3090): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-23 18:24:36.578: E/AndroidRuntime(3090): at dalvik.system.NativeStart.main(Native Method)
03-23 18:24:36.578: E/AndroidRuntime(3090): Caused by: java.lang.NoClassDefFoundError: com.lampreynetworks.ahd.oxp.Nomenclature
03-23 18:24:36.578: E/AndroidRuntime(3090): at com.lampreynetworks.ahd.oilbath.MeasurementAdapter.<clinit>(MeasurementAdapter.java:82)
03-23 18:24:36.578: E/AndroidRuntime(3090): ... 15 more
There's been a change to the dependency management system. Xavier Durochet posted a Google+ item about it.
It looks like com.lampreynetworks.ahd.oxp.Nomenclature was in Referenced Libraries in your project. It now needs to be located only under Android Dependencies. You can remove the Referenced Libraries dependency from the Libraries tab under the project's Properties > Java Build Path
Also, the lib directory should be changed to libs.
In case the Google+ item gets deleted at some point, it links to a blog post and a post on tools.android.com which I am linking here for completeness.
Did you update the tools as well as the SDK? I believe that the new SDK requires ADT 17.
I'm getting a class cast exception namely
java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
when I'm trying to use the green droid library in my project.Here is the concerned code. I've been trying to figure out what is going wrong but still no luck. Any sort of help will be much appreciated. Thank you.
public class MainMenu extends GDActivity{
private QuickActionWidget mBar;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.mainmenu);
mBar = new QuickActionBar(this);
mBar.addQuickAction(new QuickAction(this, R.drawable.food, "food"));
Button foodButton=(Button)findViewById(R.id.food);
foodButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
mBar.show(v);
}
});
}
}
Here is my mainmenu.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:id="#+id/menu"
android:background="#drawable/menu"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:id="#+id/food"
android:layout_toRightOf="#id/menu"
android:background="#drawable/food"></Button>
</RelativeLayout>
</LinearLayout>
This my LogCat.
> 03-23 10:21:27.887: D/dalvikvm(395): GC_FOR_ALLOC freed 54K, 4% free 6389K/6595K, paused 48ms
03-23 10:21:27.937: I/dalvikvm-heap(395): Grow heap (frag case) to 10.253MB for 4096016-byte allocation
03-23 10:21:28.018: D/dalvikvm(395): GC_FOR_ALLOC freed <1K, 3% free 10389K/10631K, paused 47ms
03-23 10:21:28.128: D/dalvikvm(395): GC_CONCURRENT freed <1K, 3% free 10389K/10631K, paused 3ms+2ms
03-23 10:21:28.967: V/TLINE(395): new: android.text.TextLine#40654a10
03-23 10:21:36.497: D/AndroidRuntime(395): Shutting down VM
03-23 10:21:36.497: W/dalvikvm(395): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 10:21:36.507: E/AndroidRuntime(395): FATAL EXCEPTION: main
03-23 10:21:36.507: E/AndroidRuntime(395): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.ramada/com.bombil.ramada.MainMenu}: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.os.Looper.loop(Looper.java:132)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-23 10:21:36.507: E/AndroidRuntime(395): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 10:21:36.507: E/AndroidRuntime(395): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 10:21:36.507: E/AndroidRuntime(395): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 10:21:36.507: E/AndroidRuntime(395): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 10:21:36.507: E/AndroidRuntime(395): at dalvik.system.NativeStart.main(Native Method)
03-23 10:21:36.507: E/AndroidRuntime(395): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:21:36.507: E/AndroidRuntime(395): at greendroid.app.GDActivity.getGDApplication(GDActivity.java:205)
03-23 10:21:36.507: E/AndroidRuntime(395): at greendroid.app.GDActivity.onCreate(GDActivity.java:147)
03-23 10:21:36.507: E/AndroidRuntime(395): at com.bombil.ramada.MainMenu.onCreate(MainMenu.java:18)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 10:21:36.507: E/AndroidRuntime(395): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-23 10:21:36.507: E/AndroidRuntime(395): ... 11 more
03-23 10:22:58.089: D/dalvikvm(446): GC_FOR_ALLOC freed 55K, 4% free 6389K/6595K, paused 48ms
03-23 10:22:58.128: I/dalvikvm-heap(446): Grow heap (frag case) to 10.253MB for 4096016-byte allocation
03-23 10:22:58.207: D/dalvikvm(446): GC_FOR_ALLOC freed <1K, 3% free 10389K/10631K, paused 46ms
03-23 10:22:58.308: D/dalvikvm(446): GC_CONCURRENT freed <1K, 3% free 10389K/10631K, paused 4ms+2ms
03-23 10:22:59.317: V/TLINE(446): new: android.text.TextLine#40654d68
03-23 10:23:01.357: D/AndroidRuntime(446): Shutting down VM
03-23 10:23:01.357: W/dalvikvm(446): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 10:23:01.367: E/AndroidRuntime(446): FATAL EXCEPTION: main
03-23 10:23:01.367: E/AndroidRuntime(446): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.ramada/com.bombil.ramada.MainMenu}: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.os.Looper.loop(Looper.java:132)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-23 10:23:01.367: E/AndroidRuntime(446): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 10:23:01.367: E/AndroidRuntime(446): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 10:23:01.367: E/AndroidRuntime(446): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 10:23:01.367: E/AndroidRuntime(446): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 10:23:01.367: E/AndroidRuntime(446): at dalvik.system.NativeStart.main(Native Method)
03-23 10:23:01.367: E/AndroidRuntime(446): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:23:01.367: E/AndroidRuntime(446): at greendroid.app.GDActivity.getGDApplication(GDActivity.java:205)
03-23 10:23:01.367: E/AndroidRuntime(446): at greendroid.app.GDActivity.onCreate(GDActivity.java:147)
03-23 10:23:01.367: E/AndroidRuntime(446): at com.bombil.ramada.MainMenu.onCreate(MainMenu.java:18)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 10:23:01.367: E/AndroidRuntime(446): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-23 10:23:01.367: E/AndroidRuntime(446): ... 11 more
03-23 10:26:58.047: D/dalvikvm(490): GC_FOR_ALLOC freed 54K, 5% free 6311K/6595K, paused 100ms
03-23 10:26:58.097: I/dalvikvm-heap(490): Grow heap (frag case) to 10.176MB for 4096016-byte allocation
03-23 10:26:58.167: D/dalvikvm(490): GC_FOR_ALLOC freed <1K, 4% free 10310K/10631K, paused 39ms
03-23 10:26:58.267: D/dalvikvm(490): GC_CONCURRENT freed <1K, 4% free 10310K/10631K, paused 5ms+4ms
03-23 10:26:59.298: V/TLINE(490): new: android.text.TextLine#406513b8
03-23 10:27:07.167: D/AndroidRuntime(490): Shutting down VM
03-23 10:27:07.167: W/dalvikvm(490): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 10:27:07.177: E/AndroidRuntime(490): FATAL EXCEPTION: main
03-23 10:27:07.177: E/AndroidRuntime(490): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.ramada/com.bombil.ramada.MainMenu}: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.os.Looper.loop(Looper.java:132)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-23 10:27:07.177: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 10:27:07.177: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 10:27:07.177: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 10:27:07.177: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 10:27:07.177: E/AndroidRuntime(490): at dalvik.system.NativeStart.main(Native Method)
03-23 10:27:07.177: E/AndroidRuntime(490): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:27:07.177: E/AndroidRuntime(490): at greendroid.app.GDActivity.getGDApplication(GDActivity.java:205)
03-23 10:27:07.177: E/AndroidRuntime(490): at greendroid.app.GDActivity.onCreate(GDActivity.java:147)
03-23 10:27:07.177: E/AndroidRuntime(490): at com.bombil.ramada.MainMenu.onCreate(MainMenu.java:18)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 10:27:07.177: E/AndroidRuntime(490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-23 10:27:07.177: E/AndroidRuntime(490): ... 11 more
03-23 10:31:49.177: D/dalvikvm(567): GC_FOR_ALLOC freed 56K, 4% free 6389K/6595K, paused 47ms
03-23 10:31:49.227: I/dalvikvm-heap(567): Grow heap (frag case) to 10.253MB for 4096016-byte allocation
03-23 10:31:49.297: D/dalvikvm(567): GC_FOR_ALLOC freed <1K, 3% free 10389K/10631K, paused 40ms
03-23 10:31:49.398: D/dalvikvm(567): GC_CONCURRENT freed <1K, 3% free 10389K/10631K, paused 3ms+2ms
03-23 10:31:50.468: V/TLINE(567): new: android.text.TextLine#406405f8
03-23 10:31:52.377: D/AndroidRuntime(567): Shutting down VM
03-23 10:31:52.387: W/dalvikvm(567): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 10:31:52.398: E/AndroidRuntime(567): FATAL EXCEPTION: main
03-23 10:31:52.398: E/AndroidRuntime(567): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.ramada/com.bombil.ramada.MainMenu}: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.os.Looper.loop(Looper.java:132)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-23 10:31:52.398: E/AndroidRuntime(567): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 10:31:52.398: E/AndroidRuntime(567): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 10:31:52.398: E/AndroidRuntime(567): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 10:31:52.398: E/AndroidRuntime(567): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 10:31:52.398: E/AndroidRuntime(567): at dalvik.system.NativeStart.main(Native Method)
03-23 10:31:52.398: E/AndroidRuntime(567): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:31:52.398: E/AndroidRuntime(567): at greendroid.app.GDActivity.getGDApplication(GDActivity.java:205)
03-23 10:31:52.398: E/AndroidRuntime(567): at greendroid.app.GDActivity.onCreate(GDActivity.java:147)
03-23 10:31:52.398: E/AndroidRuntime(567): at com.bombil.ramada.MainMenu.onCreate(MainMenu.java:18)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 10:31:52.398: E/AndroidRuntime(567): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-23 10:31:52.398: E/AndroidRuntime(567): ... 11 more
03-23 10:32:23.498: I/Process(567): Sending signal. PID: 567 SIG: 9
03-23 10:32:31.847: D/dalvikvm(605): GC_FOR_ALLOC freed 57K, 4% free 6389K/6595K, paused 44ms
03-23 10:32:31.887: I/dalvikvm-heap(605): Grow heap (frag case) to 10.253MB for 4096016-byte allocation
03-23 10:32:31.967: D/dalvikvm(605): GC_FOR_ALLOC freed <1K, 3% free 10389K/10631K, paused 44ms
03-23 10:32:32.057: D/dalvikvm(605): GC_CONCURRENT freed <1K, 3% free 10389K/10631K, paused 3ms+2ms
03-23 10:32:32.857: V/TLINE(605): new: android.text.TextLine#40644090
03-23 10:32:43.418: D/AndroidRuntime(605): Shutting down VM
03-23 10:32:43.428: W/dalvikvm(605): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-23 10:32:43.438: E/AndroidRuntime(605): FATAL EXCEPTION: main
03-23 10:32:43.438: E/AndroidRuntime(605): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.ramada/com.bombil.ramada.MainMenu}: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.os.Looper.loop(Looper.java:132)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-23 10:32:43.438: E/AndroidRuntime(605): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 10:32:43.438: E/AndroidRuntime(605): at java.lang.reflect.Method.invoke(Method.java:491)
03-23 10:32:43.438: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-23 10:32:43.438: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-23 10:32:43.438: E/AndroidRuntime(605): at dalvik.system.NativeStart.main(Native Method)
03-23 10:32:43.438: E/AndroidRuntime(605): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication
03-23 10:32:43.438: E/AndroidRuntime(605): at greendroid.app.GDActivity.getGDApplication(GDActivity.java:205)
03-23 10:32:43.438: E/AndroidRuntime(605): at greendroid.app.GDActivity.onCreate(GDActivity.java:147)
03-23 10:32:43.438: E/AndroidRuntime(605): at com.bombil.ramada.MainMenu.onCreate(MainMenu.java:18)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-23 10:32:43.438: E/AndroidRuntime(605): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-23 10:32:43.438: E/AndroidRuntime(605): ... 11 more
03-23 10:37:43.477: I/Process(605): Sending signal. PID: 605 SIG: 9
I can only guess. Does you android app extends GDApplication ?
For example (in AndroidManifest.xml):
<application
android:icon="#drawable/ic_gdcatalog"
android:label="#string/app_name"
android:theme="#style/Theme.GDCatalog"
android:name=".CatalogApplication">
...
...
You should in your class do this:
public class CatalogApplication extends GDApplication {
#Override
public Class<?> getHomeActivityClass() {
return CatalogActivity.class;
}
#Override
public Intent getMainApplicationIntent() {
return new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.app_url)));
}
}
You can also download GDCatalog sample Application and run it in Eclipse.