Importing Android Source Code into an Eclipse Project

Take Android's Calculator (package com.android.calculator2; URL https://android.googlesource.com/platform/packages/apps/Contacts) as an example.

 

 

Since Calculator.java makes reference to anroid.support package by the following statements, you should include Android Support library for the project.

 

 

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
 

 

  • Right click on the project in the Project Explorer, choose Build Path>Configure Build Path.
  • On the shown dialog, choose Java Build Path and change to Libraries tab.
  • Click Add External JARs and choose android-support-v4.jar which by default is stored in extras\android\support\v4 under Android SDK root directory.

 

CalculatorEditText.java imports com.google.common classes, as a result of which you need to add google's guavalib.jar in External JARs.

 

import com.google.common.collect.ImmutableMap;

 

In addition, the Calculator module also makes use of javia package. So you need to delcare arity.jar in External JARs. Arity is an open source project hosted on google code.

 

In summary, declare arity.jarguavalib.jar and Android's android-support-v4.jar in External JARs, and you will be succeeded with making the project build.

 

 

 

 

你可能感兴趣的:(android)