Skip to content

Troubleshooting

1. SDK Initialization Fails

Problem: IllegalArgumentException during initialization

// ❌ Common mistakes
AlphynSDK.initialize(null); // Null context
AlphynSDK.initialize(); // Missed context

Solution:

// ✅ Correct initialization
try {
AlphynSDK.initialize(getApplicationContext());
} catch (IllegalArgumentException e) {
Log.e("Byteria", "Invalid initialization parameters: " + e.getMessage());
}

2. Native Library Not Found

Problem: UnsatisfiedLinkError when loading native library

Solution:

The SDK ships native libraries for arm64-v8a, armeabi-v7a, and x86_64. If your app restricts ABIs with ndk.abiFilters, make sure the filter includes an ABI the device supports (or remove the filter). The SDK links its C++ runtime statically and ships no shared libc++_shared.so, so no pickFirst rule is needed for it.

3. Memory Leaks from Listeners

Problem: Activity/Fragment leaks due to listener references

Solution:

public class LeakSafeListener implements AlphynSecurityListener {
private final WeakReference<Activity> activityRef;
public LeakSafeListener(Activity activity) {
this.activityRef = new WeakReference<>(activity);
}
@Override
public void onSuccess(AlphynCallbackResult result) {
Activity activity = activityRef.get();
if (activity != null && !activity.isFinishing()) {
// Handle result
}
}
// Always remove listeners
@Override
protected void onDestroy() {
super.onDestroy();
AlphynSDK.removeSecurityListener(listener);
}
}

4. ProGuard/R8 Obfuscation Issues

Problem: SDK classes get obfuscated and break functionality

Note: The Alphyn AAR ships consumer ProGuard rules that R8 applies to your app automatically, so this should not happen with a standard Gradle build. Add the rules below manually only if your build pipeline strips consumer rules.

Solution:

# Byteria SDK - Keep all classes and methods
-keep class com.byteria.sdk.** { *; }
# Keep classes with @Keep annotation
-keep @androidx.annotation.Keep class * { *; }
-keepclassmembers class * {
@androidx.annotation.Keep <methods>;
}
# Keep native methods
-keepclasseswithmembernames class * {
native <methods>;
}

Enable Debug Logging:

public class DebugSecurityListener implements AlphynSecurityListener {
private static final String TAG = "ByteriaDebug";
@Override
public void onSuccess(AlphynCallbackResult result) {
Log.d(TAG, String.format("SUCCESS: %s | %s | %s",
result.getOperationType(),
result.getOriginalEventType(),
result.getMessage()));
}
@Override
public void onFailure(AlphynCallbackResult result) {
Log.w(TAG, String.format("FAILURE: %s | %s | %s | %s",
result.getOperationType(),
result.getOriginalEventType(),
result.getMessage(),
result.getDetails()));
}
@Override
public void onThreatDetected(AlphynCallbackResult result) {
Log.e(TAG, String.format("THREAT: %s | %s",
result.getOriginalEventType(),
result.getMessage()));
}
}

Event Timing Analysis:

public class EventTimingAnalyzer {
private final Map<AlphynEventType, Long> eventTimings = new HashMap<>();
public void recordEvent(AlphynCallbackResult result) {
AlphynEventType eventType = result.getOriginalEventType();
long currentTime = System.currentTimeMillis();
Long previousTime = eventTimings.put(eventType, currentTime);
if (previousTime != null) {
long interval = currentTime - previousTime;
Log.d("EventTiming", String.format("%s interval: %dms",
eventType, interval));
}
// Log event details
Log.d("EventDetails", String.format("Event: %s, Type: %s, Message: %s",
eventType, result.getOperationType(), result.getMessage()));
}
}