zoukankan      html  css  js  c++  java
  • 在Eclipse里查看java和android源码

    按ctrl再单击类名,或者双击选中类名再按F3,可以查看源码。

    这时如果看不到源码,出现"Attach Source..."按钮,点击它,
    1,如果是java源码,则选择jdk安装目录下的src.zip,但可能第一次要选的是目录,第二次才是全路径,比如: C:\Program Files\Java\jdk1.6.0_25\src.zip
    2,如果是android源码,先用Android SDK Manager把想要的"Sources for Android SDK"下载下来,选择放置的目录即可: D:\Program Files\AndroidSDK\sources\android-16
    ------------------------------------
    转一篇:Eclipse中查看源码,来自: http://blog.csdn.net/hanyankai/article/details/4891090

    Eclipse中要看到源代码, 分为两个部分
    (一):使用jdk源代码
    点 “window”-> "Preferences" -> "Java" -> "Installed JRES"
    2.此时"Installed JRES"右边是列表窗格,列出了系统中的 JRE 环境,选择你的JRE,然后点边上的 "Edit...", 会出现一个窗口(Edit JRE)
    3.选中rt.jar文件的这一项:“c:/program files/java/jre_1.5.0_06/lib/*.jar”点 左边的“+” 号展开它,
    4.展开后,可以看到“Source Attachment:(none)”,点这一项,点右边的按钮“Source Attachment...”, 选择你的JDK目录下的 “src.zip”文件
    5.一路点"ok",结束。
    (二)使用反编译工具查看class文件的源码(请参考http://java.decompiler.free.fr/?q=jdeclipse)

    使用jdeclipse反编译工具,先安装
    Equinox/p2 plug-in

    ,我的Eclipse包中已经带的有了。接着点击 help-->Install New Software-->Add-->Location中写入http://java.decompiler.free.fr/jd-eclipse/update,然后自己很容易搞定的,就是自动安装一个插件

    注: 试的时候,以上URL不可用,换一个: http://www.technoetic.com/eclipse/update

    ===================================================

    以上是导入包来看源代码的,下面是直接把整个安卓源代码android_2.3.1_r1导入eclipse工程:

    How to import Android Source code into Eclipse

    First, build the whole android source code in Ubuntu.

    Step 1, copy .classpath file to android folder:
    cd android
    cp development/ide/eclipse/.classpath ./
    chmod u+w .classpath

    Step 2, import format related files into eclipse: Preferences > Java > Code Style > Formatter
    android-formatting.xml and android.importorder are in this folder:
    development\ide\eclipse

    Step 3, modify the eclipse.ini file:
    -Xms128m
    -Xmx1024m
    -XX:MaxPermSize=512m
    or add line for polycaryon processor:
    -XX:+UseParallelGC

    Step 4, Create new eclipse work space, create new project or create the new project file:
    File→New→Java Project, DO NOT "use default location", use the android source root path.

    工程名称可以自己随便填,这里最重要的是不要使用默认的工程路径,不要沟选"use default location",要使用ANDROID的代码所在的顶层目录.


    Or (Not recommand) create .project file in the workspace folder:

    <?xml version="1.0" encoding="UTF-8"?>    
    <projectDescription>    
        <name>android_2.3.1r1</name>    
        <comment></comment>    
        <projects>    
        </projects>    
        <buildSpec>    
            <buildCommand>    
                <name>org.eclipse.jdt.core.javabuilder</name>    
                <arguments>    
                </arguments>    
            </buildCommand>    
        </buildSpec>    
        <natures>    
            <nature>org.eclipse.jdt.core.javanature</nature>    
        </natures>    
    </projectDescription> 

    // Skip if import at Step 4 already.

    Step 5, Import, Create project from existing source, and check the error,

    Change the .classpath file or do other modifications.

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

    ** After the import of the project source
    Errors occurred during the build.

    android 2.3.1r1

    Description Resource Path Location Type
    Project 'android_2.3.1r1' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar' android_2.3.1r1 Build path Build Path Problem
    Project 'android_2.3.1r1' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar' android_2.3.1r1 Build path Build Path Problem
    Project 'android_2.3.1r1' is missing required source folder: 'frameworks/base/awt' android_2.3.1r1 Build path Build Path Problem
    Project 'android_2.3.1r1' is missing required source folder: 'frameworks/base/common/java' android_2.3.1r1 Build path Build Path Problem
    The project cannot be built until build path errors are resolved android_2.3.1r1 Unknown Java Problem

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

    前面两个包,删了两行,添加了一行,

    后面2个文件夹,手动在目录生成。
    ====================================
    出现的问题:
    Project 'gingerbread' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar'
    Project 'gingerbread' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar'

    解决方法:
    .classpath 删除下面两行
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar"/>
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar"/>
    添加 <classpathentry kind="lib" path="/work/froyo/out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/>


    在eclipse中修改
    2.2.1. 通过create file from existing source 导入源代码
    2.2.2. 展开packages/providers/CalendarProvider/src
    2.2.3. 展开包: com.android.providers.calendar
    2.2.4. 右键点击包com.android.providers.calendar
    2.2.5. 选择 "new file"
    2.2.6. 在对话框中选择点击 "Advanced >>" 按钮, 可以看到"Link to file in the file system" checkbox,
    2.2.7. 勾选上 checkbox. 这时 "Browse..." 可用.
    2.2.8. 点击 "Browse..." 按钮,选择EventLogTags.java (e.g.,out/target/common/obj/APPS/CalendarProvider_intermediates/src/src/com/android/providers/calendar/EventLogTags.java)
    2.2.9. 点击OK
    2.2.10. 点击 Finish (in "New File")

    ** Other solutions:
    删除.classpath中的这两行路径
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar"/>
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar"/>
    添加
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/>
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/filterfw_intermediates/classes-jarjar.jar"/>
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/classes-jarjar.jar"/>
    --------- About android version unknown, so add only one line:
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/>

    Related links:
    http://m.blog.csdn.net/article/details?id=7966426
    http://bbs.csdn.net/topics/360137952

    How to config the eclipse:
    http://blog.csdn.net/chosen0ne/article/details/6885350 

    ==========================================================

    如下是导入android-5.1.1_r3源码到eclipse,这次错误比2.3.1多多了。

    Some errors from extracting tar.gz file due to path too long or folder name restrict. And also the .repo folder extract needs Administator privilege.

    ======== Extract Errors =========

    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.pde.api.tools.ee.cdcfoundation10_1.0.0.200901281111\org\eclipse\pde\api\tools\internal\api_stubs\CDC-1.0_Foundation-1.0.zip
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.pde.api.tools.ee.osgiminimum12_1.0.1.200904031014\org\eclipse\pde\api\tools\internal\api_stubs\OSGi_Minimum-1.2.zip
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.pde.api.tools.ee.osgiminimum10_1.0.0.200901281111\org\eclipse\pde\api\tools\internal\api_stubs\OSGi_Minimum-1.0.zip
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.pde.api.tools.ee.cdcfoundation11_1.0.0.200901281111\org\eclipse\pde\api\tools\internal\api_stubs\CDC-1.1_Foundation-1.1.zip
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.test.performance.ui\src\org\eclipse\test\internal\performance\results\ui\PerformanceResultsPreferenceInitializer.java
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\eclipse-basebuilder\basebuilder-3.6.2\org.eclipse.releng.basebuilder\plugins\org.eclipse.pde.api.tools.ee.osgiminimum11_1.0.0.200901281111\org\eclipse\pde\api\tools\internal\api_stubs\OSGi_Minimum-1.1.zip
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\libunwind\aux\ltmain.sh
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\libunwind\aux\config.sub
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\external\libunwind\aux\config.guess
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\out\target\product\generic\obj\STATIC_LIBRARIES\third_party_webrtc_modules_remote_bitrate_estimator_rbe_components_gyp_intermediates\third_party\webrtc\modules\remote_bitrate_estimator\remote_bitrate_estimator_single_stream.P
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\out\target\product\generic\obj\STATIC_LIBRARIES\third_party_webrtc_modules_remote_bitrate_estimator_rbe_components_gyp_intermediates\third_party\webrtc\modules\remote_bitrate_estimator\remote_bitrate_estimator_single_stream.o
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\fragment.properties
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\runtime_registry_compatibility.jar
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\META-INF\MANIFEST.MF
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\META-INF\ECLIPSE_.SF
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\META-INF\ECLIPSE_.RSA
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\.api_description
    ! E:\build_android-5.1.1_r3.tar.gz: Cannot create E:\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\

    E:\build_android-5.1.1_r3\prebuilts\eclipse\mavenplugins\tycho\tycho-dependencies-m2repo\org\eclipse\tycho\tycho-bundles-external\0.20.0\eclipse\plugins\org.eclipse.core.runtime.compatibility.registry_3.5.200.v20130514-1256\


    symbolic link E:\build_android-5.1.1_r3\build_android-5.1.1_r3\.repo\manifest.xml
    ! You may need to run WinRAR as administrator
    A required privilege is not held by the client.

    =========== Extract Error Ends ==========================

    Description Resource Path Location Type
    Project 'android_5.1.1_r3' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/libphonenumber-platform_intermediates/javalib.jar' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'external/icu/icu4j/main/classes/core/src' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'external/libphonenumber/geocoder/src' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'external/libphonenumber/internal/prefixmapper/src' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'external/libphonenumber/libphonenumber/src' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'frameworks/base/phone/java' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'libcore/tzdata/update/src/main' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/src/src' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/src/src/java' android_5.1.1_r3 Build path Build Path Problem
    Project 'android_5.1.1_r3' is missing required source folder: 'out/target/common/obj/JAVA_LIBRARIES/NfcLogTags_intermediates/src/src' android_5.1.1_r3 Build path Build Path Problem
    The project cannot be built until build path errors are resolved android_5.1.1_r3 Unknown Java Problem

    First line:
    change:
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/libphonenumber-platform_intermediates/classes-jarjar.jar"/>
    to be:
    <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javalib.jar"/>

    Change:
    <classpathentry kind="src" path="external/icu/icu4j/main/classes/core/src"/>
    To be:
    <classpathentry kind="src" path="external/icu/icu4c/source"/>

    Change:


    To be:
    existing : external/libphonenumber/java/src
    <classpathentry kind="src" path="external/libphonenumber/java/src"/>
    Delete:
    <classpathentry kind="src" path="external/libphonenumber/libphonenumber/src"/>
    // com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder missing,
    // download from here: http://repo1.maven.org/maven2/com/googlecode/libphonenumber/geocoder/2.17/ geocoder-2.17.jar
    // Resource '/android_5.1.1_r3/out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes-jarjar.jar' does not exist.
    // <classpathentry kind="src" path="external\libphonenumber\geocoder-2.17"/>
    // change the type to be lib: <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar"/>
    <classpathentry kind="src" path="external/libphonenumber/geocoder/src"/>
    <classpathentry kind="src" path="external/libphonenumber/internal/prefixmapper/src"/>

    Dlete:
    <classpathentry kind="src" path="frameworks/base/phone/java"/>
    <classpathentry kind="src" path="libcore/tzdata/update/src/main"/>

    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/src/src"/>
    to be:
    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/classes-jarjar.jar"/>
    Still error,
    => classes
    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/classes"/>


    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/src/src/java"/>
    to be:
    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes-jarjar.jar"/>

    delete:
    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/NfcLogTags_intermediates/src/src"/>
    -----------------------After changed:
    Description Resource Path Location Type
    incall_error_call_failed cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 253 Java Problem
    incall_error_emergency_only cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 271 Java Problem
    incall_error_no_phone_number_supplied cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 283 Java Problem
    incall_error_out_of_service cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 276 Java Problem
    incall_error_power_off cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 265 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 481 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 49 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved to a type CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 481 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved to a type GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 49 Java Problem
    support_swap_after_merge cannot be resolved or is not a field CdmaConference.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 170 Java Problem
    The import com.google.i18n.phonenumbers.geocoding cannot be resolved CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 34 Java Problem
    The import com.google.i18n.phonenumbers.geocoding cannot be resolved GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 24 Java Problem

    //----
    <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/classes"/>
    //-------
    Still 12 errors:
    Description Resource Path Location Type
    incall_error_call_failed cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 253 Java Problem
    incall_error_emergency_only cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 271 Java Problem
    incall_error_no_phone_number_supplied cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 283 Java Problem
    incall_error_out_of_service cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 276 Java Problem
    incall_error_power_off cannot be resolved or is not a field DisconnectCauseUtil.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 265 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 481 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 49 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved to a type CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 481 Java Problem
    PhoneNumberOfflineGeocoder cannot be resolved to a type GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 49 Java Problem
    support_swap_after_merge cannot be resolved or is not a field CdmaConference.java /android_5.1.1_r3/packages/services/Telephony/src/com/android/services/telephony line 170 Java Problem
    The import com.google.i18n.phonenumbers.geocoding cannot be resolved CallerInfo.java /android_5.1.1_r3/packages/apps/InCallUI/src/com/android/incallui line 34 Java Problem
    The import com.google.i18n.phonenumbers.geocoding cannot be resolved GeoUtil.java /android_5.1.1_r3/packages/apps/ContactsCommon/src/com/android/contacts/common line 24 Java Problem

    After importing geocoder-2.17.jar , Still 6 Errors: // All are
    add below in public static final class bool of com.android.phone.common.R file:
    public static int support_swap_after_merge;
    public static Integer incall_error_call_failed; //Similar in public static final class string
    // Below 5 are created in String class:
    public static Integer incall_error_call_failed;
    public static Integer incall_error_power_off;
    public static Integer incall_error_emergency_only;
    public static Integer incall_error_out_of_service;
    public static Integer incall_error_no_phone_number_supplied;

    After creating the fields in the R file, all errors are gone.

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

    Refer to: "Android platform Java development howto 03/04/15 (AOSP lollipop 5.1)" 

    URL: slowbutdeadly.blogspot.com/2015/02/android-java-setting-220215-lolipop.html

    3. I prefer to picking only needed files because non java project files can be burden.

    4. If project has jarjar-rules.txt file in the folder, java class path changed. That means we can not use the original sources for development because the class path is changed.

    List of projects have jarjar-rules.txt
    ./external/chromium_org/android_webview/build/jarjar-rules.txt
    ./external/okhttp/jarjar-rules.txt
    ./external/apache-harmony/jarjar-rules.txt
    ./external/bouncycastle/jarjar-rules.txt
    ./external/conscrypt/jarjar-rules.txt
    ./external/libphonenumber/jarjar-rules.txt
    ./frameworks/base/core/java/jarjar-rules.txt

    To pick up only needed files

    7z a -R java.7z *.java packages/apps/Calculator/arity-2.1.2.jar out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes-jarjar.jar  out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar  out/target/common/obj/JAVA_LIBRARIES/libphonenumber-platform_intermediates/classes-jarjar.jar  out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-jarjar.jar  out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar  out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar  out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar  out/target/common/obj/JAVA_LIBRARIES/mockito-api_intermediates/javalib.jar  out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar  out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar  out/target/common/obj/JAVA_LIBRARIES/junit-runner_intermediates/javalib.jar


    To install 7z in ubuntu.

    sudo apt-get install p7zip-full

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

    Refer link: http://www.cnblogs.com/larack/p/4629156.html

    参考了一下这里jar missing Error的处理,但是发觉并不需要解压,Ubuntu编译之后,jar包已经有了,把路径改对就可以了。

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

    总结一下android-5.1.1_r3的导入,

    1. Given .classpath is outdate. Use the .classpath from "http://webcache.googleusercontent.com/search?q=cache:PEVyPD2JmhYJ:slowbutdeadly.blogspot.com/2015/02/android-java-setting-220215-lolipop.html+&cd=2&hl=zh-CN&ct=clnk&gl=us"
    Refer link: https://source.android.com/source/using-eclipse.html

    2. Change the eclipse.ini to be:

    -Xms256m
    -Xmx1024m
    -XX:MaxPermSize=768m

    3. and import the format file as before.
    4. project -> properties -> Resources (Windows OS)
       Text file encoding -> UTF-8
       New text file line delimiter -> Other: Unix

    5. project -> properties -> Java Compiler
       Enable project specific settings -> checked
       Compiler compliance level: 1.7 (Because AOSP is now Open JDK7 based)


    6. Adjust the .classpath file according to the errors.
    Download geocoder-2.17.jar from here: http://repo1.maven.org/maven2/com/googlecode/libphonenumber/geocoder/2.17/
    Import the jar, and modify the .classpath file, pay attention to type "src" and "lib".

    7. Refresh the project, automatically re-build. And OK now.

    Below is my modified file (base on the one above mentioned):

    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
        <classpathentry kind="src" path="packages/apps/Email/provider_src"/>
        <classpathentry kind="src" path="packages/apps/Bluetooth/src"/>
        <classpathentry kind="src" path="packages/apps/Browser/src"/>
        <classpathentry kind="src" path="packages/apps/Bluetooth/lib/mapapi"/>
        <classpathentry kind="src" path="packages/apps/Calendar/src"/>
        <classpathentry kind="src" path="packages/apps/Calendar/extensions_src"/>
        <classpathentry kind="src" path="packages/apps/Calculator/src"/>
        <classpathentry kind="src" path="packages/apps/CertInstaller/src"/>
        <classpathentry kind="src" path="packages/apps/Contacts/src"/>
        <classpathentry kind="src" path="packages/apps/ContactsCommon/src"/>
        <classpathentry kind="src" path="packages/apps/Dialer/src"/>
        <classpathentry kind="src" path="packages/apps/Email/src"/>
        <classpathentry kind="src" path="packages/apps/Email/emailcommon/src"/>
        <classpathentry kind="src" path="packages/apps/HTMLViewer/src"/>
        <classpathentry kind="src" path="packages/apps/InCallUI/src"/>
        <classpathentry kind="src" path="packages/apps/Launcher2/src"/>
        <classpathentry kind="src" path="packages/apps/Mms/src"/>
        <classpathentry kind="src" path="packages/apps/PackageInstaller/src"/>
        <classpathentry kind="src" path="packages/apps/PhoneCommon/src"/>
        <classpathentry kind="src" path="packages/apps/QuickSearchBox/src"/>
        <classpathentry kind="src" path="packages/apps/Provision/src"/>
        <classpathentry kind="src" path="packages/apps/Settings/src"/>
        <classpathentry kind="src" path="packages/apps/UnifiedEmail/src"/>
        <classpathentry kind="src" path="packages/apps/VoiceDialer/src"/>
        <classpathentry kind="src" path="packages/providers/CalendarProvider/src"/>
        <classpathentry kind="src" path="packages/providers/ContactsProvider/src"/>
        <classpathentry kind="src" path="packages/providers/DownloadProvider/src"/>
        <classpathentry kind="src" path="packages/providers/MediaProvider/src"/>
        <classpathentry kind="src" path="packages/providers/TelephonyProvider/src"/>
        <classpathentry kind="src" path="packages/services/Telecomm/src"/>
        <classpathentry kind="src" path="packages/services/Telephony/src"/>
        <classpathentry kind="src" path="packages/services/Telephony/common/src"/>
        <classpathentry kind="src" path="packages/services/Telephony/sip/src"/>
        <classpathentry kind="src" path="packages/services/Telephony/tests/src"/>
        <classpathentry kind="src" path="frameworks/base/cmds/am/src"/>
        <classpathentry kind="src" path="frameworks/base/cmds/input/src"/>
        <classpathentry kind="src" path="frameworks/base/cmds/pm/src"/>
        <classpathentry kind="src" path="frameworks/base/cmds/svc/src"/>
        <classpathentry kind="src" path="frameworks/base/core/java"/>
        <classpathentry kind="src" path="frameworks/base/drm/java"/>
        <classpathentry kind="src" path="frameworks/base/graphics/java"/>
        <classpathentry kind="src" path="frameworks/base/keystore/java"/>
        <classpathentry kind="src" path="frameworks/base/location/java"/>
        <classpathentry kind="src" path="frameworks/base/location/lib/java"/>
        <classpathentry kind="src" path="frameworks/base/media/java"/>
        <classpathentry kind="src" path="frameworks/base/media/tests/MediaFrameworkTest/src"/>
        <classpathentry kind="src" path="frameworks/base/media/mca/effect/java"/>
        <classpathentry kind="src" path="frameworks/base/media/mca/filterfw/java"/>
        <classpathentry kind="src" path="frameworks/base/media/mca/filterpacks/java"/>
        <classpathentry kind="src" path="frameworks/base/nfc-extras/java"/>
        <classpathentry kind="src" path="frameworks/base/obex"/>
        <classpathentry kind="src" path="frameworks/base/opengl/java"/>
        <classpathentry kind="src" path="frameworks/base/packages/FusedLocation/src"/>
        <classpathentry kind="src" path="frameworks/base/packages/Keyguard/src"/>
        <classpathentry kind="src" path="frameworks/base/packages/SettingsProvider/src"/>
        <classpathentry kind="src" path="frameworks/base/packages/SystemUI/src"/>
        <classpathentry kind="src" path="frameworks/base/policy/src"/>
        <classpathentry kind="src" path="frameworks/base/rs/java"/>
        <classpathentry kind="src" path="frameworks/base/sax/java"/>
        <classpathentry kind="src" path="frameworks/base/services/core/java"/>
        <classpathentry kind="src" path="frameworks/base/services/accessibility/java"/>
        <classpathentry kind="src" path="frameworks/base/services/print/java"/>
        <classpathentry kind="src" path="frameworks/base/services/backup/java"/>
        <classpathentry kind="src" path="frameworks/base/services/devicepolicy/java"/>
        <classpathentry kind="src" path="frameworks/base/services/appwidget/java"/>
        <classpathentry kind="src" path="frameworks/base/telecomm/java"/>
        <classpathentry kind="src" path="frameworks/base/telephony/java"/>
        <classpathentry kind="src" path="frameworks/base/test-runner/src"/>
        <classpathentry kind="src" path="frameworks/base/wifi/java"/>
        <classpathentry kind="src" path="frameworks/ex/camera2/public/src"/>
        <classpathentry kind="src" path="frameworks/ex/common/java"/>
        <classpathentry kind="src" path="frameworks/ex/variablespeed/src"/>
        <classpathentry kind="src" path="frameworks/opt/calendar/src"/>
        <classpathentry kind="src" path="frameworks/opt/chips/src"/>
        <classpathentry kind="src" path="frameworks/opt/colorpicker/src"/>
        <classpathentry kind="src" path="frameworks/opt/datetimepicker/src"/>
        <classpathentry kind="src" path="frameworks/opt/net/ims/src/java"/>
        <classpathentry kind="src" path="frameworks/opt/net/voip/src/java"/>
        <classpathentry kind="src" path="frameworks/opt/net/wifi/service/java"/>
        <classpathentry kind="src" path="frameworks/opt/photoviewer/activity/src"/>
        <classpathentry kind="src" path="frameworks/opt/photoviewer/src"/>
        <classpathentry kind="src" path="frameworks/opt/setupwizard/navigationbar/src"/>
        <classpathentry kind="src" path="frameworks/opt/telephony/src/java"/>
        <classpathentry kind="src" path="frameworks/opt/timezonepicker/src"/>
        <classpathentry kind="src" path="frameworks/opt/vcard/java"/>
        <classpathentry kind="src" path="frameworks/opt/bitmap/src"/>
        <classpathentry kind="src" path="frameworks/support/v13/java"/>
        <classpathentry kind="src" path="frameworks/support/v13/ics"/>
        <classpathentry kind="src" path="frameworks/support/v13/ics-mr1"/>
        <classpathentry kind="src" path="frameworks/support/v7/appcompat/src"/>
        <classpathentry kind="src" path="frameworks/support/v7/cardview/src"/>
        <classpathentry kind="src" path="frameworks/support/v7/cardview/base"/>
        <classpathentry kind="src" path="frameworks/support/v7/cardview/eclair-mr1"/>
        <classpathentry kind="src" path="frameworks/support/v7/cardview/api21"/>
        <classpathentry kind="src" path="frameworks/support/v7/cardview/jellybean-mr1"/>
        <classpathentry kind="src" path="frameworks/support/v7/palette/src"/>
        <classpathentry kind="src" path="libcore/dalvik/src/main/java"/>
        <classpathentry kind="src" path="libcore/dex/src/main/java"/>
        <classpathentry kind="src" path="libcore/json/src/main/java"/>
        <classpathentry kind="src" path="libcore/libart/src/main/java"/>
        <classpathentry kind="src" path="libcore/luni/src/main/java"/>
        <classpathentry kind="src" path="libcore/xml/src/main/java"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/ApiDemos_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/Browser_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/CalendarProvider_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/ContactsProvider_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/MediaProvider_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/PackageInstaller_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/QuickSearchBox_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/Settings_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/SystemUI_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/APPS/TeleService_intermediates/src/src"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates/classes-jarjar.jar"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/com.android.emailcommon_intermediates/src/src"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/keystore/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/location/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/media/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/packages/services/PacProcessor"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/packages/services/Proxy"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/telecomm/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/telephony/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/wifi/java"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/services.core_intermediates/src/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/src/src/java"/>
        <classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/src/src/java"/>
        <classpathentry kind="src" path="out/target/common/R"/>
        <classpathentry kind="src" path="external/apache-http/src"/>
        <classpathentry kind="src" path="external/easymock/src"/>
        <classpathentry kind="src" path="external/hamcrest/src"/>
        <classpathentry kind="src" path="external/junit/src"/>
        <classpathentry kind="src" path="external/ksoap2/kobjects"/>
        <classpathentry kind="src" path="external/ksoap2/ksoap2-base/src/main/java"/>
        <classpathentry kind="src" path="external/ksoap2/ksoap2-j2se/src/main/java"/>
        <classpathentry kind="src" path="external/mp4parser/isoparser/src/main/java"/>
        <classpathentry kind="src" path="external/nist-sip/java"/>
        <classpathentry kind="src" path="external/objenesis/main/src"/>
        <classpathentry kind="src" path="external/owasp/sanitizer/src/main"/>
        <classpathentry kind="src" path="external/tagsoup/src"/>
        <classpathentry kind="src" path="external/xmp_toolkit/XMPCore/src"/>
        <classpathentry kind="src" path="external/icu/icu4c/source"/>
        <classpathentry kind="src" path="external/libphonenumber/java/src"/>
        <classpathentry kind="src" path="external/libphonenumber/geocoder-2.17"/>
        <classpathentry kind="lib" path="packages/apps/Calculator/arity-2.1.2.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes-jarjar.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-jarjar.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/mockito-api_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/junit-runner_intermediates/javalib.jar"/>
        <classpathentry kind="lib" path="E:/ws_android_5/geocoder-2.17.jar"/>
        <classpathentry kind="output" path="out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes"/>
    </classpath>
  • 相关阅读:
    C# List<string>和List<int>互相转换
    sourcetree跳过注册的方法
    列举 contentType: 内容类型(MIME 类型)
    nginx 使用过程中一些基础性问题总结
    MVC3升级到MVC4模型验证信息显示为英文问题及解决方案
    ckeditor:复制内容到ckeditor时,只保留文本,忽略其样式解决方法
    MVC从视图传参到Controller几种方式
    Window Service 计划任务
    Git命令行连Github与TortoiseGit 连Github区别
    For xml path
  • 原文地址:https://www.cnblogs.com/lionfight/p/2934712.html
Copyright © 2011-2022 走看看