java.lang.SecurityException: Prohibited package name: java.sql


I have a problem with SQL connection via JDBC in Kotlin in IntellijIDEA 2018.3.2 and have been working and googleing about it for days and still have got nothing. I created a package named ‘com.myapp.test’ and used JDBC for connecting to SQLServer and fetch data. Problem is that building project reports no errors but when trying to run it in emulator gives a strange build exception.

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:app:transformClassesWithInstantRunForDebug’.
java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.SecurityException: Prohibited package name: java.sql

I tried changing target java SDK from 6 to 11 and many other tricks like naming for imported classes like:

import java.sql.ResultSet as jsqlRes

class myClass{
    val myRes:jsqlRes

but the problem still exists. 

have any idea what can i do to fix this problem?

That usually means that you are creating a class in that package. Are you sure all your classes are in the com.myapp.test package?


All classes of project are in same package called ‘com.myapp.test’.
I guess this is not a package naming problem. this must be a kotlin or java thing or anything else.
I tried various package names and also stared a new empty project for test and got no answers.
Seems like Kotlin or java gone crazy wherever i use this java.sql namespace imports.


Please upload a project that shows that behaviour somewhere. I’m still convinced that you have a incorrect package statement somewhere. Have you tried searching your code for package java.sql or something similar?