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.