I just started testing my app on android 1.5, and it doesn't want to run at all. I have a breakpoint in onCreate on my main activity, but I get a ClassNotFound exception even before reaching that. The class not found appears to be the class of my main activity. The exception happens in:
ActivityThread.performLaunchActivity
It runs fine on 1.6 and later, so I assume I'm using something that isn't supported on 1.5. But how can I find out what it is? Any tips on how to debug this would be greatly appreciated.
Thanks.
If you have imported jars, verify that they are in the /libs directory and not in the /lib directory and they are imported as jars and not as external jars
I had the same problem today. It's difficult to identify which class is not supported. The stack trace doesn't really shed any light on it, it just gives the somewhat misleading message that your activity class cannot be found. A couple API's that I have used that I know are not in Android 1.5 are:
- Bluetooth (2.0 and up)
- Text to Speech (1.6 and up)
I ran into this issue because I added support for text to speech to my app and didn't think to check the docs first to make sure text to speech is supported on Android 1.5. I was dismayed to learn it was only added in Android 1.6. To work around the problem I had to do a couple things:
Remove the "import android.speech.tts.*" from my activity
Create wrapper classes that mirror the text to speech API and call the real text to speech classes from there.
Put if statements around the calls to my wrapper class to make sure I only call out to it if the Android SDK level is 1.6 or above. You can check the Android SDK level by inspecting android.os.Build.VERSION.SDK
In your Android Market listing, indicate that the text to speech functionality is only available if you have Android 1.6 or higher installed.
The nice thing about this approach is that in the future, when I decide to abandon support for Android 1.5 I can easily change my calls to my wrapper class to just call the text to speech API directly and rip out the wrapper classes.
I did something similar for my Bluetooth code.
Related
Background
I wanted to simplify the usage of DB in an Android app.
For this, I've compared some third party libraries that create a DAO layer.
I've come up with a nice library called "GreenDao" (presentation about it here) . The website shows that it's faster than other competitors (like ORMLite) and is optimized for Android.
The problem
For some reason, on some device (usually old devices, with GB) , I get the next console error when trying to install the app:
Installation error: INSTALL_FAILED_DEXOPT
Please check logcat output for more details.
Launch canceled!
I've searched for the reason of this error, but couldn't find out how to solve it. Many complain about this error, but I can't find out why it occurs, and what can be done.
The error is quite common and known, but it's never mentioned as the result of using this library, yet when I remove the usage of this library, everything works fine...
Also note that on newer devices (like nexus 4) it installs and works just fine, and that the sample itself also works fine no matter which device I test it on.
The question
Why does it occur?
Is it possible that the structure of the classes is just too much for old devices to load, since we use other libraries ?
Could it be that I've reached the limit of code that is supported by android apps?
The jar file itself takes just 87KB ...
How can I solve this?
Ok, I've found the problem and the solution:
It has nothing to do with GreenDao.
It's because the app uses too many jars, so maybe Android has a limitation of code.
The solution is to either delete un-needed jar files or delete a lot of code.
I have task to modify android gingerbread launcher (2.3). I want to download launcher's sources and add some functionality. I have found sources here:
android Gingerbread launcher sources
I download this and import into workspace as is. As a result I get numerous compile errors (some classes are missing, instance variables are missing, etc). Why? I mean why wouldn't it compile? What should I do to make it compile?
P.S. By the way, when project is imported, used platform as per project settings is not 2.3, so I have to manually set it to 2.3. However, numerous errors still remain.
To convert an AOSP application into a standalone SDK application, you will need to find all the "classes and variable not present in the SDK" and remove/replace the references to them. The simplest is to remove the references to them, if the app will still run with reduced functionality. For references to internal resources, you can simply copy those to your project and modify the R values to point to your local copy. You are welcome to examine the "classes and variable not present in the SDK" and determine that you can copy those as well (refactoring them into a new package), in which case you would update your project to refer to the copied and refactored classes.
The easier solution would be to use someone's source where they already did that..Here found one at
Launcher2 full compilable Ginngerbread lancher code
Have a look at here.
It is the Launcher2 from ICS, not GB, but they are very similar.
From Wiki: Note that it is not completely bug free, and adding widgets will crash the app (as it uses a system level permission. Maybe if you installed via root it'll work).
Here's a list of what all I had to do, that I can recall doing:
There are lots of methods like setFastXXX (for example, setFastAlpha()) that aren't available to us. Changing these to setXXX (for example, 'setAlpha()`) worked for me.
Some thing which are available to us via getSystemService() are initialized directly in the code, like the usage of the Vibrator class. These need to be changed to use getSystemService().
I am implementing menus using TWL (http://twl.l33tlabs.org/) in an app written using Libgdx. The app runs fine if I don't start any menus, but as soon as I go to a menu screen it immediately force-closes. Menu screens work fine on the desktop version.
In which build path should TWL-android.jar be included (right now it behaves the same in main, android, and both)? And how will the program know to use the libraries from this .jar instead of the default gdx-twl.jar? Will I have to manually implement something in code to use one or the other depending on platform?
There does not seem to be any documentation or sample code of anyone using TWL on android, only mentioning that it can be done.
Running debugger attached to phone gives the following logcat error:
Could not find class 'com.badlogic.gdt.twl.Layout' referenced from method com.Nanners.OptionsScreen.<init>
I think that TWL-android.jar should be added to android project's build path too. Location of .jar is not relevant.
When you add TWL-android.jar. As that is Android specific you can't use it on the core project, so the classes you are importing are the ones from gdx-twl. To make it simpler to explain I will divide it in different escenarios.
You add TWL-android to your Android buildpath. But you use Gdx-twl in your core project. Which isn't added. Thus getting a:
Could not find class 'com.badlogic.gdx.twl.Layout'
You add both TWL-android AND Gdx-twl to your build path. Thus getting duplicated classes and:
Conversion to Dalvik format failed with error 1
Solution
If you use TWL-android classes, you can only do it inside the Android project:
Merge Core, Desktop and Android project. Or
Use Interfacing with Platform Specific
If you use Gdx-twl:
Don't do it.
Actually the best solution is to get rid of all twl stuff and use Scene2d.Ui instead. Its crossplatform and much easier to use.
Greetings all,
I realize this issue has been posed before in other forms, and believe me, I have been searching the net for days trying to find the answer. However, I'm fairly new to Android and Java, and I need a little guidance please.
I presently have two version of my app, one for Android 1.5 and 1.6, and another for 2.0 and beyond. As you probably guessed, it's because the Contacts API is different.
I recently became aware that it was possible to combine both methods into a single app, by using dynamically loadable classes. Very cool! After days of attempts, I still haven't been able to do it successfully... or at least, it won't run.
I have come across 3 examples of how to do this - one by Google, called "Business Card", another that had something to do with Spinners, and a 3rd was something someone here created. My problem is that each one seems to me to have a showstopper.
I'm using Eclipse on Windows 7. My app was first created for A1.5, so that's the one I'm upgrading. What's happening is that my ContactsAccessorNewApi class needs to import the ContactContracts, and according to Eclipse, that won't work because my project was originally built without support for it. Hence, it won't run. I've tried adding the android.jar for SDK level 5 into the project, but that creates a whole mess of other problems.
My code for this pat of my app is exactly like the Google example "Business Card" - so if someone could help me cross this hurdle, I'd be very grateful. I'll be happy to post any code that you need to answer my question.
Thank you!
another that had something to do with Spinners
If you mean this sample project, that's mine.
I'm using Eclipse on Windows 7. My app was first created for A1.5, so that's the one I'm upgrading. What's happening is that my ContactsAccessorNewApi class needs to import the ContactContracts, and according to Eclipse, that won't work because my project was originally built without support for it.
You need to set your build target (Project Properties > Android) to be high enough that ContactsContract exists (android-5 or higher).
So long as your android:minSdkVersion in your manifest is set to support earlier versions of Android (e.g., 3 for Android 1.5), your app will still install on older emulator AVDs and devices.
I've tried adding the android.jar for SDK level 5 into the project, but that creates a whole mess of other problems.
Yeah, don't do that.
I'm using the jexcel api in my android application. It works great on devices running Android 2.2, but any other device just gives a blank String when I try to get the contents of a cell.
I've narrowed the thing thats not working to the Cell.getContents() method in the jexcel api. All android version below 2.2 are able to get the workbook, get the sheets, get the number of sheets, and they can get the cells, but when trying to get the contents within that cell, it return a blank string.
Is there something wrong with the library, or is it an android problem
My guess is that FroYo added in support for some new Apache Harmony class or method (JavaSE-compatible) that JExcel depends on. In earlier versions, JExcel happens to catch the exception that's thrown and quietly fail. However, this is just a guess.
Since JExcel is open source, you could examine the source code to that method and see what turns up. Or, you could temporarily add the JExcel source code to your project (since I'm guessing you're using a JAR right now), and you'll probably get a compile-time error regarding the missing class or method.
This is all a guess, though.