Intellij not recognising drawable folders for android - android

I'm trying to set up a splash screen for PhoneGap in Intellij Community edition 11.12.
The problem is that Intellij gives me the error 'cannot resolve symbol splash' - for some reason it's not picking up R.drawable.splash - I've rebuilt the project and deleted the generated files, but that doesn't help.
I have the following folder structure (looks correct from http://developer.android.com/guide/topics/resources/providing-resources.html)
-res
--drawable
----splash.png
--drawable-hdpi
----splash.png
--drawable-mdpi
----splash.png
--drawable-ldpi
----splash.png
--drawable-xhdpi
----splash.png
And I'm trying to set the splash screen with:
package com.illbeintouch.mobile;
import android.R;
import android.os.Bundle;
import org.apache.cordova.DroidGap;
public class MyActivity extends DroidGap
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 5000);
}
}
I don't know if it makes a difference, but I'm using 1.7 Java SDK, and android 2.3.3 as the target platform.
If you can help out I'd be super grateful - I've spent all morning trying to sort this thing out!!!

You try to find splash in default R class:
import android.R;
Remove this import and import appropriate autogenerated R.

Related

setContentView(R.layout.main); - cannot find package

I have never used Android Studio before and have always been coding using NetBeans.
I need to create an app for Android, so I decided to use NetBeans. I created new project and it is 'empty' for now, however I have an error:
package Fridge.Freezer;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
The error is in setContentView(R.layout.main); - cannot find package. Can anyone tell what I am doing wrong? Clean and build does not work.
erase your package name at the top and try to add it to getting the suggestion package import by shortcut Control + Enter beside "R"
Try checking following component in your project directory
R.java file
folder named layout
layout xml file named main.xmlmain
PS Since your are starting a fresh project, I would suggest you to start at Android Studio.
I tried cleaning the project and rebuilding it again. It did not work. The solution was to restart IDE.

New->Android application Project created with a lot of errors(Android 6.0)

So when i create a new android application project with ANDROID 6.0 library i instantly get the a lot of errors in the MainActivity code.
Starting with The import android.support.v7.app cannot be resolved
To The method onCreate(Bundle) of type MainActivity must override or implement a supertype method
When i add the appcompat.v7 library obviously Some of the errors related are gone but other are coming instead. Like:
The type android.support.v4.widget.DrawerLayout$DrawerListener cannot be resolved. It is indirectly referenced from required .class files on the package line.
And still The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method.
Ok. So add the v4 jar too. Ok. I added it too to the project properties and no errors!
Wait,but when i run the app now I get a ClassNotFoundException.
So what the hell android 6.0???
Thanks for the help.
EDIT
MainActivity.java:
package com.minyan.get.dl;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The main reason is that Android Studio is the main IDE now.
Eclipse is no longer supported.
I suggest switching to Android Studio.

In Android Studio 0.8.6, all the import statements say Cannot Resolve Symbol?

import android.app.Activity;//activity is in red
import android.os.Bundle;//bundle is in red
import android.view.Menu;//menu is in red
import android.view.MenuItem;//Menuitem is in red
import android.widget.Button;//Button is in red
public class MyActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);//OnCreate is in red
//OnCreate is in red
It says it cannot resolve symbol for almost everything!
`
This seems to happen occasionally. Unfortunately, there are only a few things you can do.
First, try to clean the project...(Build -> Clean Project)
That, most likely, won't work. The next step would be to open your SDK manager (3rd button from the right) and download the latest build tools. This is very likely to work.
If that doesn't work, then you may just want to reinstall Android Studio. That's what I had to do two weeks ago.

How to use holoeverywhere in the intellij idea? Can I use the holoeverywhere in the finished project under 2.3?

I imported holoeverywhere like jar in project. But when I tried use theme, nothing not changed. What should I do to make it work?
package com.example.testholo;
import android.app.Activity;
import android.os.Bundle;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
setTheme(com.actionbarsherlock.R.style.Holo_Theme_Fullscreen);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
I also have a project under 2.3. How сan I use the holoeverywhere in the finished project under 2.3?
Open module settings - Libraries - + - From Maven - type org.holoeverywhere:library:1.5.0 - OK.
Specify some dirs and IDEA should automatically import and connect HoloEverywhere from the maven repo.
Also see a demo project - you are should use org.holoeverywhere.* classes, not android.*.

Missing R.java on Linux Eclipse Android project

I am running Eclipse Indigo with Android SDK 4.0.3 and Google API in Linux 11.10. However, when I start up a new Android project, my R.java is no where to be found, hence resulting in the following issue:
package com.lol.asdf;
import android.app.Activity;
import android.os.Bundle;
public class AsdfActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
I have tried all suggestion on this page but it's no good.
Anyone have any ideas?
your R.java is an auto generated class from the res/ folder. Check for error inside it. Try clean and rebuild your project too.
R.java will generated automatically...
first solve all other errors of your project it will be created...

Categories

Resources