We use centrifuge lib to communicate with Sockets. Everything works well but
this code :
val credentials = Centrifuge.newCredentials(
getCurrentUserId(),
webSocketToken.timestamp,
EMPTY_STRING,
webSocketToken.token
)
throws this error, it only happens with android based on arm structure. Here is the output:
Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.namba-_dbpnhlp0R3PyG4erhR_2w==/base.apk"],nativeLibraryDirectories=[/data/app/com.namba-_dbpnhlp0R3PyG4erhR_2w==/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libgojni.so"
at java.lang.Runtime.loadLibrary0 + 1012(Runtime.java:1012)
at java.lang.System.loadLibrary + 1669(System.java:1669)
at go.LoadJNI.<clinit> + 23(LoadJNI.java:23)
at java.lang.Class.classForName(Class.java)
at java.lang.Class.forName + 453(Class.java:453)
at java.lang.Class.forName + 378(Class.java:378)
at go.Seq.<clinit> + 28(Seq.java:28)
at go.Seq.touch()
at centrifuge.Centrifuge.<clinit> + 11(Centrifuge.java:11)
at centrifuge.Centrifuge.newCredentials(Centrifuge.java)
at com.namba.websocket.CentrifugoWebSocketClient.createClient + 214(CentrifugoWebSocketClient.kt:214)
at com.namba.websocket.CentrifugoWebSocketClient$initClient$1.invokeSuspend + 145(CentrifugoWebSocketClient.kt:145)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith + 32(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask$DefaultImpls.run + 235(Dispatched.kt:235)
at kotlinx.coroutines.DispatchedContinuation.run + 81(Dispatched.kt:81)
at kotlinx.coroutines.scheduling.Task.run + 94(Tasks.kt:94)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely + 586(CoroutineScheduler.kt:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely + 60(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run + 732(CoroutineScheduler.kt:732)
Related
I am using android.arch.lifecycle extension to detect when the app moves in background or foreground:
#OnLifecycleEvent(Lifecycle.Event.ON_STOP)
private void onAppBackgrounded() {
Log.i(this.getClass().getName(), "onAppBackgrounded()");
}
The extension works fine except on a device running on Android 5.0.2 (SDK 21) on which I get the following exception:
Caused by java.lang.NoSuchFieldException: ON_STOP
at java.lang.Class.getDeclaredField + 929(Class.java:929)
at libcore.reflect.AnnotationAccess.decodeValue + 685(AnnotationAccess.java:685)
at libcore.reflect.AnnotationAccess.toAnnotationInstance + 663(AnnotationAccess.java:663)
at libcore.reflect.AnnotationAccess.toAnnotationInstance + 641(AnnotationAccess.java:641)
at libcore.reflect.AnnotationAccess.getDeclaredAnnotation + 170(AnnotationAccess.java:170)
at java.lang.reflect.Method.getAnnotation + 301(Method.java:301)
at android.arch.lifecycle.ClassesInfoCache.createInfo + 124(ClassesInfoCache.java:124)
at android.arch.lifecycle.ClassesInfoCache.hasLifecycleMethods + 59(ClassesInfoCache.java:59)
at android.arch.lifecycle.Lifecycling.resolveObserverCallbackType + 137(Lifecycling.java:137)
at android.arch.lifecycle.Lifecycling.getObserverConstructorType + 119(Lifecycling.java:119)
at android.arch.lifecycle.Lifecycling.getCallback + 57(Lifecycling.java:57)
at android.arch.lifecycle.LifecycleRegistry$ObserverWithState.(LifecycleRegistry.java:2)
at android.arch.lifecycle.LifecycleRegistry.addObserver + 162(LifecycleRegistry.java:162)
Is there any possibility to upload a file on mobile browser (Safari on iOS, Chrome on Android)? Conventional methods doesn't seem to work. Maybe there are similar options to BrowserStack where file upload can actually work?
BrowserStack uses Appium to drive your Selenium tests on Android and iOS.
As given here, since Appium currently does not support uploads, BrowserStack too wouldn't be able to support File Upload on mobile devices.
This is a hacky file upload solution using base64 and JS, but it works, so hey, I hope you find this useful:
public CorePage UploadHack(string fileInputId, string contentType, string fileContent, string fileName, string angularScopeVar)
{
UploadFile(_filePath);
var uploadHack =
"(function(){" +
"function convert(base64){" +
"var raw = atob(base64);" +
"var arr = new Uint8Array(new ArrayBuffer(raw.length));" +
"for (var i = 0; i < raw.length; i++){" +
"arr[i] = raw.charCodeAt(i);" +
"}" +
"return arr; " +
"}" +
$"var file = new Blob([convert('{fileContent}')], {{'type':'{contentType}'}}); " +
$"file.name = '{fileName}'; " +
$"angular.element('#{fileInputId}').scope().{angularScopeVar} = file;" +
"})()";
Driver.ExecuteJavaScript(uploadHack);
return this;
}
I rebooted my android phone and the geolocation code in my app has stopped working. The navigator.geolocation is returning true but getCurrentPosition and watchPosition aren't working. It isn't returning an error message either. I have location turned on the phone, the phone version is 5.0.1 and the cordova version I am using is 5.3.3.
Any help would be greatly appreciated!
The JavaScript code I am using:
function showCurrentPosition(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
}
// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
// onError Callback receives a PositionError object
//
function onError() {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
Console Log:
The key "target-densitydpi" is not supported.
file:///android_asset/www/css/images/ajax-loader.gif Failed to load resource: net::ERR_FILE_NOT_FOUND
whitelist.js:23 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.(anonymous function) # whitelist.js:23
index.js:41 Uncaught TypeError: Cannot read property 'querySelector' of null
521whitelist.js:25 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
I figured out what was causing my geolocation to stop working. When I rebooted my android is set the location services to GPS only. When I changed it use WiFi, phone network and GPS for my location it was able to obtain my longitude and latitude.
The problem with my android phone is that the GPS has stopped working so this turned out to be a hardware problem not a software problem.
I am trying to merge two videos in Android using FFMPEG and I have been following the Android War Zone blog which gives great ideas and simple methods to integrate FFMPEG in our project. However, I am facing issues in merging two videos.
Command :
vk.run(new String[]{
"ffmpeg",
"-f",
"concat",
"-i",
list,
"-s",
"hd720",
"-c",
"copy",
"-b",
br_from_db + "k",
path + "/" + "merged_video_3.mp4"
}, work_path, getActivity());
And the "list" in the above command is the one where I am facing a issue.It throws me the following error when I use the following method :
Code :
private String generateList(String[] inputs) {
File list;
Writer writer = null;
try {
list = File.createTempFile("ffmpeg-list", ".txt");
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(list)));
for (String input : inputs) {
writer.write("file '" + input + "'\n");
Log.d(TAG, "Writing to list file: file '" + input + "'");
}
} catch (IOException e) {
e.printStackTrace();
return "/";
} finally {
try {
if (writer != null)
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
Log.d(TAG, "Wrote list file to " + list.getAbsolutePath());
return list.getAbsolutePath();
}
Error :
12-16 19:49:57.416 5437-5437/? E/ffmpeg4android﹕ Command validation failed.
12-16 19:49:57.416 5437-5437/? E/ffmpeg4android﹕ Check if input file exists: /data/data/com.family45.golive.family45v1/cache/ffmpeg-list-1803386407.txt/storage/emulated/0/DCIM/Camera/dec24.mp4 /storage/emulated/0/DCIM/Camera/vid2.mp4
12-16 19:49:57.416 5437-5437/? W/System.err﹕ com.netcompss.ffmpeg4android.CommandValidationException
12-16 19:49:57.416 5437-5437/? W/System.err﹕ at com.netcompss.loader.LoadJNI.run(LoadJNI.java:34)
12-16 19:49:57.416 5437-5437/? W/System.err﹕ at com.netcompss.loader.LoadJNI.run(LoadJNI.java:49)
I obtained the command from this stack question. Its accepted but I am facing the above issue. I am very sure that the videos are present in their respective locations and all the paths are right but I cant seem to make it work.
Any insights on this is highly appreciated. Thanks in advance.
Update :
Call to generateList:
ArrayList<String> paths_to_merge = new ArrayList<String>();
paths_to_merge.add(path + "/" + "dec24.mp4");
paths_to_merge.add(path + "/" + "vid2.mp4");
LoadJNI vk = new LoadJNI();
String[] v12 = new String[paths_to_merge.size()];
v12 = paths_to_merge.toArray(v12);
String list = generateList(v12);
I am not sure what went wrong in my code, I am still not able to come with the right list. However, I found another command which seems to be working good.
Command :
vk.run(new String[]{"ffmpeg","-y","-i",path + "/" + "num1.mp4","-i",path + "/" + "num2.mp4","-i",path + "/" + "num3.mp4","-i",path + "/" + "num4.mp4",
"-i",created_folder + "/" + "created_video2.mp4","-strict","experimental",
"-filter_complex",
"[0:v]scale=640x480,setsar=1:1[v0];[1:v]scale=640x480,setsar=1:1[v1];[2:v]scale=640x480,setsar=1:1[v2];[3:v]scale=640x480,setsar=1:1[v3];" +
"[4:v]scale=640x480,setsar=1:1[v4];[v0][0:a][v1][1:a][v2][2:a][v3][3:a][v4][4:a] concat=n=5:v=1:a=1",
"-ab","48000","-ac","2","-ar","22050","-s","640x480","-r","30","-vcodec","mpeg4","-b","2097k",path + "/" + "numbers_video_m.mp4"},path,getActivity());
As you can see in the command, I have appended 5 videos for the purpose of testing but I believe that we can add more videos dynamically and this works without any issues for me.
Things to be noted :
"-i",path + "/" + "num1.mp4"
represent the input and you can append as many as you want.
[0:v]scale=640x480,setsar=1:1[v0];
and add this according to the number of inputs accordingly as [0:v]...[1:v].. and so on.
[v0][0:a]
and also this parameter to be added according the number of inputs.
concat=n=5:v=1:a=1
Give the value of n according to the number of videos.
So those are the main things that needs to be taken care of.
I googled _ctx is Null and I was shocked to find nothing relating to Android. I am hoping this pose will help someone if we find the right answer.
Here is a link to the ANE I am using: https://github.com/pozirk/AndroidInAppPurchase
I have no idea where to go from here. It once worked now its not. :(
I am trying to use Pozirk's InAppPurchase.ane - which I have used before but suddenly its not working. I am not sure what changed. It may be, the ANE, or something in google play. Not sure but now its not working and I keep on getting this error:
_ctx is null.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.pozirk.payment.android::InAppPurchase/init()[C:\Users\blah\blah\Android\com\pozirk\payment\android\InAppPurchase.as:46]
at hereWeGo_fla::MainTimeline/fl_MouseClickHandler()[hereWeGo_fla.MainTimeline::frame1:97]
import com.pozirk.payment.android.InAppPurchase;
import com.pozirk.payment.android.InAppPurchaseEvent;
import flash.display.MovieClip;
/**
* ...
* #author Ben Barnard
*/
var _iap:InAppPurchase;
_iap = new InAppPurchase();
_iap.addEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess);
_iap.addEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_SUCCESS, onPurchaseSuccess);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_ALREADY_OWNED, onPurchaseSuccess);
_iap.addEventListener(InAppPurchaseEvent.PURCHASE_ERROR, onPurchaseError);
_iap.addEventListener(InAppPurchaseEvent.CONSUME_SUCCESS, onConsumeSuccess);
_iap.addEventListener(InAppPurchaseEvent.CONSUME_ERROR, onConsumeError);
_iap.addEventListener(InAppPurchaseEvent.RESTORE_SUCCESS, onRestoreSuccess);
_iap.addEventListener(InAppPurchaseEvent.RESTORE_ERROR, onRestoreError);
// Liscense Key
function onRestoreError(e:InAppPurchaseEvent):void
{
trace("Restore Error - " + e.toString());
outputField.text = "Restore Error - " + e.toString() + e.data.toString();
}
function onConsumeError(e:InAppPurchaseEvent):void
{
trace("Consume Error - " + e.toString());
outputField.text = "Consume Error - " + e.toString() + e.data.toString();
}
function onConsumeSuccess(e:InAppPurchaseEvent):void
{
trace("Consume Success - " + e.toString());
outputField.text = "Consume Success - " + e.toString();
// ------------------------------- THIS LINE PROMPTS THE USER TO PURCHASE THE ITEM ------------------------------- //
_iap.purchase("android.test.purchased", InAppPurchase.TYPE_INAPP);
}
function onPurchaseError(e:InAppPurchaseEvent):void
{
trace("Purchase Error - " + e.toString());
outputField.text = "Purchase Error - " + e.toString();
}
function onRestoreSuccess(e:InAppPurchaseEvent):void
{
trace("Restore Success - " + e.toString());
// ------------------------------- THIS LINE CONSUMES THE "TEST" ITEM ------------------------------- //
_iap.consume("android.test.purchased");
}
function onPurchaseSuccess(e:InAppPurchaseEvent):void
{
trace("Purchase Successful - " + e.data.toString());
outputField.text = "Purchase Successful - " + e.data.toString();
}
function onInitError(e:InAppPurchaseEvent):void
{
trace("Init Error - " + e.toString());
outputField.text = "Init Error - " + e.toString();
}
function onInitSuccess(e:InAppPurchaseEvent):void
{
trace("Init Success - " + e.toString());
outputField.text = "Init Success - " + e.toString();
// ------------------------------- THIS LINE RESTORES ALL PURCHASED ITEMS ------------------------------- //
//_iap.restore(InAppPurchase.TYPE_INAPP);
}
init.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
_iap.init("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiM0Lpjf/S5JQOh0L5c3IQNawziFTT9WeJ9fAmQl5nXJdfVnRK9+mMCnHJlKz8omt9RljlrtLpOV4iy+/KUFgtZ/SCvF+Brpk9lAEe+SbifT2mNGNKgF3tCXSHTXX2Xuq9kw1CR0bDy0Jf36LE04zBo4jYV4RcWQ66ViS2JbTEXAugG5S71z+CJXo6o5uYG/mRZlHFRJkpp1ufDFg4dp8r2ApN3RXhMv9Rl3NCcwTk3R0/rmwCc80Uy94kX7hkgeBuj/AViFZMbzYzY8YLdx80cYYHPc/ofecXmCl6OorJiBC+GiMs/vBoyjr4EGeIqfp1WdZrxeaJzMzAWPNoY4mSwIDAQAB");
}
purchase.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
//_iap.restore(InAppPurchase.TYPE_INAPP);
_iap.purchase("android.test.purchased", InAppPurchase.TYPE_INAPP);
}
consume.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);
function fl_MouseClickHandler_3(event:MouseEvent):void
{
//_iap.restore(InAppPurchase.TYPE_INAPP);
_iap.consume("android.test.purchased");
}
restore.addEventListener(MouseEvent.CLICK, rLove);
function rLove(event:MouseEvent):void
{
//_iap.restore(InAppPurchase.TYPE_INAPP);
_iap.restore(InAppPurchase.TYPE_INAPP);
}
You did not add ANE file to your project properly.
This question was already asked and answered:
http://inside.pozirk.com/2013/02/18/adobe-air-in-app-purchase-native-extensions/#comment-87
http://inside.pozirk.com/2013/02/18/adobe-air-in-app-purchase-native-extensions/#comment-89
My checklist, after tinkering FlashBuilder for 2 hours:
1) "project" > Properties > ActionScript Build Path > Native Extensions > Add ANE > "add InAppPurchase.ane"
2) "project" > Properties > ActionScript Build Packaging > Google Android > Native Extensions > "select package InAppPurchase.ane"
3) ... AS3 code uses the in-app-purchase API ...
4) The ANE seems to fail if you try to use it in debug mode; an exported APK should be used instead.
5) FlashBuilder > Project > Export Release Build:
Verify that the ANE is included in the package (Native Extensions)
Verify that your are using the correct signing certificate.
6) Copy the created APK to the Android device.
7) Install the APK using a file explorer.
8) The app finally runs, instead of crashing/hanging at startup.