How do I make Android backward compactible

Started by
9 comments, last by Strategy 8 years, 10 months ago

Hello,

I am developing my app with Android Java. Since i started many months, i was targeting version 4.1.2/4.2.2 devices. It works fine on these devices.

I am now trying run on a another device (galaxy S4) which has version 5.0.1. due to heap memory problems on previous devices

But on the new device it runs initially but at the touch of the switch intent button it is forced closed. This stage is breezed through very easily on 4.x devices, not even close to the stage were the memory problem begins to kick in

I managed to retrieve this error message from the very fast scrolling Logcat. But i don't know how to make use of it to help myself

07-02 00:28:39.900: E/SMD(25326): smd Interface open failed errno is 2 -1
Current manifest targets:
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
Initially i thought i need to set the manifest to a higher target for version , but google says on developer.android.com
To better optimize your app for devices running Android 5.0, set yourtargetSdkVersion to "21", .....
SO the correct target is already set for vs 5.0.1. I must be missing something.
How do i make my program run on this device, how do i target version 5.0.1?
Many thanks

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

Advertisement

Isn't this called "upward" compatible?

Which language and IDE do you use?

Every Logcat message has an appid. Normally ADT plugin automatically filters the messages of your currently running app but it seems this isn't the case for you.

Please filter the messages first and don't pick a random message from the universal logcat log.

I am using Eclipse IDE, and Android Java as stated

I know this is about setting the right device target because the program works fine, but there is no clues anywhere i can search on how to do this

100% sure its about something deprecated for version 5.0.1 , but i don't want to re-code for version 5.0 because that would be an awful lots and lots of re-coding

Anyone has an idea of how i can get this to work? I appreciate any suggestions, many thanks

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

I do not think your problem is the sdk version.

targetSDKVersion of 21 already means you are using 5.0 behaviour, on devices with this version installed

minSDKVersion of 16 means it will also run on anything from 4.1.

Even though things change slightly between versions, the changes are not that big, it is mainly that new APIs are added, so it is unlikely your application needs lots of change to work.

But first of all, you need to find out what is actually going wrong.

The best way to do this is to run the application from within eclipse in debug mode. Then you can set breakpoints and step through your program line by line, and make sure variables have the values they are supposed to have, and that all objects you try to create is created properly.

If there is a crash, it will likely stop and show you where in your program go wrong, and what exceptions.

Then you have to figure out why from there.

The E/SMD error message you see most likely has nothing to do with your application. Unfortunately logcat is very polluted by system services puking uninteresting information. (On one device I used, just starting a sound generated more then 30000 lines of debug output. yes, thirty thousands. unbelievable...)

Eclipse is supposed to show filtered logcat messages, but this does not always work. If not, you can filter it out yourself from running the command line tool "logcat"

Personally I use grep on OSX to filter.. (logcat | grep <process id>)

That number in parenthesis on the line is the process id of the application that generate the message.

Check what process id your application has when it starts up, and then use that to see what messages your application is showing.

Indeed, as I also said. Filter it!

Picking a random message from the universal log doesn't help.

I have overseen that you wrote "Java" and only read "Android" which could also mean C++, I am sorry.

If you are using Java I supposed you know how an error message normally looks like:


07-02 13:38:26.990: E/AndroidRuntime(1905): FATAL EXCEPTION: GLThread 9899
07-02 13:38:26.990: E/AndroidRuntime(1905): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
07-02 13:38:26.990: E/AndroidRuntime(1905):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
07-02 13:38:26.990: E/AndroidRuntime(1905):     at java.util.ArrayList.get(ArrayList.java:308)
07-02 13:38:26.990: E/AndroidRuntime(1905):     at com.google.liquidfun.look.LookDatabase.draw(LookDatabase.java:49)
07-02 13:38:26.990: E/AndroidRuntime(1905):     at com.google.liquidfun.look.Look.onDrawFrame(Look.java:181)
07-02 13:38:26.990: E/AndroidRuntime(1905):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
07-02 13:38:26.990: E/AndroidRuntime(1905):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
07-02 13:38:39.745: E/OpenGLRenderer(1905): SFEffectCache:clear(), mSize = 0

This is also the case for android. Without a real error message nobody can help you from those few information you provided.

Refer to @Olof Hedman to set up a filter correctly.

Many thanks @Hedman and @ iceCave

@ iceCave I didn't ignore your advice, i just didn't know how to do that

I know how to filter my own messages -
create a String tag = "myPrintOuts",
go to Logcat message filter settings and place the filter name and the tag
thus i can print:- Log.v( tag, "vvvvvvv"+myData);
In the command promt - direct the filter to a file
C:\users\name> adb logcat -s "myPrintOuts" > C:/logcat/file.txt
But i dont know how to filter Android own loads and loads of outputs
I have a fair idea though where it force closed because i have a UI button for switching activities (using Intent), instantaneously as i press that button (without any time lapse) it closes. Which never happened on previous devices.
But i will follow Hedman's advice using the debugger and be more specific so I will post afterwards

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

Mhm I see.

Rather use PID or your "Application Name" for the filter.

The ADT plugin normally uses automatically the Application Name.

The application name is the package your launcher activity is located in, you don't have to use the full package name if you are not sure.

So if your package is called "com.package.name.activitypackage" you can also just type "com.package" in the Application Name filter option.

Then start your application again.

Hope this helps :)

Best Regards

Thanks,

I have package com.example.liveideas;

Do i also put com.example as the filename field also? I tried placing com.example.liveideas as both filename and by Application name fields but it didn't work

I sometimes have a proper error dump http://www.gamedev.net/topic/669431-crash-on-one-device-but-not-the-other-what-could-be-the-cause/?view=findpost&p=5236328

but this time it switched to mass messaging

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

I finally got the error dump

07-02 14:19:40.444: E/AndroidRuntime(7609): FATAL EXCEPTION: main
07-02 14:19:40.444: E/AndroidRuntime(7609): Process: com.example.liveideas, PID: 7609
07-02 14:19:40.444: E/AndroidRuntime(7609): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
07-02 14:19:40.444: E/AndroidRuntime(7609):  at com.example.liveideas.Liveideas.snapDone(Liveideas.java:275)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at com.example.liveideas.Liveideas$6.onClick(Liveideas.java:169)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.view.View.performClick(View.java:5197)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.view.View$PerformClick.run(View.java:20926)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.os.Handler.handleCallback(Handler.java:739)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.os.Handler.dispatchMessage(Handler.java:95)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.os.Looper.loop(Looper.java:145)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at android.app.ActivityThread.main(ActivityThread.java:5942)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at java.lang.reflect.Method.invoke(Native Method)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at java.lang.reflect.Method.invoke(Method.java:372)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
07-02 14:19:40.444: E/AndroidRuntime(7609):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
07-02 14:19:43.727: I/Process(7609): Sending signal. PID: 7609 SIG: 9

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

Many thanks @IceCave .

I now fully know why its crashing with the new device. The code reads a couple of bitmaps which exist in the other devices but i haven't updated it to the new device

it clicked when i read this line

07-02 14:19:40.444: E/AndroidRuntime(7609): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

can't help being grumpy...

Just need to let some steam out, so my head doesn't explode...

This topic is closed to new replies.

Advertisement