Disable auto-import in eclipse? - General Questions and Answers

I'm trying to compile the open source Replica Island project and I notice that there are errors in the source. I see lines of code such as
setContentView(R.layout.main);
that give an error saying that R.layout.main cannot be resolved. So I look up at my import statements and see that it's importing android.R. Well there's the problem, that import statement is pointing to the wrong place. R.layout.main is in the general res folder structure, so the import is unnecessary. So I comment the import out and save the file...
and Eclipse "helpfully" puts the import statement back automagically.
I've been looking around in the panels to find where you can turn this setting off but have no luck so far. Where do you find the setting?

Related

SQL CE 3.5 - First App

I'm working on developing my first WM 6 App using SQL CE 3.5 . I'm sure there are other apps out there that do what mine does, but I'm just wanting the experience of developing it.
I'm working on a fairly simple app to track gas mileage and such. But, for some reason, whenever I debug it, the app can't seem to find the database file. I get an error saying: "The database file cannot be found. Check the path to the database. [ Data Source = .\GasTrackerDB.sdf ]"
I can browse with file explorer on the device and find the database in the same directory as the deployed application, so I'm not really sure where to go from here..
I'm doing everything through the IDE, so all of the code is generated for me to connect to the database.
Anybody experienced enough to help me troubleshoot this stupid problem?
i have been looking for an app that does the same thing as the one you are working on.
when it is finished please pm me. i wish i knew more programing, if i did i would help you.
Try
Code:
string database = string.Format(@"{0}\GasTrackerDB.sdf", GetApplicationPath());
public static string GetApplicationPath()
{
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
return path;
}
I did figure it out after messing around with it. I think it has to do with the way VS2008 deploys the app on the emulator...
When I hard-code the path to the database file, it works. So, my app will just have to be installed on the local device and not the SD card
Don't hard-code the path! The method GetApplicationPath() returns the application path. This is also important when installing on OS with different language.
heliosdev said:
Don't hard-code the path! The method GetApplicationPath() returns the application path. This is also important when installing on OS with different language.
Click to expand...
Click to collapse
How is that possible when the Connection String was generated by the IDE? Here's what the .xsd says:
Code:
<Connection ConnectionStringObject="Data Source=\program files\gastracker\GasTrackerDB.sdf" IsAppSettingsProperty="false" Modifier="Assembly" Name="GasTrackerDBConnectionString" ParameterPrefix="@" Provider="Microsoft.SqlServerCe.Client.3.5" />
On application start create the connection string "Data Source = " + database (like post #3)
This connection string can then be passed wherever you need to connect to the database.
That's the problem.. the IDE created all the stuff for the connection string and I don't know enough about it to create everything needed manually.
How do you connect to the db? What are you calling for retrieving data from db? How do you insert data to the db? All these actions need an object which somehow knows the connectionstring. And this string can/must be changed.
Hmm.. That doesn't seem to be a valid function name. I'm using .NET CF 3.5 .I'll keep looking.
Well, I wrote my own function to get the execution path, but I still can't figure out how to modify the connection string at runtime.
This crap is ridiculous. I don't understand why it doesn't "just work" when I let the IDE do everything...
Well, I FINALLY made it work.. i ended up going through the xsd file and changing all the code that creates queries. I had to replace every instance of:
Code:
CType(Me._commandCollection(0), Global.System.Data.SqlServerCe.SqlCeCommand).Connection = New Global.System.Data.SqlServerCe.SqlCeConnection("Data Source=.\GasTrackerDB.sdf;")
With:
Code:
CType(Me._commandCollection(0), Global.System.Data.SqlServerCe.SqlCeCommand).Connection = New Global.System.Data.SqlServerCe.SqlCeConnection("Data Source=" & GetAppPath() & "\GasTrackerDB.sdf;")
That had to be done for every one of my queries created through the designer. Thankfully I only had 5!
Great! Keep in mind that changes in generated code can get lost when the ide is recreating the code. Just keep an eye on it when doing changes in this area!
heliosdev said:
Great! Keep in mind that changes in generated code can get lost when the ide is recreating the code. Just keep an eye on it when doing changes in this area!
Click to expand...
Click to collapse
Yeah, I already ran into that one If it gets to be too much of a pain, I'll see if I can create some sort of compile time script to do a find and replace.. But I haven't spent enough time going back and fixing it yet
go to
http://www.connectionstrings.com/
They have everything you need to build your connection string. From my experience, it's okay to let the IDE build everything EXCEPT the connection string....

[Q] To which language does the following code belong to ?

Hey Guys,
Recently I was planning to learn to code android apps, so I decompiled an app I wanted to modify & was going through the source code. All of the .smali files were un-encrypted. I would like to know if this code is Objective-C or Java.
I tried to add the code snippets & also tried to pastie it but apparently the posts doesn't seem to accept foreign links so I'll try to post it in the comments.
File Names: h, h$a
Also, I wanted to know what do these file names represent & what does the "dollar" sign stand for in the file names.
Thanks in Advance,
Netguy
Update: I tried posting it via comments but it wasn't possible. Let me know how can I share the code over here. Thanks.
Smali is disassembled Dalvik virtual machine byte code.
The source of it is Java, although you can't easily reconstruct the original source.
MyClass.smali is the class file for MyClass
MyClass$SubClass.smali is the class file for the nested subclass SubClass
MyClass$1.smali is the class file for an anonymous nested subclass.
ab.smali and ab$bd.smali are obfuscated file names.
Some companies rename everything using automatic tools to hide the intent.
Yes, you can write in smali if you like.
Usually such use is limited to small changes in an existing program.
Thanks a lot for the information Renate NST. While digging through some of the smali files, I found some URLs related to the google ads. So will changing the URL to something else disable the ads or will it just result in malfunctioning of the app ? Thanks a lot once again.

Building an APK, could use a few pointers please?

If this is in the wrong section please delete/move. This seems the best fit to me. At any rate, Ive been using http://developer.android.com/training/basics/firstapp/building-ui.html to learn how to build an apk, but I havent found anything that shows how to import your own images and such. Id like to import my own background as apposed to the one provided by default. Any help is greatly appreicated!
Try this,
In the layout tag in the xml file, add this
android:background="@drawable/image">
and put the image.jpg or any other format in the drawable folder.
returns the error
[2012-08-26 23:46:09 - V.I.C.T.O.R.Y. TOOLS] /home/sniper_5/workspace/V.I.C.T.O.R.Y. TOOLS/res/layout/activity_victorytool.xml:1: error: Error: No resource found that matches the given name (at 'background' with value '@drawable-xhdpi/Background1').

Language Resources File

Please bear with me. I'm new to Android. But I'm a seasoned java developer. I have inherited a project with zero documentation that I'm trying to figure out. All of the text strings are retrieved from PreferenceManager and SharedPreferences. I put some debug statements in the method that retrieves the strings, and it is indeed finding a long JSON string with labels and values. But I cannot find the source for that. There is one strings.xml file in the res folder. But the strings.xml file is almost empty, and does not contain the labels/strings the app uses. I've grep'd the entire project (I believe) and I can't find any file with all of the labels/strings defined. I've done a clean rebuild, and this string is being built from somewhere. But no clue where it's finding it.
Can someone please help me? Where is the source file for this?
Thanks.
Jerry

Cannot Import Google Platform (AOSP) App's Java File to Android SystemUI Java File.

Hi all,
Excited to be a new member to this forum, seems like there is lots of powerful information here.
So, not the most clear title ever, but a specific example of my problem goes like this. If I want to take advantage of googles launcher3 src code such as CellLayout.java (packages/apps/Launcher3/src/com/android/launcher3/CellLayout.java) so I can play with the ability to reorganize the home screens app layout using the methods existing in that file. I would wish to import this CellLayout.java file so I can use it from a quick setting tile button's file, such as in the airplane mode tile.
In file frameworks/base/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java
So if I add the line "import com.android.launcher3.CellLayout;" in AirplaneModeTile.java, when I do a full AOSP build with the changes to the two files I get a compile time Error on the import code that "launcher3 cannot be resolved".
If I had to guess these two files are in different domains of sorts, and I think when I build using GNU make from the top directory, the Google App's code (h t tps:// android.googlesource. c o m /platform/packages/apps/) such as the AlarmClock, Contacts, Camera, and Launcher3 for example are built and then removed from scope at a different time than the Android systemui code.
Any thoughts on how to fix this?

Categories

Resources