I'm a beginner of Android Application development need to practice by examples and samples given in the book "Beginning with Android" by Wei Meng Lee, but whenever I try to follow those steps I come across a few errors unable to clean them. The Error seems like this:
" setContentView(R.layout.activity_main);" Don't know what type of error is it. In my computer I've installed SDK API level 16 that is for Android 4.1 What to do? Please guide me through appropriate answer.
Remove import
import android.R;
Than clean build your project also check xml layout file name in
setContentView(R.layout.activity_main);
than it'swork fine.
You should get the latest version of eclipse. Its now Eclipse Juno.
And check your import.
Remove
import android.R;
Instead put
import android.packagename.R;
Related
I have started using Android studio (intellij idea) for Android development (on Ubuntu 18.05) so I am very new to how it works and more used to visual studio :)
When I type a class name from Android API I note that ide mostly won't have suggestion as to which package to include. I find this to be a complete pain. For example if I type " ApiException aex;" IDE won't have any suggestions for what to include and will just report compile error.
I have various android libraries included in gradle and in the imports list so farily sure this class could be discovered by IDE (shouldn't this be java.lang.* or Google play services/GM's which I have in gradle?)
What is the easiest way to find which import I need for a class eg ApiException and is there a shortcut within Intellij to help with this?
Thank you
I'm trying to install the face book sdk and have all the projects showing up under my Package explore
Every project has almost evreyline of code as being a error.
I think the problem is that all the inports
except import java.io.InvalidObjectException; and import com.facebook.internal.Validate
have a error that says the import (name of inport) cannot be resolved. This is for both java sdk and android sdk.
I'm assuming if this is fixed all the remiaing errors will go away.
try this:
right click your project -> properties -> java compiler
select enable project specific , and select compiler comp level to 1.6
Perhaps this thread will help:
Android Facebook SDK import occurs with errors - Eclipse
I have searched through Stack Overflow as I know this is a common question, but none of the solutions seemed to work for me. This included cleaning my project, deleting all imports and deleting the project and starting again entirely.
I am using the Eclipse specifically for android on mac (ADT bundle mac).
Whenever I create a new project I have errors immediatley in my src folder on the line
setContentView(R.layout.activity_main);
and also on inflate.
Any suggestions other than those stated? It is literally before I have done any programming so cannot understand what is wrong.
EDIT: Fixed. Downloaded the SDK a second time and this seems to have fixed it.
import The R class. The basic syntax is
import your_application_package_name.R;
If you have already imported it but it is not working then check if there in any error in your resource xmls. If so then r can be not generated and that error will be shown
Change your Project Build Target to the Latest
Right Click Project > Properties > Android > Change the Api to latest version
Try to update the Android_SDK. When you create or import a new Android project the SDk builds the project. The R problem is mostly an update SDK problem.
I'm trying to get the Android LVL (App Licensing) setup to work with my software... and I cannot get it to import into Eclipse at all. The documentation says, "add the library folder to your workspace"... but it won't let me. I have rev. 2 downloaded... but when I try to import the project (from /android-sdk-macosx/extras/google/play_licensing/library) it shows up greyed-out in the projects list and won't import. Can someone please help me out here?
Just drag the sources into your project. The intention of the LVL is that you build your own sources and make changes (to try to thwart people that modify your binary by looking for LVL-specific bits).
We are new to Android and we are trying to develop a new application. We installed all the basic setup of Android. We tried to run the Android Sample projects in Eclipse. But while to compile the following lines and a few other lines that uses the variable 'R' throws up an error.
setContentView(R.layout.activity_main);
'R cannot be resolved to a variable'. I do not understand what is causing the error. Anyone help me out in this issue.
check that the import for R class is not
import com.android.R;
and you should make it
import yourpackagename.R;
then recompile
Please try to clean the project, and try compiling again.
If not solved, refer to R cannot be resolved - Android error
If you have 64 bit Linux platform without ia32 libraries, then this problem could also occur. It took me quite some time to pin this one down, seeing that the problem is not clearly linked with the inability to execute 32 bit code.
Just make the import part import com.android.R.layout instead of com.android.R
In my case i forgot to re-install the SDK. When you re-install your operating system, you should re-extract (re-install) your SDK Zip file.
Also check that you have your android libraries mapped correctly in the settings for Eclipse (if you are using eclipse to develop).
Check if your resorce name (for example template.xml) has ONLY small caps letters.
import com.packagename.R* will worl
Change import to
import yourpackagename.R;
If error is still there then
go to gen folder->packagename->R.java
and remove error line some times it gave error on drawable files.
setContentView(R.layout.activity_main)
Change the SDK and delete the project and create new ... it will definitely work!