3

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 で試してみました


  1. Smooch SDK を統合せずにカメラを使用する。アプリは期待どおりに動作しています。

  2. **Smooch UI を使用**。smooch-cordova プラグインは期待どおりに動作します。https://github.com/smooch/smooch-cordova

  3. smooch sdk が統合されたカメラを使用します。アプリからカメラを開くと、「アクティビティを再開できません」というメッセージが表示されてアプリがクラッシュします。

上に貼り付けたスタックトレース。


ファイル:

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);
 }
}

controller.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 を追加してカメラ デバッガーを開くとすぐに切断されます。

どうすれば解決できますか?

4

0 に答える 0