Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error: java.lang.Class<boofcv.core.image.border.BorderIndex1D_Extend> has no zero argument constructor #92

Closed
akidee opened this issue Nov 7, 2017 · 3 comments

Comments

@akidee
Copy link

akidee commented Nov 7, 2017

On Android with org.boofcv:boofcv-core:0.27 :

ConfigCirculantTracker config = new ConfigCirculantTracker();
CirculantTracker<GrayU8> tracker = FactoryTrackerObjectAlgs.circulant(config, GrayU8.class);

Stacktrace:

E/MessageQueue-JNI: java.lang.RuntimeException: java.lang.InstantiationException: java.lang.Class<boofcv.core.image.border.BorderIndex1D_Extend> has no zero argument constructor
    at boofcv.core.image.border.ImageBorder1D_S32.<init>(ImageBorder1D_S32.java:36)
    at boofcv.core.image.border.FactoryImageBorder.single(FactoryImageBorder.java:139)
    at boofcv.factory.interpolate.FactoryInterpolation.bilinearPixelS(FactoryInterpolation.java:187)
    at boofcv.factory.tracker.FactoryTrackerObjectAlgs.circulant(FactoryTrackerObjectAlgs.java:117)

The same happens when using FactoryTrackerObjectQuad, while not happening in the DemoApp ( https://github.com/lessthanoptimal/BoofAndroidDemo/blob/master/app/src/main/java/org/boofcv/android/tracker/ObjectTrackerActivity.java#L100 ):

TrackerObjectQuad tracker = FactoryTrackerObjectQuad.circulant(null, GrayU8.class);

From build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    ...
        compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8 // Needed
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled true // / false
            useProguard false // / true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        ...
    }
}

configurations {
    all*.exclude group: "xmlpull", module: "xmlpull"
    all*.exclude group: "org.apache.commons", module: "commons-compress"
}

dependencies {
            compile 'org.boofcv:boofcv-core:0.27'

            compile 'org.apache.commons:commons-lang3:3.6'
            compile 'com.android.support:appcompat-v7:25.4.0'
            compile 'org.reactivestreams:reactive-streams:1.0.0'
            compile 'io.reactivex.rxjava2:rxjava:2.0.8'
            compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
}

apply plugin: 'me.tatarka.retrolambda'

...

Using 'org.boofcv:core:0.26' I get this build error:

Error:java.lang.RuntimeException: com.android.build.gradle.shrinker.ClassLookupException: 
Invalid class reference: javax/swing/JPanel
Error:com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: javax/swing/JPanel

This error wont disappear if ProGuard is enabled and

-ignorewarnings
-dontwarn javax.swing.*

added to the proguard rules.

Currently there is no way to let even 1 line with BoofCV code run inside my Android project. Probably sourceCompatibility is the issue?

@lessthanoptimal
Copy link
Owner

Could you post a complete but very simple project which reproduces the "no zero argument constructor" exception? I was not able to reproduce this issue in a simple DesktopApplication

The 0.26 problem is most likely caused by a call a function which using Swing to visualize data or load an image. The AndroidDemo includes core without issue in 0.26

@akidee
Copy link
Author

akidee commented Nov 7, 2017

Suddenly I get this error in my own code where I instantiate a class with

nonAbstractPublicStaticClass.newInstance()

And I still get this error after I have added a non arg constructor or set minifyEnabled/shrinkResources to false! This seems to be a more general problem.

@akidee
Copy link
Author

akidee commented Nov 7, 2017

The problem was minification while not explicitly using those classes. Using multidex and setting minification to off, it works. Now I need to find a way to use it with minification without getting all those swing warnings.

The solution to this problem is to not compile it inside the Android app and instead just link to its jars.

I have downloaded the boofcv-v0.27-libs.zip. Which jars do I need to add in my module's libs/ dir to make boofcv-core work?

@akidee akidee closed this as completed Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants