【问题标题】:Do we modify our build gradle when we create a new package?当我们创建一个新包时,我们是否修改了我们的构建 gradle?
【发布时间】:2021-08-31 14:44:28
【问题描述】:

我是 android studio 的初学者,所以我下载了这段代码并想在上面添加身份验证,为此我创建了一个新包“com.example.authapp”。

所以当我尝试连接到 firebase 时,我收到以下错误:

Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.

所以我想知道我应该在我的 gradles 中添加一些东西吗?

我的 gradles 的内容: 1/build.gradle(app)

apply plugin: 'com.android.application'

repositories {
    google()
    maven {
        url 'https://alphacephei.com/maven/'
    }
}

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "org.vosk.demo"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.1"
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'x86'
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'net.java.dev.jna:jna:5.8.0@aar'
    implementation group: 'com.alphacephei', name: 'vosk-android', version: '0.3.23'
    implementation project(':models')
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
}

2/build.gradle(模型)

apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    buildFeatures {
        buildConfig = false
    }
    sourceSets {
        main {
            assets.srcDirs += "$buildDir/generated/assets"
        }
    }
}

tasks.register('genUUID') {
    def uuid = UUID.randomUUID().toString()
    def odir = file("$buildDir/generated/assets/model-en-us")
    def ofile = file("$odir/uuid")
    doLast {
        mkdir odir
        ofile.text = uuid
    }
}

preBuild.dependsOn(genUUID)

3/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

请帮助我,我应该怎么做才能连接到 Firebase?

【问题讨论】:

    标签: java android firebase gradle


    【解决方案1】:

    您尝试构建的内容称为多模块应用,因为您添加了不同的包。我不是你的本意,因为你提到你是初学者。

    以下是实施的步骤

    1. 在 com.vosk.demo 中创建一个 Activity 名称 LoginActivity 并在其中应用您的 firebase 功能
    2. 将您的 Loginactivity 设置为 Launcher Activity
    3. 身份验证成功后,传递Intent以进入下一个活动

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-09
      • 2010-10-29
      • 1970-01-01
      • 2017-05-26
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 2021-12-06
      相关资源
      最近更新 更多