How do I open this Android project in Eclipse? - android

https://github.com/android/platform_packages_apps_alarmclock
I have it cloned on my PC, and I tried to create a new project from existing source. I pointed it to the code I downloaded, but I had bunches of errors. I went into the project properties, and set the build target to Google API (8), and that fixed a lot of the errors, but I can't fix the remaining errors. This is my first time importing a project from github into Eclipse, so I am probably missing some simple fundamental steps.
Edit: adding error listing
I am down to 9 errors (some are dupes)
ACTION_ALARM_CHANGED cannot be resolved or is not a field in Alarms.java
Cannot instantiate the type Vibrator in AlarmKlaxon.java
com.android.internal.R cannot be resolved to a variable in AlarmKlaxon.java and SetAlarm.java
mContext cannot be resolved in DigitalClock.java (x5)

Somewhy in the project.properties the target was android-3 (target=android-3), write it to target=android-8, because a lot of layout xmls are using match parent. Then clean the project (Eclipse->Project->Clean...)
After this, no more xml errors will be there, but some java code errors remain, which are from use of com.android.internal.R which is a hidden android api?
This explains the use of it:
http://devmaze.wordpress.com/2011/01/19/using-com-android-internal-part-5-summary-and-example/

File -> import... -> existing projects into workspace -> select project

Related

Android - Exclamatory Mark Near Project Name

I recently updated by Android SDK and now if i create a new project, i see a Exclamatory mark near my project name.
I Tried the solution in below links.
Android:Error an Exclamation mark in my project how to resolve it
Android eclipse - Exclamation mark next to project name
After adding the correct library, i see R.java not getting generated. Tried cleaning and building the project multiple times. But still the same issue.
Need help on fixing this issue.
My Target SDK Version - 19 and min SDK Version is 8
Eclipse Version - 4.2.x
After adding the correct library, i see R.java not getting generated.
This implies that there is some error in your XML files.
Check the following in the order.
Name of all XML files should not contain capital letters.
In Values folder, in styles.xml file, try removing parent="Theme.AppCompat.Light"
After doing this, clean the project and build it. Check the Console window to see what error it throws. Make the corresponding change. It should fix your issue.
This is usually an issue with an XML file providing the libraries aren't throwing any errors. You can check the "problems" tab in Eclipse to see where the errors are coming from. Most likely, it's with an XML file and once you fix that error R.java should compile and your project will be fixed.

Android Studio cannot resolve R in imported project?

I'm trying the new Android Studio. I've exported a project from eclipse, using the build gradle option. I've then imported it in Android Studio. The R.java file under gen has a j in a little red circle on it. And in my source files, I get "cannot resolve symbol R" wherever I have a reference to a resource, e.g. "R.layout.account_list" etc.
I have never used Intellij before. Would appreciate any help as there obviously aren't many answer yet about Android Studio. Thanks!
Press F4 into Project Structure, Check SDKs on left
Click Modules ---> Source Tab, check gen and src as sources
PS: The answer over a year old and the menus have changed.
File -> invalidate caches
then
Restart application
None of the answers on the web so far have helped. Build > Make Project did not work for me. For me it was as simple as choosing this other option (on Android Studio 1.3.1):
Build > Make Module 'module name'
In my case I had an Activity file imported from Eclipse that had the line:
import android.R;
So all of my R classes were resolving to the SDK, as soon as I commented out that line everything compiled correctly to my package. I only noticed the issue when I was moving the project from my Mac to my Windows machine.
This issue starting occurring for me when I started working with build.gradle to incorporate the data necessary (signingConfigs) to build a signed .apk. After what appeared to be a successful build from the command line, I discovered that going into any class using R.* that all R.* references were unresolved.
The answers here didn't help me. I decided to re-import the project and it magically fixed the issue. File/Import Project... and select the build.gradle file in my apps root folder. I would love to know why re-import fixed this :)
This is probably due to a failed resource build
Once the issue is fixed, a mere Build > Rebuild Project will do the trick
Goto File -> Settings -> Compiler now check use external build
then rebuild project
I've been frustrated on many occasions with this problem, especially when intergating a project library as part of another project. In the most recent occurrence of this plagued problem, my Android lib project was using a WebView. It turns out that Gradle builds the R.class file in a sub directory called "web" whose path does not have anything to do with my source code path. When I imported this, my problem was gone. What have I learned? In the future, simply do a file search for R.class and note the path where it is located. Then import the package into your code using that path. It really sucks that you have to manually perform this. Gradle should automatically import packages it generates.
I was also facing the same issue and I went through lot of answer on stackoverflow. Then i found one solution which help me resolve this issue.
Check package name in AndroidManifest.xml file. I forgot to change it while copy pasting another project into new project.
At first check if there is import android.R; in top of your class this happens when auto import in enable in android studio.
after that comment all lines of your code that you use R variable (you can comment entire class or ...)
then run application it regenerates R variable and you can uncomment your code.
Here's what worked for me in IntelliJ (Not Studio), in addition to the replies presented above:
You need to attach an Android facet to an existing Android module. To do this, select the module from the module list in 'Module Settings', hit the '+' button on top and select 'Android'. See https://www.jetbrains.com/idea/webhelp/enabling-android-support.html.
The solution is to open project structure window. [by press command+; on mac ox s. i don't what's the key shortcut for other platforms. you should be able to find it under "File" menu.]
and click "Modules" under "Project settings" section, then your project is revealed, finally mark the generated R.java as Sources.
I am using Intellij idea 14.0 CE.
The generated R.java is located at build/generated/source/r/debug/com/example/xxx
Really not easy to find for the first time.
Follow the five steps below:
Step 1 ===>Delete(CTRL X) the additional tag(s) in XML manifest file.
Step 2 ===>Open Build-->Clean project.
Step 3 ===>Open XML manifest file and past the last additional tag(s) like:
Tag Manifest file example:
(<uses-permission android:name="android.permission.VIBRATE"></uses-permission>)
Step 4 ===>Step 2 again.
Step 5 ===> Open Tool-->Android-->Sync project with 'Gradle'.
I have had the same problem but after all the steps it's work for me.
On IntelliJ 14
Check if the generated sources are excluded. Usually in Project Structure -> [module] -> Paths -> Compiler output: "Inherit compile output path"
My problem was that I had file 'default.jpg' in drawable folder and for some reason every resource was not resolved. Fixed after deleting that file!
You should check all your files if it don't have errors and again rebuild your project in:
Build > Rebuild Project.
Or in:
File > Settings > Build, Execution, Deployment > Compiler
Check use external build and after rebuild the project.
After you tried Clean and Rebuild without success, check your res folder for corrupted files.
In my case a corrupted .png file caused all the trouble.
Regarding the following, from Crossle Song's answer
Press F4 into Project Structure, Check SDKs on left
Click Modules ---> Source Tab, check gen and src as sources
Despite the message "We will provide a UI to configure project settings later....etc" this worked for me.
None of these answers helped me!
My problem was not a problem! The program could compile completely and run on the device but the IDE has given me an annoying syntax error. It has underlined the lines of codes that included "R.".
The way that I could solve this issue:
I just added these three classes in "myapp/gen/com.example.app/" folder:
BuildConfig
package com.example.app;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
Manifest
package com.example.app;
public final class Manifest {
}
R
package com.example.app;
public final class R {
}
I solve that problem setting JAVA_HOME, CLASSPATH.
People sometimes skip JAVA_HOME and CLASSPATH when setting Java_path.
So try to check Environment Variable.
CLASSPATH -> .;
JAVA_HOME -> C:\Program Files\Java\jdk(version) or where Java installed
and then check the xml file which can have error(Do not naming well-known things such as button,text etc)
In my case (Linux, Android Studio 0.8.6 ) the following helps :
File > Project Structure > Modules > select main module > select its facet > Generated Sources
change value of "Directory for generated files:"
from
MY_PATH/.idea/gen
to
MY_PATH/gen
Without that code is compiled, apk is build and run successfully
but Android Studio editor highlights mypackage.R.anything as "cannot resolve" in all sub-packages classes
I had the same problem and got it fixed by deleting an extra library.
To do try this solution go to File > Project Structure (on a mac you can use the command "Apple ;")
Then select app on the left tab. Go to the dependencies tab and delete the extra library.
check the build tools version in build.gradle(for module app). Then go to android sdk manager see if the version is installed if not install it or change the build tools version to the one which is installed like below.
android {
buildToolsVersion "22.0.1"
..
..
..
}
The solution posted by https://stackoverflow.com/users/1373278/hoss
above worked for me. I am reproducing it here because I cannot yet comment on hoss' post:
Remove import android.R;
from your activity file in question.
My setup:
Android Studio 1.2.2
Exported project from one Mac to Git (everything was working). I then imported the project on another Mac from Git. Thats when it stopped resolving the resource files.
I tried everything on this thread:
invalidating cache and restart
Delete .iml files and .idea folder and reimport project
Clean and Rebuild project
Nothing worked except removing import android.R; from my activity java file.
To avoid this issue in the future add .idea folder to your .gitignore file. There is a nice plugin from git for gitignore in Android Studio. Install this plugin and right click in .idea > Add to .gitignore
just clean project and then sync your project with gradle file.
In my case, I found that "android.R.layout.account_list" was referenced instead of "R.layout.account_list". Simply remove "android." can fix the problem. Hope this help because sometimes you may overlook when you are too focusing.
In my case:
I had to Copy Reference the R file; i.e. right click gen/<package>/R and Copy Reference. Then paste that over the R in your code where it fails to resolve.
That solved it for me (after trying everything else here). Still not sure why it worked to be honest.
I had this same issue. The package name was wrong in two of the following three files. I manually updated the package name and everything started working again.
gen/com/example/app/BuildConfig.java
gen/com/example/app/Manifest.java
gen/com/example/app/R.java
I'm not sure what caused them to change as I've never modified these files before.
Had this error when importing project from Eclipse. The reason was some of the xml files had errors. Check ALL your XML files for errors. Including androidmanifest.xml, and values, themes, styles, layouts folders, etc. Warnings in xml are ok, but errors will generate this error.
Afterwards, do a Clean Project and rebuild.
For me, with Android Studio 1.5.1, the solution was to recreate the whole project with a slightly different name.
I think it didn't handle the app name "Kommentator_AS", because several places the package was named"Kommentator" instead.

Missing myProject.R file in android

It seams that I missing the R file, this is a common error and usually I have solved by cleaning the projects, using android tools fix project properties and restarting eclipse.
Now I have installed the new android developer tools eclipse and after importing the project I have this error in eclipse:
Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'MyProject'.
java.lang.NullPointerException
and the R file is not generated so it is missing.
The project is a library project. Thanks
Sometimes if you have errors in an XML file, it will stop the project from building correctly and the resources (project.R) file won't be created properly. You will also need to make sure that you are importing your resource file and not the one from android.R
If you've changed the project build target or minSdkVersion, you might have XML nodes in one of your layout files that isn't supported by the SDK you are using which will stop it from building. That's also worth checking
Go to Project and hit Clean. This should regenerate your R.java file.
Also get rid of any import android.R.* statements and then do the clean up as mentioned.
Otherwise, XML resource under layout may not having the correct naming convention or might be having some capital letters.
Try changing them to lowercase and make sure your layout.xml files don't contains errors.
Clean the project because the project may have trouble finding the name of a resources, it really sucks that i constantly have this problem when adding new image..

Converting Eclipse Java Project to Android Project

OK, first off, I HAVE read both Convert java project into android project on Eclipse and Convert java project into android project on Eclipse
but my problem here is a little different, and none of those solutions listed work at all. This is with Eclipse Classic 3.7.2
Basically, I'm doing a bit of collaborative work on a project that comes from subversion. I've been tasked with creating an Android branch. So I grab the eclipse project from subversion, and then it should be easy to change this project to Android, right? Except it seems to be anything but. I have tried all that has been listed. There is no convert button. If I try to create a new Android project from existing source, it says 'Eclipse project already found!', if I delete the .project it demands a manifest file, I create another android project and just copy the manifest file over, no go. Everything compiles, but then I get a lot of errors in logcat. The first one being "Failed to load properties file for project". I copy over the properties file, and I still get the error. Same thing occurs if I modify the nature in .project .
I just want this to convert this to an android project, get rid of any compile time errors that might occur due to a mismatch of libraries between Java and Dalvik, then upload it as a branch. I could potentially create a new java project and copy over source, but then I'm not entirely sure how I can upload that to subversion as a branch, since I'm not modifying the stuff I got from the repository...
Thanks for any help!
EDIT: In response to one supplied answer to create a new android project, and use existing source, this simply doesn't work. I point it to the directory of the Java non-android project, it tells me that a project already exists in that directory. I delete the .project file, then I get the error "Build path contains duplicate entry 'src' for project com_android_pdstore.
You can try creating a new android project and choose 'create project from existing source', I had this type of problem once, and that was the solution.
Right Clicking on the Project and then Android Tools ,click Fix Project Properties, could be an incompatible API build.

Eclipse Android project

I have a problem I can't seem to get around. I've created a project in Eclipse (I recreated it from another project that I thought was corrupted). There are no visible errors in any of the files, including the .xml files. However, the project root [project name] itself has an error (red 'x') and so I can't run it.
On a side note, in the default properties file the line:
target=android-4 is underlined in red with the note that 'android' is not spelled correctly. I have not altered this file since it was generated.
Any clues? Target is 1.6, sdk 4. And I'm new at this :)
You may have already tried this unsuccessfully, but if not, you might want to try the Android Tools > Fix Project Properties action from the context menu of the project root.
Eclipse also thinks android-4 is misspelled in my default.properties, so I doubt that is the cause of your build problem.
Does the Problems view describe any issues? (Window->Show View->Problems)
You could also try cleaning the project in eclipse. Project->Clean..
if the error message you get is
The project cannot be built until the build path errors are resolved.
this might help:
Open the Project -> Properties
Select Java Build Path -> Libraries
Add any new library (to be deleted later) -> OK
Wait for the workspace to refresh or force a refresh
The error should go away
Remove the dummy library
You can stop the spelling error by adding that word to a user dictionary, but a spelling error wouldn't prevent a run.

Categories

Resources