Android studio module Add the latest com. android. support: appcompat-v7: 21.0.0 dependency error, androidstudio download

Source: Internet
Author: User

Android studio module Add the latest com. android. support: appcompat-v7: 21.0.0 dependency error, androidstudio download

My development platform is Mac and the testing machine is MX3 (API 19 android 4.4.4). I'm not sure if this problem occurs on other platforms, so I should explain it in advance to avoid mistakes.

When I used the custom ActionBar again today, a very strange error occurred, that is, I added the latest com for my module. android. support: appcompat-v7: 21.0.0 dependent, use final ActionBar actionBar = getActionBar (); actionBar in Activity. when show (); is used to obtain the ActionBar, an NullPointerException exception is thrown, which makes me puzzled. This has never been a problem before ..... As a result, a variety of Baidu google, but did not find similar problems (I used the latest support package ). Finally, a similar problem was found in StackOverFlow, and I realized that it may be com. android. support: appcompat-v7: 21.0.0 is too high, causing incompatibility issues with sdks below android 5.0. It is estimated that google's head is shot, and the support package is used for compatibility. In this version, it turns out to be the cause of incompatibility .....

The error cause analysis is as follows:
In the module build. gradle file, if the default automatic dependency processing method is used, it is shown as follows:


dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])compile project(':Library')compile 'com.android.support:support-v4:21.0.0'compile 'com.android.support:appcompat-v7:21.0.0'}


The system depends on the latest version of support: appcompat-v7: 21.0.0 at compile time. According to the previous experience is not because of the problem, but according to my understanding, the current appcompat-v7: 21.0.0 must use android 5.0 build tool, and the built program can only run in Android 5.0 .... Can't we mix 4.4.4 users ???
So the solution is also very simple: is to change the appcompat-v7: 21.0.0 to appcompat-v7: 19. +
As follows:


dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])compile project(':Library')compile 'com.android.support:support-v4:21.0.0'compile 'com.android.support:appcompat-v7:19.+'}

PS: I found that no one has recorded this issue in the domestic forum. So I will record it, and I am using a memorandum of authorization. I have complained a lot about it. Sorry, this problem has delayed me for more than three hours. After all, I am so powerful. Haha, the rookie Master Development Plan has started.

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.