Ich habe eine Cordova-Plugin, das auf einem Gerät einen Laserscanner läuft, dessen Main.java wie folgt aussieht:Aktivität Erlaubnis in AndroidManifest Geben
package com.example.plugin;
import org.apache.cordova.*;
import org.json.JSONArray;
import org.json.JSONException;
import java.security.PublicKey;
import android.os.Bundle;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.util.Log;
public class Hello extends CordovaPlugin {
public static final int REQUEST_CODE = 0x0ba7c0de;
@Override
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
if (action.equals("scan")) {
scan();
return true;
} else {
return false;
}
}
public void scan() {
Intent intentService = new Intent("com.hyipc.core.service.barcode.BarcodeService2D");
intentService.putExtra("KEY_ACTION", "UP");
this.cordova.startActivityForResult((CordovaPlugin) this, intentService, REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
Log.i("scan", "everything works fine");
}
}
Wenn ich das Plugin laufen, bekomme ich diese im Fehlerprotokoll :
07-11 12:03:33.541: E/AndroidRuntime(5258): FATAL EXCEPTION: main
07-11 12:03:33.541: E/AndroidRuntime(5258): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ionicframework.curierapp266167/com.hyipc.core.service.barcode.BarcodeService2D}: java.lang.ClassNotFoundException: Didn't find class "com.hyipc.core.service.barcode.BarcodeService2D" on path: DexPathList[[zip file "/data/app/com.ionicframework.curierapp266167-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.curierapp266167-2, /vendor/lib, /system/lib]]
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.app.ActivityThread.access$600(ActivityThread.java:162)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.os.Handler.dispatchMessage(Handler.java:107)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.os.Looper.loop(Looper.java:194)
07-11 12:03:33.541: E/AndroidRuntime(5258): at android.app.ActivityThread.main(ActivityThread.java:5392)
07-11 12:03:33.541: E/AndroidRuntime(5258): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:03:33.541: E/AndroidRuntime(5258): at java.lang.reflect.Method.invoke(Method.java:525)
07-11 12:03:33.541: E/AndroidRuntime(5258): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
07-11 12:03:33.541: E/AndroidRuntime(5258): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-11 12:03:33.541: E/AndroidRuntime(5258): at dalvik.system.NativeStart.main(Native Method)
07-11 12:03:33.541: E/AndroidRuntime(5258): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.hyipc.core.service.barcode.BarcodeService2D" on path: DexPathList[[zip file "/data/app/com.ionicframework.curierapp266167-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.curierapp266167-2, /vendor/lib, /system/lib]]
ich habe diese auf meine AndroidManifest.xml Datei hinzugefügt, aber ich bin ziemlich sicher, etwas mit ihm nicht stimmt.
<activity android:label="@string/share_name" android:name="com.hyipc.core.service.barcode.BarcodeService2D">
<intent-filter>
<action android:name="com.hyipc.core.service.barcode.BarcodeService2D" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
EDIT
Wenn ich meine Manifest-Datei zu dieser bearbeiten, erhalte ich keine Aktivität Intent Fehler behandeln gefunden.
<activity android:label="@string/share_name" android:name="com.hyipc.core.service.barcode.BarcodeService2D">
<intent-filter>
<action android:name="android.intent.action.LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Auch, wenn ich versuche, die Aktivität wie folgt zu starten:
cordova.getActivity().startService(intentService);
Der Scanner ohne Fehler starten, aber ich weiß nicht, wie das Ergebnis zu erhalten.
Ich denke, Sie eine Abhängigkeit verpasst haben.? Kannst du deinen Gradle oder lib Ordner überprüfen? – Raghavendra
Für was genau sollte ich aussehen? –
Welche Bibliothek wird zum Scannen verwendet? – Raghavendra