当我使用带有 cordova 相机插件的 smooch SDK 时出现此错误。
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.ionicframework.smooch310486/com.ionicframework.smooch310486.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {com.ionicframework.smooch310486/com.ionicframework.smooch310486.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2995)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3030)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {com.ionicframework.smooch310486/com.ionicframework.smooch310486.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:3626)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2969)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3030)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:445)
at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:674)
at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:120)
at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:353)
at android.app.Activity.dispatchActivityResult(Activity.java:6161)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3622)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2969)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3030)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
我尝试使用 Smooch SDK 版本2.0.5和2.0.7
使用没有集成 Smooch sdk 的相机。应用程序按预期工作。
**使用 Smooch UI **。smooch-cordova 插件按预期工作。https://github.com/smooch/smooch-cordova
使用集成了 smooch sdk 的相机。从应用程序打开相机时,应用程序崩溃并显示“无法恢复活动”。
Stacktrace 粘贴在上面。
文件:
MainApplication.java
package com.ionicframework.smooch310486;
import android.app.Application;
import io.smooch.core.Smooch;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Smooch.init(this, "<smooch-token>");
}
}
AndroidMenifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.smooch310486" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:name="com.ionicframework.smooch310486.MainApplication" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
MainActivity.java
package com.ionicframework.smooch310486;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
控制器.js
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {
$scope.click = function(){
navigator.camera.getPicture(function(data){
$scope.image = data;
},function(err){
console.log(err);
},{
});
}
});
我注意到当我使用没有集成 Smooch sdk 的 chrome 调试器时,打开相机时调试器保持不变,但一旦我添加 smooch 并打开相机调试器就会断开连接。
我该如何解决?