“以下类的超类型无法解析."在Task:app:buildInfoGeneratorDebug中 [英] "Supertypes of the following classes cannot be resolved.” in Task:app:buildInfoGeneratorDebug
问题描述
我无法编译我的Android Kotlin项目,因为在gradle编译时出现以下"Kotlin编译器"错误:
I can't compile my Android Kotlin Project because I get the following 'Kotlin compiler' error when gradle compiles:
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
这是一个简单的测试项目,具有最少的代码.常规android应用之间的主要区别.这是我的MainActivity使用RosActivity类而不是AppCompatActivity.
This is a simple test project that has the bare minimum code. The main difference between a regular android app. and this one is my MainActivity uses class RosActivity rather than AppCompatActivity.
I have changed 'ext.kotlin_version' (Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:)
I have tried changing the order of dependencies (error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath)
我已经尝试过'resolutionStrategy.force'(
I have tried 'resolutionStrategy.force' (error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath)
I have tried 'Invalidate cache/restart' (error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath)
我更改了"org.jetbrains.kotlin:kotlin",但这没有用(
I changed 'org.jetbrains.kotlin:kotlin' but this did not work (Supertypes of the following classes cannot be resolved)
Manifest.xml:
Manifest.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>
build.gradle(项目):
build.gradle (Project):
// 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
}
build.gradle(模块):
build.gradle (Module):
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' }
}
推荐答案
在gradle中,如果您的Project实现A,但是A也是实现B.构造方法,无法调用方法在B中调用superClass或将其用于方法参数.
In gradle, if your Project implementation A, but A also implementation B。 if your project used some class in A whitch extents class in B, you can just call construction method, can‘t call method whitch call superClass in B, or use it to method paramater。
只需尝试对api进行限制.
just try implemntation to api。
api'org.ros.android_core:android_15:0.3.3'
api 'org.ros.android_core:android_15:0.3.3'
这篇关于“以下类的超类型无法解析."在Task:app:buildInfoGeneratorDebug中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!