2

Cloned android source of Alarm clock from git. imported to my eclipse found following errors:

Alarms.java: 
Line 463: Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED);
Error: ACTION_ALARM_CHANGED cannot be resolved or is not a field.
---------------------------------------

AlarmKlaxon.java
Line 89: mVibrator = new Vibrator();
Error: Cannot instantiate the type Vibrator
-----------------------------------

DigitalClock.java
Line 184: CharSequence newTime = DateFormat.format(mFormat, mCalendar);
Error: Call requires API level 3 (current min is 1):android.text.format.DateFormat#format

Line 167: mContext.unregisterReceiver(mIntentReceiver);
Error: mContext cannot be resolved
-----------------------------------

SetAlarm.java
Line 115: FrameLayout content = (FrameLayout) getWindow().getDecorView()
            .findViewById(com.android.internal.R.id.content);
Error:com.android.internal.R cannot be resolved to a variable

-----------------------------------

It is just not this application , any aplication that i clone from git android tree ... i am getting some error or the other. I dont know what i am doing wrong . I am targetting for jelly bean. and i also checked making build target as google API also but no use.

Sandeep Nagaraj
  • 2,122
  • 2
  • 12
  • 10
  • I figured this out, you cannot checkout individual project and build! (I know that's stupid) instead, you have to checkout the whole tree and build from root level – Sandeep Nagaraj Jan 11 '16 at 09:10

1 Answers1

1

Here's what you should do:

  • Start fresh, so delete that project and close Eclipse.

  • Download the source again

  • Open Eclipse, press Ctrl + N. This will open new project wizard.

  • Select Android and then Android Project From Existing Code.

  • Point the Root Directory to the DeskClock source. Consider checking Copy projects into workspace. This way when you edit the files, you won't edit the original source you downloaded, but the copy of it in your workspace.

  • Open the Manifest and set a minSdkVersion.

It'll probably be like this:

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="17" />
  • You'll need to add the android-support-v13 library. This can be found in the SDK.

The path will be something like this:

PATH_TO_YOUR_SDK\extras\android\support\v13

Once you have this, toss it in the libs folder in your project. If it isn't there, create one.

After you've done all that, you should clean your project if there are still any errors. You should also consider highlighting your project, pressing Alt+Enter selecting Android and changing the Project Build Target to the latest source.

Make sure you're using the right link when you clone the repo:

git clone https://android.googlesource.com/platform/packages/apps/DeskClock

Also, make sure you're pointing Eclipse to the right Android SDK directory. Go to Window --> Android and make sure the SDK Location is pointed to the correct path.

adneal
  • 30,484
  • 10
  • 122
  • 151
  • its not working i followed your comments exactly but no use ... still the same error persist – Sandeep Nagaraj Mar 24 '13 at 07:18
  • I made some edits at the bottom about cloning the latest source and doubling checking Eclipse is set up properly. – adneal Mar 24 '13 at 07:31
  • No use ... and the source is not Deskclock its alarm clock its android/platform_packages_apps_alarmclock – Sandeep Nagaraj Mar 24 '13 at 07:49
  • [In that case you'll need to follow instructions similar to these](http://devmaze.wordpress.com/2011/01/19/using-com-android-internal-part-5-summary-and-example/). And y'know that app is deprecated, right? DeskClock replaced it. It has the same features, but much more up-to-date source. – adneal Mar 24 '13 at 08:02