WalkerKnapp / devolay

A Java binding for the Newtek NDI(tm) SDK.
Apache License 2.0
54 stars 17 forks source link

Files#createTempFile is not supported on Android with API Level <26 #21

Closed soapgu closed 2 years ago

soapgu commented 2 years ago

I want run a demo to use.

I add dependencies in build.gradle

    implementation 'me.walkerknapp:devolay:2.0.2:integrated'

here is MainActivity.java

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        Devolay.loadLibraries();
        this.finder = new DevolayFinder();
        this.textView = this.findViewById(R.id.textView);
        super.onCreate(savedInstanceState);
        nsdManager = (NsdManager)getSystemService(Context.NSD_SERVICE);
        setContentView(R.layout.activity_main);
        this.findViewById(R.id.findSourceBtn).setOnClickListener( v -> {
            if (!finder.waitForSources(5000)) {
                // If no new sources were found
                textView.setText("No change to the sources list found.");
            }
            DevolaySource[] sources = finder.getCurrentSources();
            textView.setText( String.format( "Network sources ( %s found ).",sources.length) );
        } );
    }

when I launching app on my Android device, it crash. I have no idea


java.lang.NoClassDefFoundError: Failed resolution of: [Ljava/nio/file/attribute/FileAttribute;
        at me.walkerknapp.devolay.Devolay.extractNative(Devolay.java:99)
        at me.walkerknapp.devolay.Devolay.<clinit>(Devolay.java:35)
        at me.walkerknapp.devolay.Devolay.loadLibraries(Devolay.java:136)
        at com.space365.nditest.MainActivity.onCreate(MainActivity.java:22)
        at android.app.Activity.performCreate(Activity.java:6709)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
WalkerKnapp commented 2 years ago

It looks like part of the loading routine has an implicit dependency I didn't test for on API Level 26 features. Are you running with an API Level higher than this? If that isn't possible, I can look into revisions that change how the library is loaded.

soapgu commented 2 years ago

Here is my github repository,NdiFinder My Hardware Deivice API Level is 25。compileSdk and targetSdk is 30. IDE Tools:Android Studio 2020.3.1 for Windows 64-bit

WalkerKnapp commented 2 years ago

I apologize for not responding in a few days! I have bounced off a few ideas that avoid the problem code, but I am having a hard time coming up with a solution that is platform independent.

If it is at all possible, the ideal solution would be to require API Level 26 at this time, but more generally, this library should be packaged differently on Android systems. I have created a separate issue tracking this goal, but I will leave this issue open until that can be addressed.

WalkerKnapp commented 2 years ago

I have an experimental build that uses a more android-friendly method of loading libraries. It would be great if you could try out putting this devolay-2.0.2.aar.zip (make sure to unzip it first) file in your project directory, and depending on it with

implementation(files("devolay-2.0.2.aar"))

Thank you for your patience!

WalkerKnapp commented 2 years ago

A build with this fix has been published! To use it, change your dependency to:

dependencies {
    implementation('me.walkerknapp:devolay:2.1.0') {
        artifact {
            name = "devolay"
            type = "aar"
        }
    }
}

Feel free to reopen if you have any more issues!