I used the search function for forums and Google to try and find an answer first, so this is either a somewhat unique issue... or I am very bad at searching.
I followed the instruction on the Android source site, using git to acquire the source, etc...
However I am having many, many issues when I load the source for Launcher into eclipse as a new project from existing source. Immediately upon load, I have 100 errors, the majority of which are as follows:
Code:
Description Resource Path Location Type
com.android.internal.R cannot be resolved Launcher.java Launcher/src/com/android/launcher line 865 Java Problem
ISearchManager cannot be resolved Search.java Launcher/src/com/android/launcher line 364 Java Problem
IWallpaperService cannot be resolved Launcher.java Launcher/src/com/android/launcher line 292 Java Problem
mBottom cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 80 Java Problem
mContext cannot be resolved LiveFolderAdapter.java Launcher/src/com/android/launcher line 144 Java Problem
mCursor cannot be resolved Search.java Launcher/src/com/android/launcher line 719 Java Problem
mLeft cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 80 Java Problem
mParent cannot be resolved LauncherAppWidgetHostView.java Launcher/src/com/android/launcher line 78 Java Problem
mRight cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 80 Java Problem
mScrollX cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 104 Java Problem
mScrollY cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 105 Java Problem
mTop cannot be resolved BubbleTextView.java Launcher/src/com/android/launcher line 80 Java Problem
SearchableInfo cannot be resolved to a type Search.java Launcher/src/com/android/launcher line 72 Java Problem
SearchManager.SOURCE cannot be resolved Launcher.java Launcher/src/com/android/launcher line 845 Java Problem
ServiceManager cannot be resolved Launcher.java Launcher/src/com/android/launcher line 291 Java Problem
STATUS_BAR_SERVICE cannot be resolved Launcher.java Launcher/src/com/android/launcher line 1119 Java Problem
StatusBarManager cannot be resolved to a type Launcher.java Launcher/src/com/android/launcher line 1119 Java Problem
The constructor Vibrator() is not visible DragLayer.java Launcher/src/com/android/launcher line 94 Java Problem
The import android.app.ISearchManager cannot be resolved Search.java Launcher/src/com/android/launcher line 19 Java Problem
The import android.app.IWallpaperService cannot be resolved Launcher.java Launcher/src/com/android/launcher line 78 Java Problem
The import android.app.StatusBarManager cannot be resolved Launcher.java Launcher/src/com/android/launcher line 24 Java Problem
The import android.os.ServiceManager cannot be resolved Launcher.java Launcher/src/com/android/launcher line 54 Java Problem
The import android.os.ServiceManager cannot be resolved Search.java Launcher/src/com/android/launcher line 34 Java Problem
The import android.server cannot be resolved Search.java Launcher/src/com/android/launcher line 35 Java Problem
The import com.android.internal.util.XmlUtils cannot be resolved LauncherProvider.java Launcher/src/com/android/launcher line 49 Java Problem
The method peekInstance() is undefined for the type InputMethodManager SearchAutoCompleteTextView.java Launcher/src/com/android/launcher line 44 Java Problem
I am using the cupcake branch in git, and have tried to have the project use both the 1.5 SDK or the Google SDK (1.5 with Google APIs)
If anyone has any ideas as to why this is occuring, I would very much appreciate it.
Also, I can write any original android programs I want using this eclipse setup, so I am sure I must have an issue related just with the Android Source.
Try clearing your local repo and specifying revision master or android-1.5
Well I wiped my local repo and tried it with both the master revision and android-1.5 revision. Unfortunately I am still encountering the same errors. I also redownloaded and reinstalled the current SDK, but that did not help either.
Also, it has the same errors in both my Windows 7 installation and Ubuntu installation.
Well I found a single related question on the google japan message board from Dianne Hackmann at Google:
You need to change the code to use the public SDK (calling the View
functions to get/set the scroll position etc).
Click to expand...
Click to collapse
This was just the answer for the origional posters question of how to get the variables such as mScrollX and mScrollY to work. Why would they develop on the private SDK, but require you to change all the code to be compatible with the public SDK if you wanted to compile android from source yourself?
How can I make my eclipse project error free for the Launcher application
This thread helped me in finding out an issue that I came across. I understand that in standard Android SDK, some classes and flags are not available where as during Android build time, they are available.
My question is, how can I build the launcher app using eclipse and not through the OS build process. I mean, how will my eclipse based Launcher project compiles without saying any error?
I too have the same problem. R is not autogenerated based on the code given. I have heard you have to Clean the project but that does nothing. Im using the same code from google compling under the 2.1 in eclipse indigo.
Related
Hello, Im trying to start some developing for the android, I am hampered by my inability to get the emulator to work, im sure im overlooking something basic, here is the error that generated.
invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
Hint: use 'foo' to launch a virtual device named 'foo'.
please use -help for more information
can someone help please relieve a noob of my frustration.
I have the same problem :/
Any help please?
Android AVD emulator connect problem
Similar to the previous two post, I also am unable to display my Helloworld App onto the AVD emulator skin.
The code is the traditional helloworld code:
package com.muo.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWord extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello Honeycomb Droid");
setContentView(R.layout.main);
}
}
The Eclipse Console runtime error is as follows:
[2011-11-30 21:29:23 - HelloWord] ------------------------------
[2011-11-30 21:29:23 - HelloWord] Android Launch!
[2011-11-30 21:29:23 - HelloWord] adb is running normally.
[2011-11-30 21:29:23 - HelloWord] Performing com.muo.helloworld.HelloWord activity launch
[2011-11-30 21:29:23 - HelloWord] Automatic Target Mode: Preferred AVD 'HVGA_4.0Skin' is not available. Launching new emulator.
[2011-11-30 21:29:23 - HelloWord] Launching a new emulator with Virtual Device 'HVGA_4.0Skin'
[2011-11-30 21:29:48 - HelloWord] New emulator found: emulator-5556
[2011-11-30 21:29:48 - HelloWord] Waiting for HOME ('android.process.acore') to be launched...
[2011-11-30 21:36:19 - HelloWord] emulator-5556 disconnected! Cancelling 'com.muo.helloworld.HelloWord activity launch'!
Eclipse Configuration
Java 1.6.0.29
Android 4.0
Window XP SP3
Please help... thanks!!
Author: Apriorit (Device Team)
Permanent link: apriorit(dot)com/our-company/dev-blog/62-marshalling-data-in-cf
In many situations when we create applications for different embedded systems or mobile platforms we can’t develop all parts of the product using managed code only.
For example we need several modules written in native language which perform some low level operations or we already have these libraries written on C++. So we have to use more than one programming language in our product and also use data marshaling in it.
In this article we will review some aspects of using data types and ways of using them during marshalling data to and from unmanaged code.
Making your interop calls more efficient
Marshaling is the act of taking data from one environment to another. In the context of .NET marshalling refers to transferring data from the app-domain you are in to somewhere else, outside.
You should remember that such Platform Invoke calls are slower than direct native calls and than regular managed calls. The speed depends on types marshaled between managed and native code, but nevertheless you should avoid using Platform Invoke calls if you have a chance to do this. Also it is recommended to use calls with some amount of transferred data than several “small” Platform Invoke calls.
Bitable types
It is recommended to use simple data types (int, byte, boolean, characters and strings). It makes the call more efficient and helps to avoid any convertions and copying. These blittable types have identical representation in both managed and unmanaged memory. But you should remember that in Compact Framework during marshaling boolean type is represented as 1-byte integer value (instead of 4-byte integer value in the full .NET Framework), character type (char) is always represented as 2-bytes Unicode character and String type is always treated as a Unicode array (in full .NET Framework it may be treated as a Unicode or ANSI array, or a BSTR).
Method Inlining
The JIT compiler can inline some methods in order to make the calls more efficient. You can not force a method to be inlined by the compiler, but you can make it NOT to be inlined. In order to avoid inlining you can:
• make the method virtual;
• add branching to the method’s body;
• define local variables in the method;
• use 2-bit floating point arguments (or return value).
Disabling method inlining can help to detect a problem during Platform Invoke calls.
Sequential layout
In the Compact Framework all structures and classes always have sequential layout (the managed value type has the same memory layout as the unmanaged structure). This behavior can be specified by setting attribute LayoutKind.Sequential. You don’t need to specify this attribute in Compact Framework, but if you use these pieces of code in both full .NET Framework and Compact Framework you have to set it to avoid different behavior on two platforms.
The following sample shows how to send some pointers from C# code for storing them in the native module.
Code C#:
Code:
[StructLayout(LayoutKind.Sequential)]
public class BasePointers // you can use the struct too
{
public IntPtr pointer1;
public IntPtr pointer2;
}
[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int TransferStruct(BasePointers pointers);
Code C++:
Code:
struct BasePointers
{
unsigned int pointer1;
unsigned int pointer2;
}
extern "C" __declspec(dllexport) int CDECL TransferArray(BasePointers*
pointers);
One Calling Convention
The Calling Convention determines the order in which parameters are passed to the function, and who is responsible for the stack cleaning. The .NET Compact Framework supports only the Winapi value (Cdecl on this platform) of Calling Convention. It defines the calling convention for C and C++ (instead of the full .NET Framework which supports three different calling conventions). To avoid crashes of your application you should make sure that your calling conventions in both managed and native declarations are same.
If you specify the attribute to preserve signature of functions ([PreserveSig]) then the returned value will contain 32-bit HRESULT value that will give you more data to analyze errors during the native function execution. The Calling Convention can be specified by adding the attribute CallingConvention to the declaration of your function. As it was mentioned the .NET Compact Framework supports only “Winapi” Calling Convention that corresponds to Cdecl:
Code C#:
Code:
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int ProgressEventHandler(int progressValue);
Code C++:
Code:
typedef void (CDECL *ProgressEventHandler)(int progressValue);
Data Alignment
In some situations we need to transfer data between the managed and unmanaged code in the structures. As it’s written above all structures have sequential layout in the Compact Framework, but you should remember about representation of structs in the managed in unmanaged code. The way of packing structures depends on a platform and on a way how the members of structure are aligned. On ARM platform this value for alignment is four (all values in structures are aligned to 4 bytes).
Code:
typedef struct OurStruct
{
unsigned char valueChar;
usingned int valueInt;
} ourStruct_;
This structure could be perfectly acceptable in desktop code, but if you use such structure on the Windows Mobile platform then you might receive valueInt at the offset 4. If you use such structures in both desktop and device's side code you have to use them carefully during marshaling.
During marshaling data you might receive such errors as “Datatype misalignment” (0x80000002) or “Access violation” (0x80000005). It indicates that you are using wrong pointers or try to access to the wrong offset of data. For example, you transfer array of bytes from C# code to the native module and define you functions as:
C# code:
Code:
[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int TransferArray(IntPtr src, int srcSize);
C++ Native Module code:
extern "C" __declspec(dllexport) int CDECL TransferArray(byte* srcArr,
int srcSize);
If you try to use the pointer “srcArr” as the pointer on integer (int*) and then try to use the corresponding value you will receive an error :
Code:
int value = *(int*)srcArr; // Datatype misalignment
The simple way to avoid this problem is to change declaration of C++ function and change the pointer on array of bytes to the pointer on array of integer and use it without any problems:
Code:
extern "C" __declspec(dllexport) int CDECL TransferArray(int* srcArr,
int srcSize);
Marshal class
You can use methods in the class Marshal to manually convert managed objects and perform conversions between IntPtrs. These methods are PtrToStructure, GetComInterfaceForObject, PtrToStringBSTR, GetFunctionPointerForDelegate and others. It allows you to control marshaling. These methods are also useful for debugging issues with marshaling parameters where the runtime is not able to convert a particular argument.
You cannot pass delegate directly to the native module as parameter of you function because the .NET Compact Framework does not support marshaling of delegates. Instead you should use method Marshal.GetFunctionPointerForDelegate for getting function pointer which you can pass to the native code and call it.
Code:
Code:
class MainClass
{
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate int ProgressEventHandler(int progressValue);
...
void OnProgressChanged(int progressValue)
{
...
}
…
…
[DllImport("NativeDLL.dll", CallingConvention = CallingConvention.Winapi)]
// Cdecl
public static extern int SetCallbackFunction(IntPtr functionPointer);
}
// Passing function pointer
Delegate d = new ProgressEventHandler(OnProgressChanged);
IntPtr progressChanged = Marshal.GetFunctionPointerForDelegate(d);
int result = SetCallbackFunction(progressChanged);
But you should be aware of Garbage Collector (GC) in such situation. The GC might collect you delegates and your function pointers will become invalid. It may happen when you passed the function pointer to the native code as callback method in order to call it later - GC might think that there are no references to it in the managed code. To avoid this situation you should keep reference to this delegate. For example, you can store it in the classes variable or create some delegates pool, in which you can keep references to the several delegates.
GCHandle
Since we're passing a pointer to some data we need to allocate memory for that data and make sure that the GC will not remove that memory. One of the possible ways to manage this situation is to use GCHandle.
If you want to pass some class (or array of bytes) to the unmanaged code and you need to pin memory for the proper work with it in the unmanaged code you can write:
Code:
class SampleClass
{
...
}
SampleClass classSample = new SampleClass();
GCHandle classHandle = GCHandle.Alloc(classSample, GCHandleType.Pinned);
IntPtr ptrToClass = classHandle.AddrOfPinnedObject();
int result = PassPtrToUnmanagedCode(ptrToClass); // our function
You can also make an instance of GCHandle as a member of the class to avoid deleting them by GC. Also you should remember that the structure is value-type. And pinning it to the memory will cause a problem, because structure will be copied and GCHandle will handle a reference to created “boxed” copy of the object. It will be hard to find such problem in the future.
Conclusion
During marshaling data you may face with the problems described above. Very often you may get “NotSupportedException” and other exceptions. To find a problem you can enable logging of setting the registry keys. One of the logging components is “Interop ”. The log provides information about Platform Invoke calls and marshaling. You can read MSDN for more information about Creating Log Files.
With the .NET Compact Framework 2.0 you can use Platform Invoke calls in managed application, even though there are a few limitations. You should remember all differences and limitations between full .NET Framework and the Compact Framework to avoid problems in your applications.
I have a problem with the application Casper
java.lang.illegalstateexception expected begin_object but was string at line 1 column 1 path $
I have created a Database class file to use SQLite db in Android app. Since I am beginner and I am having problem understanding what should i put in context when I instantiate Database class to another class The database code is as follows:
public Database(@nullable Context context) {
super(context,DATABASE_NAME,null,DATABASE_VERSION);
database=getWritableDatabase();
How can I instantiate it to an another class. When doing instantiation Database db = new Database(); what should be put under context
Database db =new Database(Combiner.this);. as well as Database db= new Database(this);I tried this but its showing Database(android.content,Context) in Database cannot be applied to (com.example.data.Combiner)
Are you sure that you require a context parameter in the construct function?
If it is unnecessary, just let it be null as it is nullable.
The command line client for Stagefright
https://android.googlesource.com/platform/frameworks/av/+/master/cmds/stagefright/stagefright.cpp
Is using MediaSource to play the Video.
How can I set MediaSource to be from byte array (char *), where I can specify it. I want to load the whole file from memory from array (very small video, not need for file streaming)
https://android.googlesource.com/pl.../master/cmds/stagefright/stagefright.cpp#1234
I think MediaSource is an Interface, it has read() methods etc, but nothing to consturct MediaSource from bytearray, char array (char *)
How can I construct proper MediaSource? So that I can just make
playSource(mediaSource);