I have a problem with the Android projects in Eclipse.
I am working on Mac OS Lion and when I went to continue an Android project it gives me an error on the project icon. Moreover when I went to see the error Eclipse does not gives me an error anywhere in code.
What can I do to solve this problem? Any suggestions?
Thanks!
After a lot of work I have this problem now:
Eclipse it gives me error on override methods of class preference activity. for example for the code below:
#Override
public boolean onPreferenceClick(Preference preference) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// Show something if does not exit the app
dialog.dismiss();
}
});
}
I get the error: The method onPreferenceClick(Preference) of type new Preference.OnPreferenceClickListener(){} must override a superclass method
This problem is only on Mac OS X Lion. I don't know where is the problem. All tools are installed.
On windows is just fine on the other hand.
Do you have any idea where is the problem now ?
The common reason is a error in project. Recheck references for all jars and path to android-sdk
Try doing a Project --> Clean and see if that helps. Restart Eclipse too.
Ensure that you have installed all of the necessary SDKs/APIs in the Android SDK Manager. Perhaps the reason it works on your Windows machine but not your Mac is because your Mac does not have the necessary SDKs installed to ensure that your application compiles/builds.
Also, please post the errors that Eclipse is giving you... if you want others to help you solve the problem, I suggest you improve the quality of your question :).
Related
I have just created a react-native library using react-native-create-library and imported it into my master react-native project.
There are some issues I'm having because (honestly) I lack the knowledge.
The problem is that there are no errors (using logcat) and I don't know how I can debug the android part of my imported library.
Example
public class RNZappsCameraModule extends ReactContextBaseJavaModule
implements ActivityEventListener {
#ReactMethod
public void myJavascriptMethod() {
// I want a breakpoint here
// cameraIntent initialization happens here
try
{
currentActivity.startActivityForResult(cameraIntent, requestCode);
}
catch (ActivityNotFoundException e)
{
e.printStackTrace();
}
}
#Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)
{
// I want a breakpoint here
}
}
The camera intent starts fine, but I believe onActivityResult is never hit.
I know I could log everything and read it, but that won't explain why the result is never returned to my app since there are no errors in the first place.
Google and the official RN documentation are not being my friend at the moment, so please put me on the right track.
Found it.
No rocket science here. I don't know how I managed to do it in the end...
Anyheeew, to give this question a reasonable answer for passers-by...
First off, you need a react-native (master) project in order to actually run your library in a react-native context.
So create it and import your library. The easiest way to do this is by pushing your library into a git repository and adding your library in the package.json of you master project like this:
"react-native-your-package": "git+https://your-git-url-here",
Now install it: npm install react-native-your-package
In order to debug your library:
Open the android project of your react-native project in Android Studio
In menu => view => Tool window, click Build Variants
The new window displays the build types for you project and loaded modules
Click the Build Variant dropdown next to the module you want to debug and select 'debug'
Debug the master Android project
In the projects view, you can expand your module and place breakpoints where ever you like
Click the debug button and fix errors you never head of
I moved my Eclispe project to Android Studio, but it outputs a lot of deprecated errors when built. I tried some methods, but they don't work.
Try placing this at the top of the methods:
#SuppressWarnings("deprecation")
Example
#SuppressWarnings("deprecation")
public void testMethod(){
...
}
For a brief explaination go to this link:
https://stackoverflow.com/questions/7397996/what-is-suppresswarningsdeprecation-and-unused-in-android
Update:
It seems that there is also some known issues with deprecations. You might want to read this for more info:
stackoverflow.com/questions/26921774/how-to-avoid-deprecation-warnings-when-suppresswarningsdeprecation-doesnt
Situation:
I use Android studio, when i change a line of code in it sometimes it was wrong, the code i just change is not work it still run my old version code.
such as
int a = 1;//old version
int a = 2;//new version
sometimes a still value 1 when i run the new version code.
fix:
I know i can clean the project and restart Android Studio to fix it, but why it's happened?
My Question:
It's just a AS bug or something i was wrong in my project setting?
For more detail example:
I have class a with the method putLog() like below
private void putLog()
{
Log.i("tag","string");
}
Then i find i don't need the Log.i("tag","string") anymore, so i delete it
private void putLog()
{
// Log.i("tag","string");
}
but after i delete it, the log output is still there, my delete is not work.
I restart Android Studio and clean the cache, the log is not show anymore.
That's mainly because i have use multiple-channel gradle script to generate apk, now i remove it, it not show again.
I had many Android projects that were working fine in my old pc. now, when I tried to re import them, they are not running. Problem is that onClickListener is not working. Wherever there is onClick method, it throws an Error:
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method
My actual method is :
myBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//my code
}
});
What would be the problem?In every project wherever there is onClick method it shows the same.
Using my supehuman guessing powers I assume that you are using eclipse. Eclipse projects are not portable between machines as they contain absolute paths ( but that does not stop developers from checking them in into source control system ).
Your options are:
recreate eclipse project from sources
create maven build with android plugin and make it create you an fresh eclipse project
spring 150 bucks and buy you license for IntelliJ IDEA ( or just use free community edition which also has android plugins )
simply remove all #Override annotation above the onClick() methods
Goto project menu and clean the project.
Option 1: Simply remove all #Override
Option 2: In Eclipse -> Window -> Preferences -> Java -> Compiler, set "Compiler compliance level" to 1.6 or higher.
I reinstalled my computer and tried now to import my Android project into the workspace.
(File -> Import -> General -> Existing Project into Workspace)
But now I have got a strange error.
bNormal.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
gotoNextQuestion();
}
});
In the second line (#Override) eclipse always tells me there is an error:
/* Multiple markers at this line
- implements android.view.View.OnClickListener.onClick
- The method onClick(View) of type new View.OnClickListener(){} must override a superclass Method */
This happens everywhere, where #Override is used.
I already tried to Android-Tools -> Fix Project Settings and Project -> Clean.
I hope somebody can help me with this strange problem.
Thanks, Mark
It is because the language level is set to 5.0. Change it to 6, and all will work fine. Don't know where to set it eclipse, but in Idea it's File - Project Structure - Project Language level
It happens because OnClickListener is an interface and in 5th Java #Override can not be applied to a method implementation.
Your android SDK is probably not in the same path. Fix that in your eclipse settings.