错误:“只允许 Kotlin 标准库使用 'kotlin' 包"; [英] Error: "Only the Kotlin standard library is allowed to use the 'kotlin' package"
本文介绍了错误:“只允许 Kotlin 标准库使用 'kotlin' 包";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Android Studio 3.0.1 中构建我的第一个 kotlin 项目.但我遇到了这两个错误:
I want to build my first kotlin project in Android studio 3.0.1 . but i got these 2 errors :
只允许 Kotlin 标准库使用 'kotlin' 包.
Only the Kotlin standard library is allowed to use the 'kotlin' package .
错误:任务:app:compileDebugKotlin"的执行失败.
Error:Execution failed for task ':app:compileDebugKotlin'.
如何使用或添加 Kotlin 标准库?
how can i use or add the Kotlin standard library?
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kotlin.amirreza.mykotlinproject">
<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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
毕业:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "kotlin.amirreza.mykotlinproject"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
推荐答案
您将包名称设置为 kotlin
.
将 .kt
文件中的所有 package kotlin
语句更改为类似 package mykotlintest
Change all package kotlin
statements in your .kt
files to something like package mykotlintest
这篇关于错误:“只允许 Kotlin 标准库使用 'kotlin' 包";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文