【问题标题】:Unresolved reference in Android Studio 3 CanaryAndroid Studio 3 Canary 中未解决的引用
【发布时间】:2017-12-05 00:18:18
【问题描述】:

我正在尝试使用 Carto Mobile SDK,但 Android Studio 一直告诉我 Unresolved reference: com.carto.ui.MapView

我有最新的 Android Studio Canary,我更新了 gradle 和 kotlin 插件,但仍然无法正常工作。

这只发生在 Android Studio 3.0 Canary 中,它适用于 Android Studio 2.3.3。

这些是我的 gradle 文件:

项目等级:

buildscript {
    ext.kotlin_version = '1.1.3'
    ext.anko_version = '0.10.1'

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

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

应用分级:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "me.mcordoba.test"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile "org.jetbrains.anko:anko-commons:$anko_version"

    compile 'com.android.support:appcompat-v7:25.4.0'
    compile 'com.android.support:support-v4:25.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    compile 'com.carto:carto-mobile-sdk:4.0.2@aar'

    testCompile 'junit:junit:4.12'
}

【问题讨论】:

  • 从外观上看,Android Studio 3 不支持@aar 文件? developer.android.com/studio/preview/features/…
  • 我坚持了下来,但我尝试了其他 @aar 并且成功了。我只是遇到了这个问题。
  • 如果您尝试transitive = true 会怎样?即使那不在他们的文档中
  • 编译成功了吗?因为我对 Android Studio 3.0 canary 7 有同样的问题。我有一个带有“未解决的引用”错误的 aar 库,但实际上我可以无错误地编译。

标签: android android-studio gradle kotlin


【解决方案1】:

1.将classpath org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version添加到项目gradle的buildscript-dependencies

2.添加apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions'apply plugin: 'com.android.application'of app gradle 之后。

对我来说,它发生在 Android studio 3.1 上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 1970-01-01
    • 2017-11-05
    相关资源
    最近更新 更多