-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Troubleshooting Android section #172
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Troubleshooting Android | ||
|
||
After installing Breez SDK into your application you might come across issues compiling on Android platforms because Breez SDK's Notification Plugin: | ||
- uses `kotlinx-serialization` dependency, | ||
- and it relies on JNA library. | ||
|
||
If you do, there are several steps you can take to compile and build properly, even if your application is not using the Notification Plugin feature. | ||
|
||
## kotlinx-serialization | ||
|
||
Starting with this 1.8.20 release, the Kotlin K2 compiler has a preview version of the serialization plugin. It's recommended for users to upgrade their Kotlin version to at least 1.8.20 or [set up the serialization plugin](https://github.com/Kotlin/kotlinx.serialization?tab=readme-ov-file#setup) on their projects explicitly with older versions. | ||
|
||
## JNA library | ||
|
||
JNA relies on specific class and method names to load native libraries and access native code. If these names are obfuscated or removed, it can cause runtime errors and failures in native library loading. | ||
|
||
The JNA library code obfuscation issue may not be apparent until your application is compiled on `release` mode with maximum optimization and minimal footprint size, that will be used when deploying and publishing an application. | ||
|
||
To ensure proper functionality, a Proguard rules needs to be added to explicitly tell R8 compiler to keep certain parts of the JNA library. Here is an example of Proguard rules: | ||
```pro | ||
-dontwarn dalvik.system.VMStack | ||
-dontwarn java.lang.** | ||
-dontwarn javax.naming.** | ||
-dontwarn sun.reflect.Reflection | ||
|
||
# JNA | ||
-keep class com.sun.jna.** { *; } | ||
-keep class * implements com.sun.jna.** { *; } | ||
|
||
# Other | ||
-dontoptimize | ||
``` | ||
|
||
These rules ensure that the JNA library's core components are not obfuscated, allowing the library to function correctly. See [Shrink, obfuscate, and optimize your app](https://developer.android.com/build/shrink-code) for more information on how and where to add Proguard rules on your app. | ||
|
||
## Inconsistent JVM-target compatibility | ||
|
||
It could be that compilation tasks for Java and Kotlin are using different JVM targets, in which case you need to set the [JVM toolchain](https://kotl.in/gradle/jvm/toolchain). In your application's `build.gradle` file in the `app` directory set the Java and Kotlin JVM targets consistently. | ||
``` | ||
kotlin { | ||
jvmToolchain(17) | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} | ||
|
||
android { | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_17 | ||
targetCompatibility JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '17' | ||
} | ||
} | ||
``` | ||
|
||
## Java heap space | ||
|
||
``` | ||
> Could not resolve all files for configuration | ||
> Failed to transform react-android-0.72.10-debug.aar (com.facebook.react:react-android:0.72.10) | ||
to match attributes {artifactType=android-symbol-with-package-name, | ||
com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, | ||
org.gradle.dependency.bundling=external, or g.gradle.libraryelements=aar, org.gradle.status=release, | ||
org.gradle.usage=java-api}. | ||
> Java heap error | ||
``` | ||
|
||
If you get a `Java heap space` error, try to increase the maximum memory allocation pool for the JVM in `gradle.properties`. | ||
|
||
``` | ||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=512m | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JNA library code obfuscation issue may not be apparent until users compile their apps on
"release"
mode with maximum optimization and minimal footprint size that'll be used when deploying & publishing their app.I think we should add a warning about this in this section.