Kotlin GPS 编程时出现错误

问题描述 投票:0回答:1

我正在做一个教程,并且正在使用 Android Studio Giraffe。在我添加 GPS 功能之前,该项目一直有效。编译时出现很多错误,我无法解释。其中之一就是我放在下面的那个

> Failed to transform common-27.1.3.jar
> (com.android.tools:common:27.1.3) to match attributes
> {artifactType=android-classes-jar, org.gradle.category=library,
> org.gradle.libraryelements=jar, org.gradle.status=release,
> org.gradle.usage=java-api}.

我认为是配置问题,所以我会添加配置文件。

androidManifest.xml文件是这样的:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:tools="http://schemas.android.com/tools">

   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
   <!-- INICIO: Permisos GPS-->
   <!-- Always include this permission
        https://developer.android.com/training/location/permissions?hl=es-419-->
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

   <!-- Include only if your app benefits from precise location access. -->
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

   <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
   <!-- Required only when requesting background location access on
       Android 10 (API level 29) and higher. -->
   <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

   <uses-feature android:name="android.hardware.location.gps"/>
   <!-- Recommended for Android 9 (API level 28) and lower. -->
   <!-- Required for Android 10 (API level 29) and higher. -->
   <!-- FIN: Permisos GPS-->
   <application
      android:allowBackup="true"
      android:dataExtractionRules="@xml/data_extraction_rules"
      android:fullBackupContent="@xml/backup_rules"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/Theme.WildRunning"
      tools:targetApi="31">

      <activity
         android:name=".RecordActivity"
         android:exported="false" />
      <activity
         android:name=".TermsActivity"
         android:exported="false"
         android:label="@string/app_name" />

      <activity
         android:name=".LoginActivity"
         android:exported="true"
         android:screenOrientation="portrait">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
      <activity
         android:name=".MainActivity"
         android:exported="false" />
      <activity
         android:name="com.facebook.FacebookActivity"
         android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
         android:label="@string/app_name" />
     <activity
         android:name="com.facebook.CustomTabActivity"
         android:exported="true">
         <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="@string/fb_login_protocol_scheme" />
         </intent-filter>
      </activity>

      <meta-data
         android:name="com.facebook.sdk.ApplicationId"
         android:value="@string/facebook_app_id" />
      <meta-data
         android:name="com.facebook.accountkit.ClientToken"
         android:value="@string/facebook_client_token" />
      <meta-data
         android:name="com.facebook.sdk.ClientToken"
         android:value="@string/facebook_client_token" />
      <meta-data
         android:name="com.facebook.accountkit.ApplicationName"
         android:value="@string/app_name" />
      <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
         android:value="false"/>


   </application>

</manifest>

graddle(应用程序)文件是:

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")
}

android {
    namespace = "es.proyectoslore.cursoandroid.wildrunning"
    compileSdk = 34



    defaultConfig {
        applicationId = "es.proyectoslore.cursoandroid.wildrunning"
        minSdk = 21
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {

    //noinspection GradleCompatible
    implementation("androidx.core:core-ktx:1.8.0")//"androidx.core:core-ktx:1.9.0"
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.10.0")
    implementation("com.android.tools.build:gradle-api:4.1.3")
    //com.google.android.material:material:1.8.0
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    implementation(platform("com.google.firebase:firebase-bom:32.5.0"))
    implementation("com.google.firebase:firebase-auth-ktx")
    implementation ("com.google.firebase:firebase-database:20.3.0")
    implementation ("com.google.firebase:firebase-firestore:24.9.1")
    implementation("com.google.android.gms:play-services-auth:20.7.0")
    //implementation ("com.google.auth:google-auth-library-oauth2-http:1.20.0")
    implementation ("com.google.firebase:firebase-analytics")
    implementation ("com.google.firebase:firebase-messaging:23.3.1")
    implementation ("androidx.drawerlayout:drawerlayout:1.2.0")
    implementation ("androidx.coordinatorlayout:coordinatorlayout:1.2.0")

    //para geolocalización
    //noinspection GradleDependency
    implementation("com.google.android.gms:play-services-location:19.0.1")

   //seekbar circle, doc oficial https://github.com/tankery/CircularSeekBar
    implementation ("me.tankery.lib:circularSeekBar:1.3.2")

    implementation("androidx.appcompat:appcompat:1.6.1@aar")
    // Facebook SDK Core only (Analytics)
    implementation ("com.facebook.android:facebook-core:16.2.0")
    // Facebook Login only
    implementation ("com.facebook.android:facebook-login:16.2.0")
    // Facebook Share only
    implementation ("com.facebook.android:facebook-share:5.15.3")
    // Facebook Places only
    implementation ("com.facebook.android:facebook-places:5.15.3")
    // Facbeook Messenger only
    implementation ("com.facebook.android:facebook-messenger:5.15.3")
    // Facebook App Links only
    implementation ("com.facebook.android:facebook-applinks:5.15.3")
    // Facebook Android SDK (everything)
    implementation ("com.facebook.android:facebook-android-sdk:5.15.3")
    // Audience Network SDK.
    implementation ("com.facebook.android:audience-network-sdk:5.11.0")
    // Account Kit
    implementation ("com.facebook.android:account-kit-sdk:5.4.0")


}

graddle(模块)文件是:

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

buildscript { repositories {
    google()
    mavenCentral()
}}

plugins {
    id("com.android.application") version "8.1.2" apply false
    id("org.jetbrains.kotlin.android") version "1.9.0" apply false
    id("com.google.gms.google-services") version "4.4.0" apply false
}

请问,你能帮我吗?

kotlin android-gps
1个回答
0
投票

删除此行后我解决了

实现(“com.android.tools.build:gradle-api:4.1.3”) 实现(“com.android.tools:common:31.2.0”)

现在程序编译并运行良好。我现在主要的疑问是,这些行对于其他功能来说是必需的。

© www.soinside.com 2019 - 2024. All rights reserved.