7

-Android Studio 1.5.1, Java 1.7.0 amd64, Ubuntu 15.10

-instaled kotlin-plugin 1.0.0

-created new project with empty activity (API level 15)

-Tools->Kotlin->Configure Kotlin in project

-Default options are selected, All modules, Kotlin plugin version 1.0.0

Generate build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "kotlin.org.jjvr.kotlinapplication"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),    'proguard-rules.pro'
    }
}
sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.0.0'
repositories {
    mavenCentral()
}
dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-    plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}

-open in editor MainActivity.java and convert to Kotlin: - kotlin Code->Convert Java File to Kotlin File

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
}
}

-while building these errors are listed

Error: Only the Kotlin standard library is allowed to use the 'kotlin' package

Error:Execution failed for task ':app:compileDebugKotlin'.

Compilation error.

Any idea what's going on?

Thanks in advance

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
jjvr
  • 85
  • 1
  • 7
  • It's just a guess based on the error, try to use a different application than `applicationId "kotlin.org.jjvr.kotlinapplication"` – Sebastian Feb 18 '16 at 13:21
  • With applicationId "kotlinapplication" the same errors occur. – jjvr Feb 18 '16 at 16:24
  • 2
    You can't use the Kotlin package, but that's not a matter of changing the `applicationId`. It's a matter of security so that you don't have access to internal stuff, so my guess is you can't use the kotlin package in your code. You'll need to rename your packages. – Antonio Feb 19 '16 at 09:08
  • Thanks Antonio!!, changing package name from package kotlin.org.jjvr.kotlinapplication to package practicakotlin.org.jjvr.kotlinapplication everything works well. – jjvr Feb 19 '16 at 09:38

2 Answers2

5

I got the same error because i was using "kotlin.kotlindemo" as package name. Just i renamed the package and it is working fine now.

Prakash Bala
  • 315
  • 5
  • 12
0

As error says :

Only the Kotlin standard library is allowed to use the 'kotlin' package

You can not use 'kotlin' for your package name and your Package (applicationId) is :

kotlin.org.jjvr.kotlinapplication

So you must change it to something else with renaming or creating new applicaton with another package name

Radesh
  • 13,084
  • 4
  • 51
  • 64