NoSuchFieldError: No static field MapAttrs of type when Using MapFragment with Play Services 6.5

后端 未结 5 743
南方客
南方客 2020-12-07 22:56

Maybe I am missing something here, but I am not able to use the new Maps only dependency in Play Services 6.5

I get the following exception:

java.la         


        
5条回答
  •  温柔的废话
    2020-12-07 23:37

    I found a "hacky" fix to make it work with your app until Google decides to fix this :

    Add this to your app gradle script:

    afterEvaluate {
        def pattern = ~/process(.*)Resources/
        tasks.matching { pattern.matcher(it.name).find() }.each {
            def matcher = pattern.matcher(it.name)
            matcher.find()
            def buildType = matcher.group(1)
            buildType = buildType.substring(0, 1).toLowerCase() + buildType.substring(1)
            def rDirectory = "$project.buildDir/generated/source/r/$buildType"
            it << {
                def badFile = file("$rDirectory/com/google/android/gms/R.java")
                def goodFile = file("$rDirectory/com/google/android/gms/maps/R.java")
                if (badFile.exists() && goodFile.exists()) {
                    badFile.text = goodFile.text.replaceAll('com.google.android.gms.maps', 'com.google.android.gms')
                }
            }
        }
    }
    

提交回复
热议问题