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

Throwing a Fatal error #36

Closed
dkostins opened this issue May 7, 2017 · 14 comments
Closed

Throwing a Fatal error #36

dkostins opened this issue May 7, 2017 · 14 comments

Comments

@dkostins
Copy link

dkostins commented May 7, 2017

I just copied and pasted the code and changed the links around but can't get the example working, and like it is throwing a really strange error.
I think here is the code in question I belive:
private void loadIpCam() {
Mjpeg.newInstance()
.credential(getPreference("demo"), getPreference("nxwitness"))
.open(getPreference("http://demo.networkoptix.com:7001/media/5bafc0e9-56be-97f8-5034-45a50cecf3d8.mpjpeg"), TIMEOUT)
.subscribe(
inputStream -> {
mjpegView.setSource(inputStream);
mjpegView.setDisplayMode(calculateDisplayMode());
mjpegView.showFps(true);
},
throwable -> {
Log.e(getClass().getSimpleName(), "mjpeg error", throwable);
Toast.makeText(this, "Error", Toast.LENGTH_LONG).show();
});
}
and it throws this error in Android Studios, it looks like there is dependency missing somewhere or something?
Caused by: java.lang.NoSuchMethodError: No static method com_github_niqdev_mjpeg_Mjpeg$$Lambda$1_lambda$connect$0(Lcom/github/niqdev/mjpeg/Mjpeg;Ljava/lang/String;)Lrx/Observable; in class Lcom/github/niqdev/mjpeg/Mjpeg; or its super classes (declaration of 'com.github.niqdev.mjpeg.Mjpeg' appears in /data/app/danmax.javaalexa-2/base.apk)

@niqdev
Copy link
Owner

niqdev commented May 7, 2017

I think your copy and paste is wrong, getPreference read from the preferences, try something like this. Please let me know if that was the issue or there is something else.
Thanks

Mjpeg.newInstance()
  .credential("demo", "nxwitness")
  .open("http://demo.networkoptix.com:7001/media/5bafc0e9-56be-97f8-5034-45a50cecf3d8.mpjpeg", TIMEOUT)
  .subscribe(
    inputStream -> {
      mjpegView.setSource(inputStream);
      mjpegView.setDisplayMode(calculateDisplayMode());
      mjpegView.showFps(true);
    },
    throwable -> {
      Log.e(getClass().getSimpleName(), "mjpeg error", throwable);
      Toast.makeText(this, "Error", Toast.LENGTH_LONG).show();
  });

@dkostins
Copy link
Author

dkostins commented May 7, 2017

Yeah I tried again, same error -
here is the full error.
Thanks for your speedy responce :).
FATAL EXCEPTION: RxIoScheduler-2 Process: danmax.javaalexa, PID: 5159 java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: java.lang.NoSuchMethodError: No static method com_github_niqdev_mjpeg_Mjpeg$$Lambda$1_lambda$connect$0(Lcom/github/niqdev/mjpeg/Mjpeg;Ljava/lang/String;)Lrx/Observable; in class Lcom/github/niqdev/mjpeg/Mjpeg; or its super classes (declaration of 'com.github.niqdev.mjpeg.Mjpeg' appears in /data/app/danmax.javaalexa-1/base.apk) at com.github.niqdev.mjpeg.Mjpeg$$Lambda$1.call(Unknown Source) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10346) at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761) 

@dkostins
Copy link
Author

dkostins commented May 7, 2017

Here is the full code as of right now:
` import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.github.niqdev.mjpeg.DisplayMode;
import com.github.niqdev.mjpeg.Mjpeg;
import com.github.niqdev.mjpeg.MjpegView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

private static final int TIMEOUT = 20;

@BindView(R.id.mjpegViewDefault)
MjpegView mjpegView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
}

private String getPreference(String key) {
    return PreferenceManager
            .getDefaultSharedPreferences(this)
            .getString(key, "");
}

private DisplayMode calculateDisplayMode() {
    int orientation = getResources().getConfiguration().orientation;
    return orientation == Configuration.ORIENTATION_LANDSCAPE ?
            DisplayMode.FULLSCREEN : DisplayMode.BEST_FIT;
}

private void loadIpCam() {
    Mjpeg.newInstance()
            .credential("demo", "nxwitness")
            .open("http://demo.networkoptix.com:7001/media/5bafc0e9-56be-97f8-5034-45a50cecf3d8.mpjpeg", TIMEOUT)
            .subscribe(
                    inputStream -> {
                        mjpegView.setSource(inputStream);
                        mjpegView.setDisplayMode(calculateDisplayMode());
                        mjpegView.showFps(true);
                    },
                    throwable -> {
                        Log.e(getClass().getSimpleName(), "mjpeg error", throwable);
                        Toast.makeText(this, "Error", Toast.LENGTH_LONG).show();
                    });
}
@Override
protected void onResume() {
    super.onResume();
    loadIpCam();
}

@Override
protected void onPause() {
    super.onPause();
    mjpegView.stopPlayback();
}

}`

@niqdev
Copy link
Owner

niqdev commented May 7, 2017

Uhm, just a question, have you tried the example from google play? Is it working?

@dkostins
Copy link
Author

dkostins commented May 7, 2017

What's the name on Google play, but yeah I haven't .

@niqdev
Copy link
Owner

niqdev commented May 7, 2017

Have a look the README,
Anyway I tried, but i think the problem is the format mpjpeg (motion jpeg), the library supports only mjpeg.
If you try the demo app you should get an error similar to

java.io.FileNotFoundException: http://demo.networkoptix.com:7001/media/5bafc0e9-56be-97f8-5034-45a50cecf3d8.mpjpeg
 at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)

That is like a 404 i.e. Not Found, in this case not supported I guess

@dkostins
Copy link
Author

dkostins commented May 7, 2017

Dang that is not exactly my problem because I tried to do a wrong url to get a 404 but it still threw that original error .Granted doesn't matter since not of the formats provided by the API I'm using has the correct format for your program . Thanks anyway :)

@spurd0
Copy link

spurd0 commented Jul 6, 2017

Having same problem. Just imported your lib to new project & got same exception. App from play market works well.

@spurd0
Copy link

spurd0 commented Jul 7, 2017

All right, solved it by adding:
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
to project's build gradle

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.neenbedankt.android-apt'

To module gradle

& adding your`s bintray.gradle

@niqdev
Copy link
Owner

niqdev commented Jul 7, 2017

Sorry for the late response, glad you found a solution. Thanks for sharing

@ulaserdegor
Copy link

@spurd0 hi. your solution not work for me. Can you help me?

@spurd0
Copy link

spurd0 commented Nov 20, 2017

@ulaserdegor what error have you got? Please share your build.gradle for app & project.

@ulaserdegor
Copy link

@spurd0 same your error. my gradle files like yours.
i using java 1.8 and sdk 27

@spurd0
Copy link

spurd0 commented Nov 21, 2017

@ulaserdegor

Here is my project's build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'me.tatarka:gradle-retrolambda:3.6.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}

allprojects {
    group = 'com.github.niqdev'
    version = '1.1.0'

    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Pay attention to group = 'com.github.niqdev', as i remembered i got error because i didn't have it. Also i used 25 sdk.

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

4 participants