Logcat error message - Attempted to destroy barrier with non zero count - java

I'm making an android app in Android Studio, integrating ParseCloud and when I try to retrieve some JSONObject from the cloud, I get this error message after step-debugging:
12-13 13:32:34.857 25631-25638/com.parse.starter A/art: art/runtime/barrier.cc:90] Check failed: count_ == 0 (count_=-1, 0=0) Attempted to destroy barrier with non zero count
12-13 13:32:34.858 25631-25638/com.parse.starter A/art: art/runtime/runtime.cc:366] Runtime aborting --- recursively, so no thread-specific detail!
12-13 13:32:34.863 25631-25638/com.parse.starter A/art: art/runtime/runtime.cc:366]
12-13 13:32:34.882 25631-25638/com.parse.starter A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 25638 (JDWP)
Problem arises in this piece of code in ParseDecoder.java, precisely on the while line:
Map<String, Object> convertJSONObjectToMap(JSONObject object) {
Map<String, Object> outputMap = new HashMap<>();
Iterator<String> it = object.keys();
while (it.hasNext()) {
String key = it.next();
Object value = object.opt(key);
outputMap.put(key, decode(value));
}
return outputMap;
}
As I've seen while debugging, the object I wait for is created and is filled with one entry, but then this happens and I'm little bit lost... Any guidance will be great, thank you very much!

I've solved the problem. I was using an old version of Parse library and it was interfering with the new one. I've just changed the Parse.initialize() lines to:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("MY_APP_ID")
.clientKey("MY_CLIENT_KEY")
.server("MY_SERVER_URL")
.build()
);
and it worked!

Related

Trying to get balance with web3j (Android), geting nullpointer exception

Struggling getting anything to work in web3j on android, trying this example (I have replaced token and addr) the address I used does have some rinkeby ETH in it. Testing on phone, application crashes when I load up this class/activity, code is in the oncreate method. Have internet permission turned on in the manifest, and compile android web3j in the build gradle.
Web3j web3 = Web3jFactory.build(new
HttpService("https://rinkeby.infura.io/token"));
EthGetBalance ethGetBalance = null;
try {
ethGetBalance = web3
.ethGetBalance("addr",DefaultBlockParameterName.LATEST)
.sendAsync()
.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
BigInteger wei = ethGetBalance.getBalance();
The error
06-30 02:15:47.115 18904-18904/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.user.test, PID: 18904
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.user.test/com.test.user.test.balance}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2607)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5756)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.test.user.test.balance.onCreate(balance.java:43)
at android.app.Activity.performCreate(Activity.java:5619)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2512)
Line 43 referenced in error is the last line of code in my submitted code. When I comment out that line app doesn't crash and just get a few (what I assume are all) warnings.
Your ethGetBalance return a null value .i think you put a invalid address. thats why method
web3j.ethGetBalance failes. try this with valid address.
Web3j web3 = Web3jFactory.build(new HttpService("https://ropsten.infura.io/your-token"));
String strAddress="0x24b********************"; //strAddress is your wallet address
EthGetBalance ethGetBalance=
web3.ethGetBalance(strAddress,DefaultBlockParameterName.LATEST).sendAsync().get();
BigInteger wei = ethGetBalance.getBalance();
ethGetBalance.getBalance() is used to get your ether balance in wei.
To get actual token in your wallet use this Conversion method.
java.math.BigDecimal tokenValue = Convert.fromWei(String.valueOf(wei), Convert.Unit.ETHER);
String strTokenAmount = String.valueOf(tokenValue);
ethGetBalance = web3.ethGetBalance(public_address, DefaultBlockParameterName.LATEST).sendAsync().get();
BigInteger wei = ethGetBalance.getBalance();
Log.e("ether balance", "wei" + wei);
This is working fine in my app which is available on playstore
https://play.google.com/store/apps/details?id=multi.erc20.devgenesis.token.wallet
The problem is that the ethGetBalance is null, when you want to access it, because the method web3j.ethGetBalance fails.
You are sending "addr" as an address, this is not a valid Ethereum address.
A valid Ethereum address has a format similar that begins with: 0x and then has 40 elements (digits 0-9 or letters A to F).
To see if your address exists, just try to find it in the website https://etherscan.io/
Try with a correct Ethereum address and it should work.
EthGetBalance ethGetBalance = web3j
.ethGetBalance(userAddress, DefaultBlockParameterName.LATEST)
.sendAsync()
.get();
BigInteger wei = ethGetBalance.getBalance();

How to fix mismatch processor architecture, unexpected e_machine, due to a .so file

I have a Xamarin android project and am currently using Visual Studio 2015.
Inside of my MainActivity.cs, I have the following code:
Com.Alk.Sdk.SharedLibraryLoader.LoadLibrary("alksdk", this);
which then goes into:
// Metadata.xml XPath method reference: path="/api/package[#name='com.alk.sdk']/class[#name='SharedLibraryLoader']/method[#name='loadLibrary' and count(parameter)=2 and parameter[1][#type='java.lang.String'] and parameter[2][#type='android.content.Context']]"
[Register ("loadLibrary", "(Ljava/lang/String;Landroid/content/Context;)Z", "")]
public static unsafe bool LoadLibrary (string p0, global::Android.Content.Context p1)
{
if (id_loadLibrary_Ljava_lang_String_Landroid_content_Context_ == IntPtr.Zero)
id_loadLibrary_Ljava_lang_String_Landroid_content_Context_ = JNIEnv.GetStaticMethodID (class_ref, "loadLibrary", "(Ljava/lang/String;Landroid/content/Context;)Z");
IntPtr native_p0 = JNIEnv.NewString (p0);
try {
JValue* __args = stackalloc JValue [2];
__args [0] = new JValue (native_p0);
__args [1] = new JValue (p1);
bool __ret = JNIEnv.CallStaticBooleanMethod (class_ref, id_loadLibrary_Ljava_lang_String_Landroid_content_Context_, __args);
return __ret;
} finally {
JNIEnv.DeleteLocalRef (native_p0);
}
}
The problem I am having is that when it calls the JNIEnv.CallStaticBooleanMethod, it throws this exception:
[ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.pai.rp/app_lib/libalksdk.so" has unexpected e_machine: 3
--- End of managed Java.Lang.UnsatisfiedLinkError stack trace ---
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.pai.rp/app_lib/libalksdk.so" has unexpected e_machine: 3
at java.lang.Runtime.load0(Runtime.java:908)
at java.lang.System.load(System.java:1542)
at com.alk.sdk.SharedLibraryLoader.loadLibrary(SharedLibraryLoader.java:44)
at com.pai.rp.MainActivity.n_onCreate(Native Method)
at com.pai.rp.MainActivity.onCreate(MainActivity.java:30)
at android.app.Activity.performCreate(Activity.java:6973)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1557)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
From what I've been able to research I've found that
e_machine: 3 indicates the expected arch is Intel 80386 (ELF Headers).
When using a Google Nexus 10 emulator it seems to work, however when
I use the Galaxy Tab E (ARM) through USB debugging, it crashes and gives me
this error.
So the question is, how do I correct this?

Android SQLiteDiskIOException disk I/O error (code 522)

Yesterday from Crashlytics I noticed disk I/O error (code 522) while opening the database. Problem is that this crashed already has been reported from 16 users 36 times. Sadly I can't reproduce this error. Here's the code fragment where error occurs
SessionDbManager(Context context, String tripDbFileName) {
this.context = context;
this.tripDbFileName = tripDbFileName;
this.tripDbHelper = new SessionDbHelper(this.context, tripDbFileName);
SQLiteDatabase database = null;
int attempt = 1;
while (database == null) {
try {
database = this.tripDbHelper.getWritableDatabase(); // here's the error
} catch (android.database.sqlite.SQLiteException e) {
Crashlytics.logException(e);
XLog.e("Failed to load history data from database ", e);
if (attempt == 5) throw e;
}
attempt++;
}
db = database;
}
And here's the stack trace
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 522): , while compiling: PRAGMA journal_mode
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:932)
at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:677)
at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:363)
at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:337)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:251)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:195)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:737)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at eu.fishingapp.data.sql.session.SessionDbManager.(SourceFile:51)
at eu.fishingapp.data.sql.session.SessionContentProvider.update(SourceFile:753)
at android.content.ContentProvider$Transport.update(ContentProvider.java:384)
at android.content.ContentResolver.update(ContentResolver.java:1412)
at eu.fishingapp.data.sql.session.SessionDbHelper.renameSessionDb(SourceFile:584)
at eu.fishingapp.data.network.synchronization.FileSyncServiceImpl.uploadFile(SourceFile:462)
at eu.fishingapp.data.network.synchronization.FileSyncServiceImpl.uploadSessions(SourceFile:221)
at eu.fishingapp.data.network.synchronization.FileSyncServiceImpl.uploadSessionsFiles(SourceFile:243)
at eu.fishingapp.data.network.synchronization.FileSyncIntentService.onHandleIntent(SourceFile:116)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:67)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
I have read about I/O error and found two possible answers I was thinking that this is because users ran out of free space on their devices. But here's some images from two app users
So this is definitely not storage issue :( Any ideas how to solve this problem?
EDIT: targetSdk version 22

Out of Memory on Samsung Galaxy devices

I've really tried my best, but I just can't find a fix for this Problem.
I wrote a Soundboard for Android devices, where every sound as well as its button images is loaded dynamically.
Here is the crucial paragraph in my code:
private void loadButtonColors(){
int rescount = AppConfig.BUTTONBACKGROUNDSRES(getApplicationContext()).size();
SharedPreferences prefs = getSharedPreferences("buttoncolors", 0);
String colors = null;
colors = prefs.getString("colors", null);
List<String> tempList = new ArrayList<String>();
if(colors != null){
tempList.addAll(Arrays.asList(TextUtils.split(colors, "~")));
}
if(colors == null || tempList.size() != MainActivity.SOUNDBUTTONS.size()){
for(#SuppressWarnings("unused") SoundButton s : MainActivity.SOUNDBUTTONS){
int randomint = new Random().nextInt(rescount);
Integer randominteger = Integer.valueOf(randomint);
String randomstring = String.valueOf(randominteger);
tempList.add(randomstring);
}
prefs.edit().putString("colors", TextUtils.join("~", tempList)).commit();
}
MainActivity.BUTTONCOLORS = (ArrayList<String>) tempList;
}
Later the button's images will be displayed with the images out of the following Arrays where the error seems to arise.
public static ArrayList<Drawable> BUTTONBACKGROUNDSRES(Context context){
ArrayList<Drawable> tempList = new ArrayList<Drawable>();
tempList.add(context.getResources().getDrawable(R.color.button_lblue));
tempList.add(context.getResources().getDrawable(R.color.button_lime));
tempList.add(context.getResources().getDrawable(R.color.button_orange));
tempList.add(context.getResources().getDrawable(R.color.button_pink));
tempList.add(context.getResources().getDrawable(R.color.button_red));
tempList.add(context.getResources().getDrawable(R.color.button_yellow));
return tempList;
};
The resulting error looks like this:
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2150)
at android.content.res.Resources.getDrawable(Resources.java:715)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:176)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
at android.content.res.Resources.loadDrawable(Resources.java:2132)
at android.content.res.Resources.getDrawable(Resources.java:715)
at com.centivo.inscope21soundboard.AppConfig.BUTTONBACKGROUNDSRES(AppConfig.java:45)
at com.centivo.inscope21soundboard.LauncherActivity.loadButtonColors(LauncherActivity.java:128)
at com.centivo.inscope21soundboard.LauncherActivity.access$1(LauncherActivity.java:127)
at com.centivo.inscope21soundboard.LauncherActivity$1.run(LauncherActivity.java:43)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
If you wanna check out the App visit the Playstore
EDIT: The size of every button image is about 70kb.
If you are running out of memory, store the tempList in BUTTONBACKGROUNDSRES in a member or static variable. It looks like every time you call BUTTONBACKGROUNDSRES, you are going to load a new set of Drawables. If these are always the same, there is no sense in loading them frequently from scratch and then leaving the tempList to be garbage collected. Just create the list once, then refer it.

confusion in acquiring and releasing of locks

I have the following code snippet from Client of an Android emulator:
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,String sortOrder) {
String key = selection;
String keyHash = genHash(key);
Log.v("provider.query","Key & keyHash: "+key+" & "+keyHash);
if(SimpleDhtUtil.toForward(keyHash, currentHash, predecessorHash)){
DhtDto dto = new QueryTransfer(successorPort, currentPort, -1, key, keyHash);
st.makeSendRequest(dto);
synchronized(BigLock.LOCK){
SimpleDhtUtil.cursorReset();
requiredAnswers = 1;
currentAnswers = 0;
}
while(requiredAnswers>currentAnswers){
synchronized(BigLock.LOCK){
try{
if(requiredAnswers>currentAnswers){
Log.d("provider.externalQueryLock","CA: "+currentAnswers+"RA: "+requiredAnswers+" Waiting... "+BigLock.LOCK);
BigLock.LOCK.wait();
Log.d("provider.externalQueryLock","Woke up");
}
}catch(InterruptedException e){
Log.e("provider.query", "InterruptedException",e);
}
}
}
return SimpleDhtUtil.getCursor();
}
The following code in the Server of the same AVD:
private void acceptAnswer(QueryAcknowledge qa) {
// Object lock = SimpleDhtProvider.externalQueryLock;
synchronized(BigLock.LOCK){
SimpleDhtProvider.currentAnswers += 1;
Log.d("ReceiverTask.acceptAnswer","Got result. Current count: "+SimpleDhtProvider.currentAnswers);
SimpleDhtUtil.addValues(qa.getRecords());
Log.d("ReceiverTask.acceptAnswer","Aggregated result. Net count: "+SimpleDhtUtil.getCursor().getCount());
BigLock.LOCK.notifyAll();
Log.d("ReceiverTask.acceptAnswer","lock released: "+BigLock.LOCK);
}
}
Now the problem is that when releasing the lock in the server code, I want the lock in the client to be notified and awoken. This happens >80% of the time. But sometimes it gets stuck. Find the android log below. Also, the currentAnswers and requiredAnswers are always being handled from the client, i.e., these variables are static and volatile in Client and BigLock is an enum with only one value as LOCK.
Client log:
04-14 08:14:07.172: V/provider.query(2699): Key & keyHash: 6oLNUimWIuAM4YWN183cwtz0te5aq6r7 & 837cccd1cac03a9c4c9169fad595a997d2673920
04-14 08:14:07.202: D/provider.externalQueryLock(2699): CA: 0RA: 1 Waiting... LOCK
Server log:
04-14 08:14:07.192: D/ReceiverTask.acceptAnswer(2699): Got result. Current count: 2
04-14 08:14:07.192: D/ReceiverTask.acceptAnswer(2699): Aggregated result. Net count: 2
04-14 08:14:07.192: D/ReceiverTask.acceptAnswer(2699): lock released: LOCK
The problem here is that I was resetting the cursor after sending the request from the client assuming that the Server would receive reply after resetting the cursor in the next line.
The correct order is first reset the cursor and then send the request.

Categories

Resources