Ionic 3 Android Build Error (could not find support-v4.jar)

可紊 提交于 2019-12-01 01:26:22

You have to do some modifications in your build.gradle file inside platforms/android as follows:

allprojects { 
  repositories { 
    mavenCentral()
    maven { url 'https://maven.google.com' } //add this code
    jcenter() 
 } 
}

It's essential for new versions of google libraries. They moved their libraries out of the android SDK to the maven repo.

I'm sure I could adjust the build.gradle file that Cordova generates to fix this. However, that would get stepped on by Cordova on every Dev machine. I found a different work-around.

I previously had to mess with the com.android.support library because different plugins required different versions, and they didn't play well with each other. My approach was to add a build-extras.gradle file (via a hook, see here (option 2) which eventually leads to here) with the contents below. That worked (until fairly recently).

configurations.all {
    resolutionStrategy {
       force 'com.android.support:support-v4:26+'
    }
}

From what I can tell, something is different about the 26.1.0 version of this library. It seems like it's not available in the same repository or something? Regardless, swapping to an earlier version (below) works. Notice the real change is from 26+ to 26.0+ (which should pull in 26.0.2). This builds fine again.

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:26.0+'
    }
}

This happened to me as well, today. It compiled two days ago and now the build fails. I did not change anything to the project or config. It may be because google moved their libraries to maven but what can we do about this?

WARNING: Module 'com.android.support:support-v4:26.1.0' depends on one or more Android Libraries but is a jar

BUILD FAILED

Total time: 2.87 secs FAILURE: Build failed with an exception.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!