update readme

This commit is contained in:
amauri 2024-04-10 10:49:31 +02:00
parent e68fdb2bc7
commit 935eec2a4b
1 changed files with 123 additions and 72 deletions

View File

@ -1,6 +1,7 @@
Android SDK
===================
# Android SDK
## Table of Contents
- [Import](#import)
- [Installation](#installation)
- [Project](#project)
@ -11,25 +12,36 @@ Android SDK
- [Authors](#authors)
<a name="import"></a>
## Import
You must use git to download the sdk from [repository](https://github.com/tecnaviapress/newsmemory-android-sdk)
1. The repository is private, to clone it you must generate an ssh key, see the [guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
2. Once the key is generate you must send to Tecnavia the public key and wait a confirmation that you are enabled
3. Inside root folder run the following command, replace TAG with the latest release, see the list on [releases](https://github.com/tecnaviapress/newsmemory-android-sdk/releases)
```sh
git clone --depth 1 --brach TAG git@github.com:tecnaviapress/newsmemory-android-sdk.git
```
4. if you already has the module you could update to another release by the following commands
```sh
cd newsmemory-android-sdk
git checkout tags/TAG
```
<a name="installation"></a>
## Installation
<a name="project"></a>
### Project Gradle
1. check main gradle repositories and dependencies
```java
buildscript {
repositories {
@ -69,6 +81,7 @@ allprojects {
```
2. if you are using sdk for amazon and it is built for it add the following maven repository
```java
maven {
url "https://s3.amazonaws.com/android-listener/mvn-repo"
@ -78,7 +91,7 @@ maven {
3. you could customize all dependencies version by updating the following variables, !pay attention, because the sdk may not starts or works properly add these variables to ext object in main gradle file, see below example.
| variable | default | Description |
|:---------------------------------- |:-------:|:-------------------------------------------------------------- |
| :--------------------------------------------------------------------------------------------------- | :-----: | :-------------------------------------------------------- |
| compileSdk | 33 | |
| targetSdk | 33 | |
| minSdk | 24 | |
@ -116,14 +129,21 @@ ext {
...
}
```
<a name="settings"></a>
### Settings Gradle
```java
include ':newsmemory-android-sdk'
```
<a name="app"></a>
### App Gradle
add the following lines if missing
```java
plugin: "com.android.application"
apply plugin: "com.google.gms.google-services"
@ -154,8 +174,11 @@ dependencies{
...
}
```
<a name="fragment"></a>
## Add fragment to activity
```java
public class YourActivity extends AppCompatActivity {
...
@ -229,11 +252,13 @@ public class YourActivity extends AppCompatActivity {
```
the following constant is required by SDK to be authorized
```java
bundle.putString(TaConstants.TA_API_KEY, "");
```
the following constants are required by SDK otherwise there will be some inconsinstecies and bugs
```java
bundle.putString(TaConstants.TA_APP_VERSION_NAME, getString(com.tecnavia.sdk.R.string.APP_VERSION_NAME));
bundle.putString(TaConstants.TA_APP_VERSION_CODE, getString(com.tecnavia.sdk.R.string.APP_VERSION_CODE));
@ -242,7 +267,8 @@ the following constants are required by SDK otherwise there will be some inconsi
bundle.putBoolean(TaConstants.TA_IS_ADDON, true);
```
1. The activity that load TaFragment must implement the following interface *DefaultHardwareBackBtnHandler*
1. The activity that load TaFragment must implement the following interface _DefaultHardwareBackBtnHandler_
```java
public class YourActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
...
@ -254,15 +280,18 @@ public class YourActivity extends AppCompatActivity implements DefaultHardwareBa
}
```
2. you could extends activity class with TaActivity that already has an implementation of *DefaultHardwareBackBtnHandler* but also add some other methods to force locale.
2. you could extends activity class with TaActivity that already has an implementation of _DefaultHardwareBackBtnHandler_ but also add some other methods to force locale.
```java
public class YourActivity extends TaActivity {
...
}
```
## Troubleshooting
1. if you have some build issues related to google play services versions you could add the following setting to build.gradle
## Troubleshooting Guide
1. **Google Play Services Build Issues**: If you encounter build issues related to Google Play Services versions, consider adding the following setting to your `build.gradle` file:
```java
android {
...
@ -272,11 +301,33 @@ android {
...
}
```
2. if you have the following error during the build `Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module`
add `--add-opens=java.base/java.io=ALL-UNNAMED` option to `org.gradle.jvmargs` entry in `gradle.properties`
```
2. **Java Base Access Error**: If you receive an error during the build process that reads `Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module`, add the `--add-opens=java.base/java.io=ALL-UNNAMED` option to the `org.gradle.jvmargs` entry in your `gradle.properties` file:
```plaintext
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 --add-opens=java.base/java.io=ALL-UNNAMED
```
3. **Orientation Change Crash**: If your application crashes when the orientation changes, add the following attributes to your activity in the Android manifest:
```plaintext
configChanges="...|screenLayout|screenSize|smallestScreenSize"
```
For more information, refer to this [GitHub issue comment](https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-923950313).
4. **Background or Awakening Crash**: If your application crashes when it moves to the background or wakes up, try adding the following to your activity:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
}
```
For more information, refer to this [GitHub issue comment](https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067).
## Authors
Nicolò Aquilini, iOS Software developer, Tecnavia
Andrea Mauri, Android Software developer, Tecnavia