Flutter sharesdk_plugin:verifyReleaseResources

问题描述

在使用第三方分享库 sharesdk,执行 flutter run --release的时候报错了,报错内容如下:

FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Execution failed for task ':sharesdk_plugin:verifyReleaseResources'.    
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed                                    
     /Users/lgq/.gradle/caches/transforms-2/files-2.1/571183c39fe6f7ff875572206d91c282/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
                                                                        
     /Users/lgq/.gradle/caches/transforms-2/files-2.1/571183c39fe6f7ff875572206d91c282/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
                                                        

原因

ShareSdk使用的gradle版本是27 ,我使用的版本是28,导致该错误的发送。

解决方式

  • 1.修改我gradle的版本;
  • 2.修改他gradle的版本;
    我选择了第二种方式。

具体方法:

1.找到shareSdk的gradle


image.png

2.在文件浏览器中打开该路径
3.编辑android>build.gradle 文件


image.png

4.将文件中的compileSdkVersion 更改为 28 (因为我的是28)。
// sharesdk build.gradle 文件
group 'com.yoozoo.sharesdk'
version '1.0-SNAPSHOT'
apply plugin: 'com.android.library'
//apply from: 'MobSDK.gradle'
apply plugin: 'com.mob.sdk'

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "http://mvn.mob.com/android"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.mob.sdk:MobSDK:+'
    }
}

/*allprojects {
    repositories {
        jcenter()
        maven {
            url "http://mvn.mob.com/android"
        }
    }
}*/

rootProject.allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "http://mvn.mob.com/android"
        }
    }
}



android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 16
    targetSdkVersion 28
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

MobSDK {
    ShareSDK {
        loopShare true
    }
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}



其他

在解决该问题过程中,尝试过以下方式,未成功。

 // 在build.gradle(Module:app)单独配置
configurations.all {
        resolutionStrategy {
                force 'com.android.support:support-v4:27.1.0'
    }
}

参考 https://www.jianshu.com/p/84fe0c9c023b

其实最早就是想着把他的 compileSdkVersion 修改了,一开始没成功,原因是他有好几处compileSdkVersion的地方,我只修改了一处,蠢到无话可说。

特此铭记我解决该问题花费了一天时间。

你可能感兴趣的:(Flutter sharesdk_plugin:verifyReleaseResources)