I build React Native Released Version and publish it Google Play Store.
But it doesn't work.
Do not move to next HomeScreen from SplashScreen.
So I test with My Android Emulator and suddenly Meteor JS Bundle Run on Terminal and works like Debug version.
Similiar with this bug
https://github.com/facebook/react-native/issues/16793
But solution of this link doesn't work for me.
The solution is to remove "import com.facebook.react.BuildConfig;" line, but I don't have.
This is the code of MainApplication
package org.sharingappforstudent;
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import com.facebook.react.ReactApplication;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import org.wonday.pdf.RCTPdfView;
import com.RNFetchBlob.RNFetchBlobPackage;
import cl.json.RNSharePackage;
import com.reactlibrary.RNMailCorePackage;
import com.magus.fblogin.FacebookLoginPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.imagepicker.ImagePickerPackage;
import io.fabric.sdk.android.Fabric;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.AlexanderZaytsev.RNI18n.RNI18nPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SplashScreenReactPackage(),
new RCTPdfView(),
new RNFetchBlobPackage(),
new RNSharePackage(),
new RNMailCorePackage(),
new FacebookLoginPackage(),
new PickerPackage(),
new VectorIconsPackage(),
new ImagePickerPackage(),
new RNFirebasePackage(),
new RNI18nPackage(),
new RNFirebaseStoragePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseDatabasePackage(),
new RNFirebaseMessagingPackage(),
new MapsPackage()
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
SoLoader.init(this, /* native exopackage */ false);
}
}
app/build.gradle file
apply plugin: "com.android.application"
apply plugin: 'io.fabric'
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "org.sharingappforstudent"
minSdkVersion 23
targetSdkVersion 23
versionCode 11
versionName "1.3"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
// (!!!ATTENTION!!!) FIX FOR MAIL CORE DEPENDENCIES (!!!DO NOT REMOVE!!!)
packagingOptions {
pickFirst 'lib/armeabi-v7a/libgnustl_shared.so'
pickFirst 'lib/arm64-v8a/libgnustl_shared.so'
pickFirst 'lib/x86_64/libgnustl_shared.so'
pickFirst 'lib/x86/libgnustl_shared.so'
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
dexOptions {
jumboMode true
}
}
dependencies {
compile project(':react-native-splash-screen')
compile project(':react-native-pdf')
compile project(':react-native-fetch-blob')
compile project(':react-native-share')
compile(project(':react-native-mailcore'))
compile project(':react-native-facebook-login')
compile project(':react-native-image-crop-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-image-picker')
compile (project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile project(':react-native-i18n')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.google.firebase:firebase-messaging:12.0.0"
compile project(':react-native-facebook-login')
compile(project(':react-native-firebase')) {
transitive = false
}
// Firebase dependencies
compile "com.google.android.gms:play-services-base:12.0.0"
compile 'com.google.android.gms:play-services-maps:12.0.0'
compile "com.google.firebase:firebase-core:12.0.0"
compile "com.google.firebase:firebase-storage:12.0.0"
compile "com.google.firebase:firebase-auth:12.0.0"
compile "com.google.firebase:firebase-database:12.0.0"
compile "me.leolin:ShortcutBadger:1.1.21#aar"
compile('com.crashlytics.sdk.android:crashlytics:2.9.0#aar') {
transitive = true
}
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
Need help.
Thanks.
Related
I'm trying to ressurect a kotlin app that used to Just Workâ˘, i.e., compile straight away, on Ubuntu 16.04.
Part of it is generated code, but i get compilation errors because there is, for instance, no PersonEntity class. So this code fails:
public final void getName(#org.jetbrains.annotations.Nullable()
android.widget.ImageView view, #org.jetbrains.annotations.NotNull()
com.my.app.model.Plus item, #org.jetbrains.annotations.Nullable()
android.widget.ImageView parent, #org.jetbrains.annotations.NotNull()
PersonEntity line) {
}
I have two viable candidates:
Person.java:
package com.my.package.model;
import android.databinding.Observable;
import android.os.Parcelable;
import java.io.Serializable;
import io.requery.Entity;
import io.requery.Key;
import io.requery.Persistable;
#Entity
public interface Person extends Observable, Parcelable, Persistable, Serializable {
#Key
long getID();
int getAge();
...
DbPerson.kt:
package com.my.package.DbObjects
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName
class DbPerson {
#SerializedName("ID")
#Expose
var id: String =""
#SerializedName("Age")
#Expose
var age: String =""
I see kapt generates a lot of class files, e.g.:
./app/build/tmp/kapt3/incrementalData/debug/com/my/package/DbObjects/DbPerson.class
./app/build/tmp/kapt3/stubs/debug/com/my/package/DbObjects/DbPerson.java
./app/build/tmp/kapt3/stubs/debug/com/my/package/DbObjects/DbPerson.kapt_metadata
...but no PersonEntity.java. Actually, no *Entity* files whatsoever.
I'm not sure if this was because the *.model files are Java instad of kotlin, so i migrated them to kotlin, and got different errors. Maybe because they're interfaces and not regular classes? But then where are the other *Entity* files?
This is my build.gradle:
buildscript {
ext {
setup = [
compileSdk: 27,
buildTools: "27.0.1",
minSdk : 14,
targetSdk : 27
]
versions = [
supportLib: "27.0.1"
]
kotlin_version = '1.3.31'
}
repositories {
google()
jcenter() // w: JCenter is at end of life
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
//classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.jaredsburrows:gradle-spoon-plugin:1.4.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my app/build.gradle:
apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "com.jaredsburrows.spoon"
android {
lintOptions {
abortOnError false
}
compileSdkVersion 27
defaultConfig {
multiDexEnabled true
applicationId "com.my.package"
minSdkVersion 19
targetSdkVersion 26
versionCode 9 //db_version too
versionName "2.31"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "com.my.app.activities.CustomTestRunner"
resValue "string", "app_build_number", (System.getenv("BUILD_NUMBER") ?: "IDE")
resValue "string", "server_address", "1.2.3.4"
project.ext.set("archivesBaseName", "MyAppName-" + System.getenv("BRANCH_NAME") + "-v" + defaultConfig.versionName + "." + (System.getenv("BUILD_NUMBER") as Integer ?: 0).toString())
}
signingConfigs {
release {
storeFile file("myKey.jks")
storePassword 'mypassword'
keyAlias 'mykeyalias'
keyPassword 'mypassword'
}
}
buildTypes {
release {
resValue "string", "server_address", ""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
no_wifi_check
{
resValue "string", "app_build_number", "NOWIFI"
signingConfig signingConfigs.release
}
debug {
resValue "string", "server_address", "1.2.3.4"
}
}
buildFeatures {
dataBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8' // Java 7 not supported by kotlinOptions jvmTarget
}
}
dependencies {
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'xml-apis:xml-apis:2.0.2'
implementation 'xerces:xercesImpl:2.12.0'
implementation 'com.android.support:multidex:1.0.3'
androidTestImplementation('com.android.support:multidex-instrumentation:1.0.3') {
exclude group: 'com.android.support', module: 'multidex'
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
//implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31"
/* ^ w: Plugin version (1.5.0) is not the same as library version (1.3.31)
A newer version of org.jetbrains.kotlin:kotlin-stdlib-jdk8 than 1.3.31 is available: 1.4.31 */
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2' // w: A newer version of com.android.support.constraint:constraint-layout than 1.0.2 is available: 2.0.4
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
//requery
implementation 'io.requery:requery:1.4.1'
implementation 'io.requery:requery-android:1.4.1' // for android
//annotationProcessor 'io.requery:requery-processor:1.4.1'
kapt("io.requery:requery-processor:1.4.1")
//Picasso
implementation 'com.squareup.picasso:picasso:2.5.2'
//okhttp
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
//AndroidSlidingUpPanel
implementation 'com.sothree.slidinguppanel:library:3.4.0'
//
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
//MaterialDrawer
implementation("com.mikepenz:materialdrawer:6.0.9#aar") {
transitive = true
}
//required support lib modules
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
//implementation "com.android.support:support-annotations:${versions.supportLib}"
implementation "com.android.support:support-annotations"
implementation 'com.android.support:design:27.1.1'
// the sample uses more advanced functions of the fastadapter
// https://github.com/mikepenz/FastAdapter/
implementation 'com.mikepenz:fastadapter-commons:3.2.8#aar'
// used to generate the Open Source section
// https://github.com/mikepenz/AboutLibraries
implementation('com.mikepenz:aboutlibraries:6.0.0#aar') {
transitive = true
}
//used to provide different itemAnimators for the RecyclerView
//https://github.com/mikepenz/ItemAnimators
implementation 'com.mikepenz:itemanimators:1.0.1#aar'
// used to provide the MiniDrawer to normal Drawer crossfade effect via a SlidingPane layout
// --> https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/MiniDrawerActivity.java
// https://github.com/mikepenz/Crossfader
implementation 'com.mikepenz:crossfader:1.5.1#aar'
// used to provide the two step crossfade DrawerLayout. Which allows to have a mini layout which transforms to a normal layout within the drawer
// --> https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/CrossfadeDrawerLayoutActvitiy.java
// https://github.com/mikepenz/CrossfadeDrawerLayout
implementation('com.mikepenz:crossfadedrawerlayout:1.0.1#aar')
// icon fonts used inside the sample
// https://github.com/mikepenz/Android-Iconics
implementation 'com.mikepenz:google-material-typeface:3.0.1.1.original#aar'
implementation 'com.mikepenz:fontawesome-typeface:4.7.0.1#aar'
implementation 'com.mikepenz:octicons-typeface:3.0.0.1#aar'
implementation('com.mikepenz:materialdrawer:6.0.9#aar') { transitive = true }
// icon fonts used inside the sample
// https://github.com/mikepenz/Android-Iconics
implementation 'com.mikepenz:google-material-typeface:3.0.1.1.original#aar'
implementation 'com.mikepenz:fontawesome-typeface:4.7.0.1#aar'
implementation 'com.mikepenz:octicons-typeface:3.0.0.1#aar'
//Toasty
implementation 'com.github.GrenderG:Toasty:1.2.8'
//android fab
//compile 'uk.co.markormesher:android-fab:2.0.0'
//FloatingActionButton
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.jaredrummler:colorpicker:1.0.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestImplementation 'com.squareup.spoon:spoon-client:1.6.4'
}
kapt {
//generateStubs = true
useBuildCache = false
correctErrorTypes = true
}
apply plugin: 'spoon'
// This section is optional
spoon {
// for debug output
debug = true
// To run a single test class
className = 'fully.qualified.TestCase'
// To run a single method in TestCase
methodName = 'testMyApp'
// To execute the tests device by device */
sequential = true
// To grant permissions to Android M >= devices */
grantAllPermissions = true
}
android.applicationVariants.all { variant ->
def applicationId = variant.applicationId
def adb = android.getAdbExe().toString()
def variantName = variant.name.capitalize()
def grantPermissionTask = tasks.create("grant${variantName}Permissions") { doLast {
"${adb} devices".execute().text.eachLine {
if (it.endsWith("device")) {
def device = it.split()[0]
println "Granting permissions on devices ${device}"
"${adb} -s ${device} shell pm grant ${applicationId} android.permission.CAMERA".execute()
"${adb} -s ${device} shell pm grant ${applicationId} android.permission.ACCESS_FINE_LOCATION".execute()
"${adb} -s ${device} shell pm grant ${applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute()
"${adb} -s ${device} shell pm grant ${applicationId} android.permission.READ_EXTERNAL_STORAGE".execute()
}
}
}
}
}
I assume there's a mismatch somewhere between plugin versions, Java version, kotlin version, gradle, etc... but i can't place it.
** EDIT **
The same project builds on:
Windows 10 VM
Android Studio 4.1
whichever JDK is in C:\Program Files\Android\Android Studio\jre (the release file has JAVA_VERSION="1.8.0_242")
but not on:
Ubuntu Xenial VM
Android Studio 4.2.1
whichever JDK is in ${HOME}/android-studio/jre (the release file has JAVA_VERSION="11.0.8", which is too different to make sense).
Problem:
I'm trying to recreate this codelab tutorial project https://developer.android.com/codelabs/android-proto-datastore, but Android Studio can't import androidx.datastore.dataStore
Steps:
create new Kotlin project with an empty Acivity
modify gradle file
Switch to Android Studio's Project view
create a folder named proto inside of app/src/main
create and modify file user_prefs.proto inside of app/src/main/proto
Build -> Clean Project -> rebuild project
Create a serializer class called UserPreferencesSerializer
Trying to add the following Code to the empty MainActivity.kt
private const val DATA_STORE_FILE_NAME = "user_prefs.pb"
private val Context.userPreferencesStore: DataStore
by dataStore(
fileName = DATA_STORE_FILE_NAME,
serializer = UserPreferencesSerializer )
After this step Android Studio marks dataStore and shows the warning "Unresolved reference: dataStore" I'm also unable to import androidx.datastore.dataStore, but I can't find a missing import in my gradle file. Please, can someone tell me how I can resolve this problem?
Code:
build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id "com.google.protobuf" version "0.8.12"
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.datastore:datastore-core:1.0.0-alpha08"
implementation "com.google.protobuf:protobuf-javalite:3.11.0"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.10.0"
}
// Generates the java Protobuf-lite code for the Protobufs in this project. See
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option 'lite'
}
}
}
}
}
user_prefs.proto
syntax = "proto3";
option java_package = "com.example.test";
option java_multiple_files = true;
message UserPreferences {
// filter for showing / hiding completed tasks
bool show_completed = 1;
}
UserPreferencesSerializer
package com.example.test
import androidx.datastore.core.CorruptionException
import androidx.datastore.core.Serializer
import com.google.protobuf.InvalidProtocolBufferException
import java.io.InputStream
import java.io.OutputStream
object UserPreferencesSerializer : Serializer<UserPreferences> {
override val defaultValue: UserPreferences = UserPreferences.getDefaultInstance()
override suspend fun readFrom(input: InputStream): UserPreferences {
try {
return UserPreferences.parseFrom(input)
} catch (exception: InvalidProtocolBufferException) {
throw CorruptionException("Cannot read proto.", exception)
}
}
override suspend fun writeTo(t: UserPreferences, output: OutputStream) = t.writeTo(output)
}
MainActivity.kt
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.datastore.core.DataStore
private const val DATA_STORE_FILE_NAME = "user_prefs.pb"
private val Context.userPreferencesStore: DataStore<UserPreferences> by dataStore(
fileName = DATA_STORE_FILE_NAME,
serializer = UserPreferencesSerializer
)
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
I also had this problem while working on a project.
I found that I was using datastore-core and needed datastore-preferences. So I changed my dependency declaration from:
implementation 'androidx.datastore:datastore-core:1.0.0-alpha08'
to:
implementation 'androidx.datastore:datastore-preferences:1.0.0'
Possibly there was a breaking change between alpha08 and the 1.0.0 release.
The dataStore delegate is part of the androidx.datastore:datastore library.
Add the dependency to your modudle's build.gradle file. Replace $dataStoreVersion with the version of data store which you use, e.g. 1.0.0:
implementation "androidx.datastore:datastore:$dataStoreVersion"
You can find the available versions here in Google's Maven repository.
After adding this dependency, you can use by dataStore by adding the following import to your class:
import androidx.datastore.dataStore
In Android documentation:
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
This line should be at the top of your code.
See DataStore documenation
After a lot of searching, The problem is simple. Make sure Gradle is not in offline mode.
Also, ensure that you use this dependency.
implementation "androidx.datastore:datastore-preferences:$dataStoreVersion"
i should call function from native-android to react-native, so i set bridge. before set bridge, apk run & virtual run worked well.
but after set, vertual run work too, but apk run is not work.
i can't find the reason.
KeyStoreApi.java
package com.tovidapp;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.uimanager.IllegalViewOperationException;
public class KeyStoreApi extends ReactContextBaseJavaModule {
public KeyStoreApi(ReactApplicationContext reactContext){
super(reactContext);
}
#Override
public String getName(){
return "KeyStoreApi";
}
#ReactMethod
public void sayHi(Callback errCallBack, Callback successCallBack){
try{
System.out.println("Hello, i am from java");
successCallBack.invoke("Callback: Greeting from java");;
}catch (IllegalViewOperationException e){
errCallBack.invoke(e.getMessage());
}
}
}
KeyStoreApiPackage.java
package com.tovidapp;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class KeyStoreApiPackage implements ReactPackage {
#Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext){
return Collections.emptyList();
}
#Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext){
List<NativeModule> modules = new ArrayList<>();
modules.add(new KeyStoreApi(reactContext));
return modules;
}
}
build.grade
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.tovidapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-youtube')
implementation project(':react-native-vector-icons')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
call.js
import React, {Component} from 'react';
import {View, Text, NativeModules, TouchableOpacity,} from 'react-native';
const keyStoreApi = NativeModules.KeyStoreApi;
class Account extends Component {
async sayHiFromJava() {
keyStoreApi.sayHi(err => {
alert(err);
}, msg => {
alert(msg);
})
}
render() {
return (
<View>
<TouchableOpacity onPress={this.sayHiFromJava}>
<Text>TEST</Text>
</TouchableOpacity>
</View>
);
}
}
export default Account;
script in package.json
"android-apk": "react-native run-android --variant=release",
"android-virtual": "react-native run-android",
"android-build": "rm android/app/build/outputs/apk/release/app-release.apk & cd android && ./gradlew assembleRelease",
Result image
in apk
-in simple virtual machine
I switched from react native navigation v1 to v2 and I have theses 5 errors when trying to sync my files with Android Studio.
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :react-native-navigation.
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve project :react-native-navigation.
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve project :react-native-navigation.
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
I tried to clear .iml files and .idea folder, invalidate caches and restart.
Configuration:
react-native: 0.51.0,
react-native-navigation: ^2.4.0,
Android Studio: 3.1.1
Android build.gradle
buildscript {
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
jcenter()
}
}
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative55") || names.contains("reactNative56") || names.contains("reactNative57")) {
setIgnore(true)
}
}
}
}
}
}
App build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.myapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51"
multiDexEnabled true
versionCode 723
versionName "1.72"
ndk {
abiFilters "armeabi-v7a", "x86"
}
versionNameSuffix '3'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
productFlavors {
}
}
dependencies {
compile project(':react-native-appsflyer')
compile project(':react-native-text-input-reset')
compile project(':bugsnag-react-native')
compile project(':react-native-version-check')
compile project(':react-native-video')
compile project(':react-native-intercom')
compile project(':react-native-fast-image')
compile project(':react-native-device-info')
compile project(':react-native-rate')
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-fbsdk')
compile project(':react-native-linear-gradient')
implementation fileTree(dir: "libs", include: ["*.jar"])
compile 'com.facebook.android:facebook-android-sdk:4.29.0'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
// From node_modules
compile 'com.facebook.fresco:animated-gif:1.3.0'
implementation project(':react-native-navigation')
// Firebase dependencies
compile 'com.google.android.gms:play-services-base:11.6.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-auth:11.6.0'
compile 'com.google.firebase:firebase-firestore:11.6.0'
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms'
}
compile('com.google.android.gms:play-services-base:11.6.0') {
force = true;
}
compile('com.google.android.gms:play-services-maps:11.6.0') {
force = true;
}
compile('com.google.android.gms:play-services-gcm:11.6.0') {
force = true;
}
implementation "com.google.firebase:firebase-analytics:11.6.0"
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation project(':react-native-fbsdk')
implementation "com.google.firebase:firebase-messaging:11.6.0"
implementation 'me.leolin:ShortcutBadger:1.1.21#aar'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
MainActivity.java
package com.myapp;
import com.reactnativenavigation.NavigationActivity;
import android.content.Intent;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerConversionListener;
public class MainActivity extends NavigationActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
// #Override
// protected String getMainComponentName() {
// return "MyApp";
// }
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
}
MainApplication.java
package com.myapp;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
// import com.facebook.react.shell.MainReactPackage;
// import com.facebook.soloader.SoLoader;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
import com.nikolaiwarner.RNTextInputReset.RNTextInputResetPackage;
import com.reactlibrary.RNRatePackage;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.firestore.RNFirebaseFirestorePackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import com.airbnb.android.react.maps.MapsPackage;
import io.xogus.reactnative.versioncheck.RNVersionCheckPackage;
import com.bugsnag.BugsnagReactNative;
import com.brentvatne.react.ReactVideoPackage;
import com.dylanvann.fastimage.FastImageViewPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.robinpowered.react.Intercom.IntercomPackage;
import io.intercom.android.sdk.Intercom;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.app.Activity;
// import com.reactnativenavigation.controllers.ActivityCallbacks;
// import com.facebook.react.ReactApplication;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import com.appsflyer.reactnative.RNAppsFlyerPackage;
public class MainApplication extends NavigationApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
#Override
protected String getJSMainModuleName() {
return "index";
}
};
return new ReactGateway(this, isDebug(), host);
}
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// new MainReactPackage(),
new RNAppsFlyerPackage(MainApplication.this),
new RNTextInputResetPackage(),
BugsnagReactNative.getPackage(),
new RNVersionCheckPackage(),
new ReactVideoPackage(),
new IntercomPackage(),
new FastImageViewPackage(),
new RNDeviceInfo(),
new RNRatePackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new FBSDKPackage(mCallbackManager),
new LinearGradientPackage(),
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
AppEventsLogger.activateApp(this);
Intercom.initialize(this, "android_sdk-mykey", "mykey");
BugsnagReactNative.start(this);
setActivityCallbacks(new ActivityCallbacks() {
#Override
public void onActivityResumed(Activity activity) {
// Do stuff
}
#Override
public void onActivityPaused(Activity activity) {
// Do stuff
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
}
});
FacebookSdk.sdkInitialize(getApplicationContext());
SoLoader.init(this, /* native exopackage */ false);
}
#Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
#Nullable
#Override
public List<ReactPackage> createAdditionalReactPackages() {
return Arrays.<ReactPackage>asList(
new RNTextInputResetPackage(),
// new MainReactPackage(),
BugsnagReactNative.getPackage(),
new RNVersionCheckPackage(),
new RNRatePackage(),
new RNFirebasePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseFirestorePackage(),
new RNFirebaseAnalyticsPackage(),
new RNFirebaseMessagingPackage(),
// new RNFirebaseNotificationsPackage(),
new RNDeviceInfo(),
new ReactVideoPackage(),
new IntercomPackage(),
new FastImageViewPackage(),
new MapsPackage(),
new FBSDKPackage(mCallbackManager),
new LinearGradientPackage(),
new RNAppsFlyerPackage(MainApplication.this)
);
}}
My settings.gradle
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android')
And gradle-wraper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Sorry for the long code but I maybe made a mistake somewhere.
It looks like the RNN module is not present.
Quick checklist to resolve this:
1) Check package.json, it should contain in its dependencies "react-native-navigation": "^2.11.0", or another similar version. If it does not, the module will need to be (re-)installed. Use npm install --save react-native-navigation, or yarn equivalent.
2) Check inside the directory ./node_modules/react-native-navigation. If it only contains 'lib/android/app/<single file>', your module may have been deleted. If so, npm install / yarn install should recover it.
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
jcenter()
google()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
settings.gradle
rootProject.name = 'XProj1'
include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.xproj1"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57"
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation 'com.android.support:design:25.4.0'
implementation "com.android.support:multidex:1.0.3"
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xproj1">
<application
android:name="android.support.multidex.MultiDexApplication" >
</application>
</manifest>
MainActivity.java
package com.xproj1;
//import com.facebook.react.ReactActivity;
import com.reactnativenavigation.NavigationActivity;
public class MainActivity extends NavigationActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
// #Override
// protected String getMainComponentName() {
// return "XProj1";
// }
}
MainApplication.java
package com.xproj1;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
import com.reactnativenavigation.react.ReactGateway;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication{
#Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
#Override
protected String getJSMainModuleName() {
return "index";
}
};
return new ReactGateway(this, isDebug(), host);
}
#Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
// eg. new VectorIconsPackage()
);
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}
Wix 'React-Native-Navigation' V2 is not supporting for RN 57. I have tried all the ways from this PR PR for RN 57 Support. Still Facing Issues. Can anyone write a quick Medium Post on how to Integrate Navigation with RN 57 support.
Need both maven for react-native and jitpack android/build.gradle
allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
maven
{ url "$rootDir/../node_modules/react-native/android"}
maven
{ url 'https://jitpack.io' }
}
}
Ignore other RNN flavors
in end of android/build.gradle
add below mention code.
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') ||
subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") ||
names.contains("reactNative55")) {
setIgnore(true)
}
}
}
}
}
}
Just do a yarn add https://github.com/leonardoballand/react-native-navigation-rn57.git and you're good to go, just follow the Wix library instructions.
I was able to run react-native-navigation#^2.1.2 along with react-native#^0.57.5 & react#16.6.1.
The only difference that I could spot is that I added the RNN flavors configuration even though it's not highlighted as a mandatory step in the official documentation.
app/build.gradle
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative56")) {
setIgnore(true)
}
}
}
}
}
}