Android Library Project Usage issues

Source: Internet
Author: User
Tags constant

1. When you create a new Android library project or convert an existing project into an Android library project, if the project source code has the following statement:

int id = View.getid ();

Switch (ID) {

Case R.id.button1:

Action1 ();

Break

Case R.id.button2:

Action2 ();

Break

Case R.ID.BUTTON3:

Action3 ();

Break

}

will prompt the case expressions must to be constant expressions error because the resource constants in ADT14 after the r.class of the Android Library project are not final type, cause

See Http://tools.android.com/tips/non-constant-fields official explanation. So the example above R.id.button1 no longer ask constants, it can't be used in the switch structure, simple to solve

The method is to convert the switch into a if-else statement, which is very easy to implement in eclipse, place the cursor over the switch keyword, press ctrl+1, and then replace it with the following figure

2. If you have an activity in the Android Library project, you may not have to declare it in the Library project's manifest file, but be sure to make a declaration in the project that uses the library because the manifest configuration file is independent to the project and cannot be reused.

3. If you use a third-party jar package in your Android library project, you should also talk about importing it into the project that uses the library

4. If you find an error message that reports the following at run time:

Android library projects cannot be launched

I think this kind of problem must end up in Eclipse's properties, and finally, in the Android option, there will be a front tick in the is library, and then there won't be any errors!

Author: csdn blog hits Fung

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.