android - 在Android Studio中构建统一项目(具有Firebase)时出错

标签 android firebase unity3d gradle

我正在为Android平台开发一个统一项目。我必须使用gradle(new)方法进行构建,因为字段引用的数量超过了允许的数量。我还在项目中使用firebase和FbSDK。但是,我无法正确构建它。因此,我想到了导出项目并使用Android Studio进行构建的想法。但是,在构建项目时出现错误。错误是

No matching client found for package name 'com.google.firebase.unity' .



根据firebase,我需要在gradle文件中添加以下行。
1. Project-level build.gradle (<project>/build.gradle):

buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.2.0'
}
}


2. App-level build.gradle (<project>/<app-module>/build.gradle):

dependencies {
// Add this line
compile 'com.google.firebase:firebase-core:12.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

这些是我的gradle文件:
项目/ build.gradle
  // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

    buildscript {
    repositories {
    jcenter()
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
    classpath 'com.google.gms:google-services:3.2.0'
}
}

allprojects {
 repositories {
  flatDir {
    dirs 'libs'
     }
  }
}

apply plugin: 'com.android.application'

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile(name: 'facebook-android-sdk-4.23.0', ext:'aar')
    compile(name: 'facebook-android-wrapper-7.10.1', ext:'aar')
    compile project(':Firebase')
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

defaultConfig {
    multiDexEnabled true
    targetSdkVersion 27
    applicationId 'com.DefaultCompany.Data_Collection'
}

lintOptions {
    abortOnError false
}
signingConfigs { release {
    storeFile file('C:\\Users\\vaish\\.android\\debug.keystore')
    storePassword 'qwerty123'
    keyAlias 'datacollection'
    keyPassword 'qwerty123'
} }

buildTypes {
    debug {
        jniDebuggable true
    }
    release {
        // Set minifyEnabled to true if you want to run ProGuard on your project
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
        signingConfig signingConfigs.release
    }
}


}

项目/ Firebase / build.gradle
buildscript {
        repositories {
        mavenCentral()
        google()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
}
}

apply plugin: 'android-library'

dependencies {
    compile fileTree(dir: 'bin', include: ['*.jar'])
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.firebase:firebase-core:12.0.0'
}

 android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            //java.srcDirs = ['src']
             res.srcDirs = ['res']
            assets.srcDirs = ['assets']
       }
}

compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    targetSdkVersion 9
}

lintOptions {
    abortOnError false
}
}
apply plugin: 'com.google.gms.google-services'

错误日志为:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Firebase:processDebugGoogleServices'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.gradle.api.GradleException: No matching client found for package name 'com.google.firebase.unity'
        at com.google.gms.googleservices.GoogleServicesTask.action(GoogleServicesTask.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        ... 32 more

我是第一次用gradle构建,对此了解不多。

最佳答案

如果您使用 firebase unity插件,则将找到可以将google-services.json转换为google-services.xml的python代码。(我想您已经拥有)

拥有此xml时,无需应用插件:'com.google.gms.google-services'

尝试删除它并重建您的项目,我希望它可以肯定运行。

关于android - 在Android Studio中构建统一项目(具有Firebase)时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49706269/

相关文章:

android - 在构建文件中启用数据绑定(bind)会使 transformDexArchiveWithExternalLibsDexMergerForDebug 任务失败

android - 为谷歌短信检索器 api 生成哈希字符串 - 'xxd' 不被识别为内部或外部命令

firebase - Office 365 高级威胁防护正在标记我的 Firebase 身份验证电子邮件

user-interface - 在 Unity 中创建螺旋形 UI 栏

ios - Unity 在 iPhone 上的 GetCloudProjectId() 崩溃

java - Firebase:无法将java.lang.String类型的对象转换为com.example.g.Model.Cart类型

android - 动态使用 RelativeLayout 并以 px、dp、inch、mm 为单位设置边距

firebase - 如何在 flutter 朔迷离的电子商务应用程序中添加购物车页面?

android - Firebase 崩溃报告错误 : client application com. xxxx 被阻止

java - 在 Android 应用的 Assets 文件夹中创建一个符号链接(symbolic link)到其存储