“无法解析以下类的超类型。” 在任务中:应用程序:buildInfoGeneratorDebug

Tav*_*_PG 3 java android kotlin ros android-gradle-plugin

我无法编译我的 Android Kotlin 项目,因为在 gradle 编译时出现以下“Kotlin 编译器”错误:

Supertypes of the following classes cannot be resolved. Please make sure 
you have the required dependencies in the classpath: class 
sensor_msgs.CompressedImage, unresolved supertypes: 
org.ros.internal.message.Message> Task:app:buildInfoGeneratorDebug
Run Code Online (Sandbox Code Playgroud)

这是一个简单的测试项目,具有最少的代码。与常规 Android 应用程序的主要区别。这是我的 MainActivity 使用类 RosActivity 而不是 AppCompatActivity。

我已经更改了“ext.kotlin_version”(无法解析以下类的超类型。请确保类路径中具有所需的依赖项:)

我尝试更改依赖项的顺序(错误:无法解析以下类的超类型。请确保类路径中具有所需的依赖项

我尝试过“resolutionStrategy.force”(错误:无法解析以下类的超类型。请确保您在类路径中具有所需的依赖项

我尝试过“无效缓存/重新启动”(错误:无法解析以下类的超类型。请确保类路径中具有所需的依赖项

我更改了 'org.jetbrains.kotlin:kotlin' 但这不起作用(无法解析以下类的超类型

清单.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" package="com.company.roscameratest">

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme" tools:replace="android:icon">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name="org.ros.android.MasterChooser" />

        <service android:name="org.ros.android.NodeMainExecutorService" >
            <intent-filter>
                <action android:name="org.ros.android.NodeMainExecutorService" />
            </intent-filter>
        </service>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

构建.gradle(项目):

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

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

构建.gradle(模块):

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.company.roscameratest"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force "org.ros.android_core:android_15:0.3.3"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'org.ros.android_core:android_15:0.3.3'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    //androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

repositories {
    maven {  url 'https://github.com/rosjava/rosjava_mvn_repo/raw/master' }
}
Run Code Online (Sandbox Code Playgroud)

小智 7

在 gradle\xef\xbc\x8c 中,如果您的项目实现 A\xef\xbc\x8c 但 A 也实现 B\xe3\x80\x82 如果您的项目在 A 中使用了某个类,而 A 中的类扩展了 B\xef\xbc\x8c 中的类,那么您可以只调用构造方法\xef\xbc\x8c 可以\xe2\x80\x98t 调用B\xef\xbc\x8c 中调用超类的方法或使用它来方法参数\xe3\x80\x82

\n\n

只需尝试实现 api\xe3\x80\x82

\n\n

api 'org.ros.android_core:android_15:0.3.3'

\n