I configured ActiveAndroid at AndroidManifest.xml as described below:
<application
android:name="com.xxx.xxxx.XXXApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
<meta-data
android:name="AA_DB_NAME"
android:value="MyDB.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="2" />
...
</application>
Application class:
public class XXXApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
Mode class is:
#Table(name = "Routes")
public class Route extends Model {
...
public static List<Routes> all(){
return new Select().from(Route.class).execute();
}
}
Ps: I follow the documentation:
https://github.com/pardom/ActiveAndroid/wiki/Getting-started
When call Routes.all() I got this error:
tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;'
Full stack is:
03-08 16:41:56.505: E/dalvikvm(23688): ERROR: tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;' (5)
03-08 16:41:56.505: I/dalvikvm(23688): "main" prio=5 tid=1 RUNNABLE
03-08 16:41:56.505: I/dalvikvm(23688): | group="main" sCount=0 dsCount=0 obj=0x41800508 self=0x417efce0
03-08 16:41:56.505: I/dalvikvm(23688): | sysTid=23688 nice=0 sched=0/0 cgrp=apps handle=1075560240
03-08 16:41:56.505: I/dalvikvm(23688): | schedstat=( 1596851683 269907401 1132 ) utm=148 stm=11 core=0
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.models.Route.all(Route.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity.onCreate(SavedRoutesActivity.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity_.onCreate(SavedRoutesActivity_.java:24)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Activity.performCreate(Activity.java:5206)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Looper.loop(Looper.java:137)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-08 16:41:56.505: I/dalvikvm(23688): at dalvik.system.NativeStart.main(Native Method)
03-08 16:41:56.505: E/dalvikvm(23688): VM aborting
03-08 16:41:56.505: A/libc(23688): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 23688 (o.mobile.xxxx)
This is late but could help someone else who faces the same problem.
This problem only occurs in debug mode, To solve it :
remove any watched expressions (In Debug View) that involve that unprepared class.
If you don't use that class in your code just remove it (which solve the first point too).
Hope it helps.
Did you remember to write a standard constructor for Route? E. g.
public Route(){
super();
}
And if you have your own Application class, it must be derived from com.activeandroid.app.Application:
public class Application extends com.activeandroid.app.Application {
…
}
If that doesn’t help, please post the signature of Route.
Related
I'm getting an ANR that seems to be from Toast.makeText:
DALVIK THREADS: (mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED | group="main" sCount=1 dsCount=0
obj=0x40163600 self=0x12620 | sysTid=4197 nice=0 sched=0/0
cgrp=default handle=-1345338264 | schedstat=( 149532214000 43042125000
324000 ) utm=13923 stm=1030 core=0 at
android.graphics.Matrix.native_create(Native Method) at
android.graphics.Matrix.(Matrix.java:49) at
android.view.View.(View.java:1852) at
android.view.View.(View.java:2411) at
android.view.ViewGroup.(ViewGroup.java:365) at
android.widget.LinearLayout.(LinearLayout.java:156) at
android.widget.LinearLayout.(LinearLayout.java:152) at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:416) at
android.view.LayoutInflater.createView(LayoutInflater.java:576) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.inflate(LayoutInflater.java:457) at
android.view.LayoutInflater.inflate(LayoutInflater.java:391) at
android.view.LayoutInflater.inflate(LayoutInflater.java:347) at
android.widget.Toast.makeText(Toast.java:230) at
android.widget.Toast.makeText(Toast.java:253) at
com.anthonymandra.framework.ViewerActivity.onActivityResult(ViewerActivity.java:802)
at android.app.Activity.dispatchActivityResult(Activity.java:4581) at
android.app.ActivityThread.deliverResults(ActivityThread.java:2814) at
android.app.ActivityThread.handleSendResult(ActivityThread.java:2861)
at android.app.ActivityThread.access$1000(ActivityThread.java:122) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:132) at
android.app.ActivityThread.main(ActivityThread.java:4123) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:491) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) at
dalvik.system.NativeStart.main(Native Method)
This is the line of code called from within onActivityResult:
Toast.makeText(this, R.string.save_success, Toast.LENGTH_SHORT).show();
Anyone know why a Toast might cause an ANR, or what might really be wrong if I'm misreading this? Thanks!
Instead of using direct call to R.string, you should use getResources() and then like below
String strSuccess = getString(R.string.save_success);
Toast.makeText(this, strSuccess, Toast.LENGTH_SHORT).show();
or
Toast.makeText(this, getString(R.string.save_success),Toast.LENGTH_SHORT).show();
Read more
I have an app in which I have
public class mainactivity extends Activity implements View.OnClickListener
{
...
and I declare it in that manifest. Everything compiles and runs perfectly. Then I change the class as follows:
public class mainactivity extends Activity implements View.OnClickListener , MoPubInterstitialListener
{
...
+ extra code to do with "mopub"
this new code compiles, but now, as soon as my splash screen activity shuts down and hands over to mainactivity, I see
03-08 10:47:40.380: I/dalvikvm(9013): Failed resolving Lcom/mycompany/myapp/mainactivity; interface 1127 'Lcom/mopub/mobileads/MoPubInterstitial$MoPubInterstitialListener;'
03-08 10:47:40.380: W/dalvikvm(9013): Link of class 'Lcom/mycompany/myapp/mainactivity;' failed
03-08 10:47:40.380: D/AndroidRuntime(9013): Shutting down VM
03-08 10:47:40.380: W/dalvikvm(9013): threadid=1: thread exiting with uncaught exception (group=0x40c7e1f8)
03-08 10:47:40.385: E/AndroidRuntime(9013): FATAL EXCEPTION: main
03-08 10:47:40.385: E/AndroidRuntime(9013): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.mainactivity}: java.lang.ClassNotFoundException: com.mycompany.myapp.mainactivity
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1891)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.access$600(ActivityThread.java:127)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.os.Looper.loop(Looper.java:137)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.main(ActivityThread.java:4511)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 10:47:40.385: E/AndroidRuntime(9013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
03-08 10:47:40.385: E/AndroidRuntime(9013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
03-08 10:47:40.385: E/AndroidRuntime(9013): at dalvik.system.NativeStart.main(Native Method)
03-08 10:47:40.385: E/AndroidRuntime(9013): Caused by: java.lang.ClassNotFoundException: com.mycompany.myapp.mainactivity
03-08 10:47:40.385: E/AndroidRuntime(9013): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-08 10:47:40.385: E/AndroidRuntime(9013): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.Instrumentation.newActivity(Instrumentation.java:1026)
03-08 10:47:40.385: E/AndroidRuntime(9013): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
03-08 10:47:40.385: E/AndroidRuntime(9013): ... 11 more
I'm at a loss as to how to proceed. If I try the debugger it appears that not even the first line of mainactivity.OnCreate() is executed.
EDIT: I have the following included in my manifest:
<activity android:name="com.mopub.mobileads.MoPubActivity"
android:configChanges="keyboardHidden|orientation"/>
Classpath
If this ring a bell, then read on.
Diagnosis:
It means the compiler find these classes during compile-time but this class is not found in your classpath during runtime
Medicine:
I've had this before and am not perfectly sure of the steps but let me put you in the right direcction.
If you're using ADT and eclipse, check your .classpath in your project.
check the build order in project->build properties
check if your jar is included in the build path
isLibraryProject
If the ComponentInfo is part of a library project, then it's a CardinalSin (seriously!) to include it in your build path manually. You are supposed to just add is a library project in project properties->android tab.
Did you define the MoPub activity in your Manifest?
<activity android:name="com.mopub.mobileads.MoPubActivity"
android:configChanges="keyboardHidden|orientation"/>
Go have a look at this link. It should solve your problem.
I had a similar issue and I checked on the android-support-v4.jar checkbox under Java Build Path - Order and Export.
When getting the list of packages which is running in devices, i am getting the execption proxy stub exception from my logcat
This the code i used
List packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
This the exception which im am getting
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40ab1478 self=0x112f910
| sysTid=1801 nice=0 sched=0/0 cgrp=default handle=1074439528
| schedstat=( 0 0 0 ) utm=465 stm=85 core=1
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.getInstalledApplications(IPackageManager.java:1930)
at android.app.ApplicationPackageManager.getInstalledApplications(ApplicationPackageManager.java:414)
at com.informate.smnpd.DataUsageAppManager.processData1(DataUsageAppManager.java:237)
at com.informate.smnpd.DataUsageAppManager.processData(DataUsageAppManager.java:114)
at com.informate.smnpd.BackgroundService.getData(BackgroundService.java:667)
at com.informate.smnpd.ManualUpdate.onClick(ManualUpdate.java:221)
at android.view.View.performClick(View.java:3526)
at android.view.View$PerformClick.run(View.java:14133)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697)
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:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
Can anyone please guide me on why this exception will occures at the time of getting installed package name. Thanks in advance
I took a look in the developer's console and saw for the first time a freeze report rather than a crash. A crash is easy to define the breaking point from the stack trace. It normally led to a class/method being incorrectly defined or implemented.
However I have never encountered a freeze. Since Google made the effort to make the distinction in the dev console, what is the distinction?
From a general point of view obviously a crash is a force close. But does a freeze simply slow down the user experience without a force close? What are the technical differences? Is there a different method to address a freeze when compared to a crash?
Edit: added example stack traces.
Here is an example of a Crash The stack trace is very specific pointing to a line of failure.
android.view.InflateException: Binary XML file line #21: Error inflating class android.widget.ZoomControls
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at android.widget.ZoomButtonsController.createContainer(ZoomButtonsController.java:262)
at android.widget.ZoomButtonsController.<init>(ZoomButtonsController.java:211)
at android.webkit.WebView.getZoomButtonsController(WebView.java:6313)
at android.webkit.WebView.startDrag(WebView.java:5700)
at android.webkit.WebView.onTouchEvent(WebView.java:5428)
at android.view.View.dispatchTouchEvent(View.java:3885)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
Here is an example Freeze the stack trace is less specific not pointing to a direct line or activity at fault.
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40027550 self=0xcfc0
| sysTid=2076 nice=0 sched=0/0 cgrp=bg_non_interactive handle=-1345006240
| schedstat=( 30958526727 7780212297 24174 )
at android.graphics.Bitmap.nativeCreateScaledBitmap(Native Method)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:556)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:722)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1727)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1998)
at android.widget.TextView.<init>(TextView.java:389)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)
at android.app.Activity.setContentView(Activity.java:1702)
at com.e3h.usmcknowledge.MainActivity.onCreate(MainActivity.java:37)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3242)
at android.app.ActivityThread.access$1600(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1037)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
There's really no formal definition. But broadly speaking, a crash occur when an uncontrolled error happens. Freeze is when an application stops to respond to any event (for example an infinite loop) but no actual error happens (no exception thrown).
In general, a crash is an unexpected, abnormal exit. A freeze or hang occurs when the program (or the entire system) stops responding entirely.
When I run my app in landscape mode it has no issues nor does it have any issues in portrait mode until i try to add an item to one of my lists while still in portrait mode, where of which my app crashes.
any ideas on how to fix this??
here is the error I am getting as feedback in logcat....
03-08 13:30:50.201: D/AndroidRuntime(554): Shutting down VM
03-08 13:30:50.201: W/dalvikvm(554): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-08 13:30:50.229: E/AndroidRuntime(554): FATAL EXCEPTION: main
03-08 13:30:50.229: E/AndroidRuntime(554): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ATG.C3FactSystemTabbed/com.ATG.EditActivities.AmenitiesEditActivity}: java.lang.NullPointerException
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.os.Looper.loop(Looper.java:132)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-08 13:30:50.229: E/AndroidRuntime(554): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 13:30:50.229: E/AndroidRuntime(554): at java.lang.reflect.Method.invoke(Method.java:491)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-08 13:30:50.229: E/AndroidRuntime(554): at dalvik.system.NativeStart.main(Native Method)
03-08 13:30:50.229: E/AndroidRuntime(554): Caused by: java.lang.NullPointerException
03-08 13:30:50.229: E/AndroidRuntime(554): at com.ATG.EditActivities.AmenitiesEditActivity.registerButtonListenersAndSetDefaultText(AmenitiesEditActivity.java:68)
03-08 13:30:50.229: E/AndroidRuntime(554): at com.ATG.EditActivities.AmenitiesEditActivity.onCreate(AmenitiesEditActivity.java:61)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
03-08 13:30:50.229: E/AndroidRuntime(554): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
03-08 13:30:50.229: E/AndroidRuntime(554): ... 11 more
this is the line that throws the exception
btnSave.setOnClickListener(new View.OnClickListener(){ <-------
#Override
public void onClick(View v){
. . . . .
}
});
this is only thrown when I am in portrait mode, it never gets thrown unless i change the orientation before trying to add something to the list. And if i already have the view open to add something no matter how i change the orientation it won't force close.
okay so i checked the files again i had different names for the buttons i was referencing in different xml files. In other words in landscape i was calling the button btnSave and in the other i was calling it btnAmenitiesSave. Problem solved thanks everyone!!!!!!
btnSave is set to null in portrait.
It means :
btnSave is not assigned ( no btnSave = findViewById(....) )
or the id the_id specified in btnSave = findViewById(R.id.the_id) does not exist in the portait layout