Gradle compile-time problems encountered

Source: Internet
Author: User

Invalid r class path shown in problem 1:mainactivity.java

Workaround: As does not automatically generate R files for some reason. For example, if the project relies on a library file version that does not match the specified compilesdkversion, you need to manually specify the version number of the library file that needs to be compiled. For example, Android.compilesdkversion is 19, then add at the end of Project->app->build.gradle

dependencies {

Compile ' com.android.support:support-v4:+ ' changed to compile ' com.android.support:support-v4:19.+ '
Compile ' com.android.support:appcompat-v7:+ ' changed to compile ' com.android.support:appcompat-v7:19.+ '
}

Note dependencies{} and android{} siblings

Issue two: As code in the edit window and run time, Chinese display garbled

Solution: As the Code editing window garbled, only need to change the lower right corner of the IDE UTF-8 to GBK; runtime display garbled, 1, add compileoptions.encoding = "in Project->app->build.gradle GBK ". 2, can not be directly input in the layout file in Chinese, need to register in the R file, such as <activity android:label= "Chinese" > Changed to <activity android:label= "@string/chinese" Add <string name= "Chinese" > Chinese </string> in Strings.xml.






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.