无法在我的 Flutter 项目中构建 Account Kit

问题描述

之前我还没有解决华为登录的问题 链接https://forums.developer.huawei.com/forumPortal/en/topic/0201616708664590094?fbclid=IwAR2j7upjI62ISMICdVh9_MgArtzVbAFMXJ26vpfSh3t5wZ991tOuOsF06D8 在调试模式下,我在计算机上的模拟器上运行。为了解决它,我尝试使用云调试,当使用云调试时,我必须构建我的项目以使其成为应用程序,然后当我尝试构建它时,我发现一个错误如下

* What went wrong: Execution Failed for task ':app:minifyReleaseWithR8'.   com.android.tools.r8.CompilationFailedException: Compilation Failed to complete

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD Failed in 1m 29s Running Gradle task 'bundleRelease'...         
90.2s [!] The shrinker may have Failed to optimize the Java bytecode.
    To disable the shrinker,pass the `--no-shrink` flag to this command.
    To learn more,see: https://developer.android.com/studio/build/shrink-code Gradle task bundleRelease Failed with exit code 1

然后我尝试查找包中是否有错误,当我尝试拔出华为帐户包时,会发生这种情况

Unplugged

接下来,我尝试更改 Gradle 版本,因为正如前面所看到的,有一个日志说

此版本中使用了弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。

然后看看会发生什么

Plugged

我只是不知道该怎么办,因为如果它仍然发生,我无法使用帐户工具包发布应用

这是我最新的 build.gradle

应用层

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'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$FlutterRoot/packages/Flutter_tools/gradle/Flutter.gradle"

def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinoptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // Todo: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.gky_cmn"
        minSdkVersion 20
        targetSdkVersion 30
        versionCode FlutterVersionCode.toInteger()
        versionName FlutterVersionName
        multiDexEnabled true
    }

    signingConfigs {       
       release {            
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']        
       }    
   }   
 
   buildTypes {        
       debug {            
           signingConfig signingConfigs.config        
        }       
        release {  
           minifyEnabled true
            shrinkResources true
           proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
           signingConfig signingConfigs.config        
       }    
    }

}

Flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply plugin: 'com.huawei.agconnect'

安卓级别

buildscript {
    ext.kotlin_version = '1.4.32'
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.huawei.agconnect:agcp:1.4.1.300'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

LOG --verbose https://ghostbin.com/paste/bkCr2

解决方法

我在华为论坛上看到了您的问题。根据日志,您的测试设备上未安装 HMS Core。实际上,HMS SDK 提供了下载和安装HMS Core 的功能。您可以参考documententer image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...