wesshi
wesshi

Reputation: 231

Disable certain Android Studio compilation errors

I'm extending a hidden java class so I run into the error

Error:Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> class com.company.class.CustomVersion cannot access its superclass java.class.JavaVersion

However, if I don't rely on Android Studio, output a jar, and then add the jar as a dependency to the same project I don't get the above compilation error and the app can launch. Since I'm writing my own library, I'd prefer not to have to create and export a jar every time I want to test some code change. Is there a way of disabling compilations errors like the above for a class?

EDIT:

For more information I was trying to extend a hidden Android class in the java.net package.

Upvotes: 0

Views: 1465

Answers (1)

wesshi
wesshi

Reputation: 231

Alright, so while Android Studio will complain about code in your project it won't complain if a dependency tries to access a hidden class. My solution to this problem was to create a jar file with the class in question and add that to the gradle dependencies file as with the provided keyword.

dependencies {
    provided files('libs/hiddenClassDependency.jar')
}

With this your Android Studio project will build fine. When someone else uses your build product (I have mine as a jar) it'll use the hidden Android class that you couldn't access in the IDE.

Upvotes: 1

Related Questions