I'm trying to use OkHttp to download a file from a webserver in an Android app. After creating a new Project with Android Studio (API level 28) I added a button and am ImageView to my Activity. The idea is to download the an image when I press the button and show it on the screen.
I'm using the latest version of OkHttp, 3.14.0.
I added <uses-permission android:name="android.permission.INTERNET"/> to the AndroidManifest.xml file.
I tried to use the OkHttpClient exactly as described in the examples. This is what my code looks like:
public class MainActivity extends AppCompatActivity {
... // onCreate method
public void btnClicked(View view) {
new DownloadImageAsyncTask().execute("https://link.to/image.jpg");
}
public class DownloadImageAsyncTask extends AsyncTask<String, Void, Bitmap> {
OkHttpClient client = new OkHttpClient();
... // override doInBackground()
}
}
When l run the app and press the button, the btnClicked() method is executed and the app crashes. The error occurs when calling OkHttpClient() no matter if I place it as a field in the DownloadImageAsyncTask class, as a local variable of the doInBackground() method or as a field in the ManActivity class.
I've also ried to use the Builder (new OkHttpClient.Builder().build()) to initialize the object but with the same outcome.
Here's the stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.httpstuff, PID: 17796
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.BootstrapMethodError: Exception from call site #4 bootstrap method
at okhttp3.internal.Util.<clinit>(Util.java:87)
at okhttp3.internal.Util.immutableList(Util.java:234)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:124)
at com.myapp.httpstuff.MainActivity$DownloadImageAsyncTask.<init>(MainActivity.java:31)
at com.myapp.httpstuff.MainActivity.btnClicked(MainActivity.java:26)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: Bootstrap method returned null
at okhttp3.internal.Util.<clinit>(Util.java:87)
at okhttp3.internal.Util.immutableList(Util.java:234)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:124)
at com.myapp.httpstuff.MainActivity$DownloadImageAsyncTask.<init>(MainActivity.java:31)
at com.myapp.httpstuff.MainActivity.btnClicked(MainActivity.java:26)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
OkHttp 3.13+ requires Java 8+ or Android 5+. I think you've encountered a situation where a Java 8 lambda is not expected by the ART runtime.
https://android.googlesource.com/platform/art/+/master/runtime/interpreter/interpreter_common.cc#1399
Handle<mirror::Object> object(hs.NewHandle(result.GetL()));
if (UNLIKELY(object.IsNull())) {
// This will typically be for LambdaMetafactory which is not supported.
ThrowClassCastException("Bootstrap method returned null");
return nullptr;
}
You'll probably have success updating your build.gradle.
android {
compileOptions {
targetCompatibility = "8"
sourceCompatibility = "8"
}
}
https://github.com/square/okhttp/issues/4597
After trying everythin that came to my mind I tried using an older version of OkHttp.
Using OkHttp:2.7.2 instead, my code works as expected.
I just tested Okhttp3:3.12.2 as well and this fixes the issue as well.
Interestingly OkHttp3:3.12.2 was released a day after OkHttp3:3.14.0 (https://github.com/square/okhttp/releases)
Here is the answer why it works with the Okhttp3:3.12.2:
Google’s distribution dashboard shows that ~11% of the devices that visited the Play Store in October 2018 were running Android 4.x. We’ve created a branch, OkHttp 3.12.x, to support these devices. Should we encounter any severe bugs or security problems we’ll backport the fixes and release. We plan to maintain this branch through December 31, 2020.
Source: https://medium.com/square-corner-blog/okhttp-3-13-requires-android-5-818bb78d07ce
Related
I have an android app that has a second module included in the app when the main activity starts an activity in the module everything is good. The problem is if you go to another app and then resume this app the activity crashes with a null object pointer. My app uses Esri ArcGIS runtime SDK. I have a MapView open in the activity when the crash occurs. I don't have any problem with an open map in the MainActivity and the app goes to the background then back to the current app.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thevillages.myfirstapp, PID: 23267
java.lang.RuntimeException: Unable to resume activity {com.thevillages.myfirstapp/com.thevillages.maplib.MapNavActivity}: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4205)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
at com.esri.arcgisruntime.internal.jni.CoreGeoView.nativeResume(Native Method)
at com.esri.arcgisruntime.internal.jni.CoreGeoView.b(SourceFile:5)
at com.esri.arcgisruntime.a.i.f.g.d(SourceFile:3)
at com.esri.arcgisruntime.mapping.view.GeoView$RenderingThread.resume(SourceFile:4)
at com.esri.arcgisruntime.mapping.view.MapView.resume(SourceFile:1)
at com.thevillages.maplib.MapNavActivity.onResume(MapNavActivity.java:816)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
at android.app.Activity.performResume(Activity.java:7939)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I systematically went through my onCreate() method and added each piece of the code to find where the problem was. I found some code that was suspicious and I could not recall why I added the code. With the code removed the app works fine.
I was trying to adapt the code from this: 3D-model-viewer to my app because I want to insert some models from that kind to show human anatomy.
Everything seems fine, I first cloned and tried the original repository, it worked, so I started using that code.
After adapting and checking everything's okay and there are no errors marked, I ran the app, but there seems to be an issue. In the original code, the person saves a url like this:
url = new URL("android://org.andresoviedo.dddmodel2/assets/" + parent.getParamAssetDir() + File.separator + parent.getParamAssetFilename());
I already changed the first part to my project:
url = new URL("android://com.example.ovman.appbotox/assets/" + parent.getParamAssetDir() + File.separator + parent.getParamAssetFilename());
so I don't think is that, algo I inserted some logs to verify the params aren't null.
The class in github is here: SceneLoader.java
So, when I get to that point, the Logcat says "unkown protocol: andorid".
Here's the complete logcat:
06-26 17:34:26.304 26616-26616/com.example.ovman.appbotox E/SceneLoader: unknown protocol: android
java.net.MalformedURLException: unknown protocol: android
at java.net.URL.<init>(URL.java:608)
at java.net.URL.<init>(URL.java:498)
at java.net.URL.<init>(URL.java:447)
at com.example.ovman.appbotox.model3D.services.SceneLoader.init(SceneLoader.java:118)
at com.example.ovman.appbotox.ZonesActivity.onCreate(ZonesActivity.java:108)
at android.app.Activity.performCreate(Activity.java:7131)
at android.app.Activity.performCreate(Activity.java:7122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2882)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3037)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
06-26 17:34:26.533 26616-26616/com.example.ovman.appbotox E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ovman.appbotox, PID: 26616
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ovman.appbotox/com.example.ovman.appbotox.ZonesActivity}: java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: android
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2902)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3037)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: android
at com.example.ovman.appbotox.model3D.services.SceneLoader.init(SceneLoader.java:124)
at com.example.ovman.appbotox.ZonesActivity.onCreate(ZonesActivity.java:108)
at android.app.Activity.performCreate(Activity.java:7131)
at android.app.Activity.performCreate(Activity.java:7122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2882)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3037)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.net.MalformedURLException: unknown protocol: android
at java.net.URL.<init>(URL.java:608)
at java.net.URL.<init>(URL.java:498)
at java.net.URL.<init>(URL.java:447)
at com.example.ovman.appbotox.model3D.services.SceneLoader.init(SceneLoader.java:118)
at com.example.ovman.appbotox.ZonesActivity.onCreate(ZonesActivity.java:108)
at android.app.Activity.performCreate(Activity.java:7131)
at android.app.Activity.performCreate(Activity.java:7122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2882)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3037)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
My repository is this, the app runs, there are no errors marked, just when selecting the 3rd option in my menu (it's the first screen) it crashes.
I kept the url line like that since I didn't know if the "android://" part was really important or not.
What do you think I should change or do you know what that error means? Do I need to import anything? I checked the original project (manifest, folder structure, gradle) and everything is similar, so I don't know where the mistake lies.
At the end, what I want is to access my assets folder to show some .obj files. And for the URL, I know that for links you should put a protocol, but I don't get why the protocol android isn't working for getting something in one of my project paths.
EDIT:
In my repository I made some changes to get the obj file, still, if someone could tell me (as the modification hadn't anything to do with the url) how to manage that about the android protocol. I checked this link: URL but I couldn't find much.
The "android" protocol is handled by a custom handler.
// Custom handler: org/andresoviedo/app/util/url/android/Handler.class
System.setProperty("java.protocol.handler.pkgs", "org.andresoviedo.app.util.url");
It is possible that for some reason, the System property that registers the custom handler is not working. So to force java to handle custom protocol, you can do it like this:
URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
#Override
public URLStreamHandler createURLStreamHandler(String protocol) {
if ("android".equals(protocol)){
return new Handler();
}
return null;
}
});
Just use java.net.URI instead of java.net.URL
UPDATE
Consider this
I am not able to figure out what is causing this error while the app is running. It causes the app to stop. Is it a wrong practice to sleep the main thread to finish execution of the asynchronous thread. If so why and what is a good practice?
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:4707)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22295)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4702)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22295)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.example.sairahul5223.e_bot.Main4Activity.onButtonClickName43(Main4Activity.java:330)
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:4702)
at android.view.View.performClick(View.java:5619)
at android.view.View$PerformClick.run(View.java:22295)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
First thing: we don't make the main thread sleep because this will cause an Application Not Responding (ANR) error.
To get the result of an asynchronous task, we normally use a callback to determine the task's status. Take a look at this answer to give you idea: How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class?
On android 7.0 when I want to open a camera in logs I see this :
EventBus: Could not dispatch event: class pl.eltegps.smokkomunikator.event.PhotoRequestedEvent to subscribing class class pl.eltegps.smokkomunikator.ui.activity.MainActivity
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/pl.eltegps.smokkomunikator/images/gps_TEMP.jpg exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9483)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9468)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.Activity.startActivityForResult(Activity.java:4399)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4358)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:871)
at pl.eltegps.smokkomunikator.ui.activity.MainActivity.onPhotoRequestedEvent(MainActivity.java:399)
at java.lang.reflect.Method.invoke(Native Method)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485)
at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:416)
at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397)
at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370)
at org.greenrobot.eventbus.EventBus.post(EventBus.java:251)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment.photo(NewMessageFragment.java:259)
at pl.eltegps.smokkomunikator.ui.fragment.NewMessageFragment$$ViewBinder$1.doClick(NewMessageFragment$$ViewBinder.java:28)
at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
at android.view.View.performClick(View.java:6199)
at android.view.View$PerformClick.run(View.java:23647)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
On android 4.4.2 I check and it works corretly, but on new android it doesn't works corretly and I don't know why ...
This is a problem I faced also faced while testing on 7.0 . Seems like you can not use getUri() Directly on 7.0 without the use of content provider.
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
FileProvider.getUriForFile(getActivity(), getActivity().getApplicationContext().getPackageName() + ".provider", f));
You will have to use this and add a provider.xml in xml directory of your project.
this link has detailed explaination about it.
Used native-libs.jar. Following the same method as given in the sample. Currently using quickblox-android-sdk-videochat-webrtc-2.4. Trying using the sample code QBRTCClient shows the below error message:
java.lang.NoSuchMethodError: No static method registerComplexPropertyParser(Ljava/lang/String;Lcom/quickblox/chat/propertyparsers/MessagePropertyParser;)V in class Lcom/quickblox/chat/model/QBChatMessageExtension; or its super classes (declaration of 'com.quickblox.chat.model.QBChatMessageExtension' appears in /data/app/xxx.xxx.xxx/base.apk)
at com.quickblox.videochat.webrtc.RTCSignallingMessageProcessor.<clinit>(RTCSignallingMessageProcessor.java:38)
at com.quickblox.videochat.webrtc.QBRTCClient.<init>(QBRTCClient.java:93)
at com.quickblox.videochat.webrtc.QBRTCClient.getInstance(QBRTCClient.java:124)
at xxx.xxx.xxx.Activity.CallActivity.initQBRTCClient(CallActivity.java:125)
at xxx.xxx.xxx..Activity.CallActivity.onCreate(CallActivity.java:119)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2312)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2421)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5329)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
I was using multiple version of library for chat, video and core, so i contacted Quickblox and they told me to use the same version of library for all. Hope this helps.
Thank You