android source not matching jar, in eclipse - android

I'm using Android 4.0.3 (API 15). When I stop in the debugger and step into the source for Android, the source isn't matching - that is, I end up some arbitrary number of lines outside of the function I stepped into. It appears that the SDK manager is downloading a version of source slightly different than the jar.
I tried uninstalling the jar (through the Android SDK Manager) and reinstalling. Same problem.
The Manifest points to version 15.
The java Build Path (project - properties) shows version 15.
when I hover over the tab for the particular android source file, it shows the correct path.
What am I missing?
One more comment: in the Java Build Path, it automatically adds an entry called "Android 4.0.3" even though I already added "android.jar". Regardless, the source paths are correct.

The answer is obvious in retrospect :) The source you use to debug has to match the version on your device, not the minimum version. The trick was getting Eclipse to "let go" of its source setting so I could point it to the correct version.

Related

Android : R class stopped getting generated

I am a newbie to android programming .I was doing tutorial from Commsware tutorial , to be precise T3 tutorial during which I cleaned the project.After that R class file has stopped generating.
I deleted that project,looks like the same error is getting propagated to other new projects I am creating.
This error is coming for the newly created project also.
I tried all the solutions in stackoverflow like : cleaning project,selecting android version in build path , deleting my workspace,freshly install eclipse etc..
The other intimidating thing is my res folder does not show any errors and my xml file does not contain any capital letters.
It must be some silly error which is causing this?
Perhaps you should take a look at this if you've recently updated SDK tools.
After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools.
After installing this, clean your projects and rebuild.
this happened to me after updating the android dev kit and esclipse.
couple of things you should try.
if you updated ADT, you must restart ADB server. you probably haven't read the message that says after update. or maybe restart whole pc.
if you're using external jar files, rename the libs folder to lib and revert it back to libs (from eclipse, f2)
There seems to be a problem with the target build settings within your projects.
The R file will not be autogenerated if there is the slightest error in your project. E.g if you use elements in a layout xml file that are available only in Android 2.2 but your project targets android 2.0. Sometimes the offending elements don't show up as errors because, syntax-wise, they are correct.
I advice you look at your target builds in android manifest.
Or target a higher android build (Get the latest one via SDK manager)

I am geting an error while building android project?

gen folder is missing is the issue.The build patch failed .I have tried all solutions posted previously on this and no luck.
EDIT
To make it clear here is my original post
https://salesforce.stackexchange.com/questions/9460/encountering-issues-while-developing-android-hybrid-mobile-app
I am using salesforce SDK but when i am creating hello world app using native its working fine
Even if you delete the gen folder, it'll regenerate it after you compile your program.But if it is not then try creating a new project and try it again .If not , try a fresh installation of the API.
Update
Hmm, everyone in both posts is telling you to download the "SDK Platform" for "Android 2.2 (API 8)". I really, really recommend trying this. It is apparently required by the library you added to your project...
I have 4.2 and 4.1 .Is that not enough?
No, you must have the older platforms that you are building against.
Simply download it and open Project > Properties, click on Android, then select Android 2.2. After all this clean your project and save it.
Original Answer
The screenshot doesn't give us much detail, but:
Unable to Resolve target 'android-8'
Tells me that you probably don't have the SDK Platform for API 8, simply download this through the SDK Manager. Or you can change any references in your manifest and the rest of your code to use an API that you already have.
I think it is because when
you import a project, build
target is not set in the
project properties which
then default to the value
used in manifest file. and make sure you have API 8.
The solution is to enable
build target toward your
installed API level (but keep
the minimum api support as
specified in the manifest
file).

Every project says error after Android ADT update

I updated to the newest Android ADT and now every project in my workspace says error though there isn't any in the actual files. Even a clean Android project says error even though I have double checked all the preferences and I haven't found any fixes though I have investigated every possible help forum many times.
I have gotten many random error messages and here are just a few: "Current file is not a match for the given config.", "Conversion to Dalvik format failed with error 1" (not anymore), "Invalid preference page path: XML Syntax", "Failed to load properties file for project *" etc.
All my projects worked before updating.
None of the following works:
Cleaning the project, deleting the project and importing again, deleting libraries and temporary files and fixing project properties, unchecking the Is Library, updating the ProGruad, updating the Eclipse, moving Eclipse to C:\Eclipse, changing API levels and supported Android versions and so on...
I have fought with this problem for some time now.
EDIT:
The following things don't work either: Removing LibraryName_src files (my project has none).
EDIT:
I unchecked a checkbox in the general preferences which made Eclipse to delay the packing (I'll check the name of that checkbox later) and the current errors went away but now it says that "Could not find *.apk!"
I had weird errors too after updating my ADT plugin.
I solved it by performing an Android clear.
To do so just right click on yout Android project:
- Android tools
- Clear Lint Markers
It worked perfectly for me.
Recently had a similar problem. Try this:
Problem after recently after updating the ADT for Eclipse:
In your app project, check for any linked source folders pointing to your library projects (they have names in the form "LibraryName_src").
Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
Choose "Also unlink the folder from the project", and click "Yes".
Clean, rebuild and redeploy the project.
It seems the reason is that some previous version of ADT linked Library project source folders to the "child" projects, and the current ADT/Dex combination isn't compatible with that solution anymore.
(Solution found here: "Conversion to Dalvik format failed with error 1" on external JAR)
I solved it!
My jump from ADT 13 to 15 was too big. I backed up my workspace, removed everything releated to android and made a totally new SDK and Eclipse install.
After that I still got an error but deleting debug.keystore removed it.
I used Eclipse Indigo (version 3.7) and updated the CDT (instead of ADT) plugin to the latest version (cdt-master-8.0.1.zip). I experienced the same build path issues for all the existing projects that were working before I did the update. The issues that I faced were two folds:
The required source library link is missing from all the projects.
I lost my default Android SDK location in the Eclipse settings.
Here is how I fixed these two problems:
For Problem #1:
In Eclipse, click on the “Problems” tab to show the list of build errors.
Find an error that indicates certain class is not found. For example: “ClassABC cannot be resolved”
Double click on that error line would bring up the source code with the offending line, with a red dot x mark on the left edge of that offending line.
Double click on that red dot x mark would bring up a list of suggested solutions. At the bottom of the suggested list is the item of “Fix project setup…”.
Double click on the “Fix project setup…” would prompt you to add the link source library that is needed for the current project. Simply add that missing library to the project build path and click OK.
Now, do a “Refresh”, “Clean” and “Build Project” should give you a clear build, if nothing else causes errors.
For Problem #2:
In Eclipse, select from the menu bar “Window/Preferences…”, and then enter the missing Android SDK location. Click on OK button. That’s it.
These two steps basically restore all of my projects to the normal condition.
So if anyone is has been struggling with this after the latest ADT Plugin revision 22.
Be sure to install the Latest platform-tools as well.
To do this
Go to C:{Android SDK Location}\android\SDK Manager
And install the missing packages

Changing Android Project SDK level

I started writing my first Android app, and chose SDK 2.0.1, before I had an android phone.
I wantto test the app on a phone that is Android 1.6. The app itself uses pretty simple stuff, so I'm sure its 1.6 compatible, but I want to change the SDK level from Eclipse.
The "default.properties" file in my project tree and naively tried to change from Android 6, but it isn't changeable, but if I try to change it it tells me to change the build.properties of the project. I don't know what that means. I'm not used to eclipse and am still fumbling around it.
I went to the project properties and clicked on "Java Build Path", but from there I don't know how to add,remove or edit the libraries.
Basically, I'm asking how to downgrade my project from inside eclipse, so I can export it to a compatible phone.
You can actually keep the project's targetSDK at the same level, and just use a minSDK value.
What this means is that your application will target to build against a certain API, but it will let phones with lesser versions of Android than that API to also run the app. The catch is that you have to make sure you don't make any API calls that don't exist in the older versions of Android.
To change this, go to your AndroidManifest.xml and add the following inside of the xml node:
<uses-sdk android:minSdkVersion="3" />
This would set your minsdk to Android 1.5. Change it 4 for Android 1.6 and so on.
But if you really want to change the TargetSDK, right click on your project --> properties. Then click the Android tab on the left. Then check the box of the target API you want to build against.
Some more versioning info can be found here.
You can change your the Build Target for your project at any time: Right-click the project in the Package Explorer, select Properties, select Android and then check the desired Project Target.
PS : I'm on Eclipse Helios
http://developer.android.com/guide/developing/eclipse-adt.html

Move to SD Card

I've been following the post:
http://tut7.com/2010/06/15/quick-tip-enabling-the-android-%E2%80%9Cmove-to-sd-card%E2%80%9D-feature/comment-page-1/#comment-6766
(even tried to post a comment but it's been awaiting moderation forever)...
I'm trying to target Android 1.6-2.2 OSs and after applying your Build Target I get the following warnings:
Attribute minSdkVersion (4) is lower than the project target API level (8) AndroidManifest.xml /CueBrain line 1 Android ADT Problem
And also, trying to launch my app in the 1.6 emulator it just ignores it and runs the 2.2 emulator.
What am I missing?
Are you building within Eclipse? You need to set the target SDK version within the manifest file (like the post you referenced shows), and you also need to set it within the Project settings in Eclipse.
On the main menu, go to Project --> Properties
Select the Android page
Check the box next to the target SDK you would like to build against
You should see the correct Android version in the Package Explorer as library. Mine is listed as "Android2.2" beneath the "src" and "gen" folders.

Categories

Resources