Unable to find a matching configuration of project :realm: - realm

I am trying to install and link realm library in my project but automatically it did not link by link command so I tried with manual linking of realm library in my project, but after running app then the error comes
error: "Unable to find a matching configuration of the project :realm:".
I also tried to downgrade node to v9.0, but still error comes.
android/settings.gradle
rootProject.name = 'realmBasic'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
android/app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
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
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.realmbasic"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
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:
// https://developer.android.com/studio/build/configure-apk-splits.html
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 fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':realm') // added this line
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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 from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
MainApplication.java
package com.realmbasic;
import io.realm.react.RealmReactPackage;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
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() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example:
// packages.add(new MyReactNativePackage());
new RealmReactPackage(); // added this package
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* #param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
* We use reflection here to pick up the class that initializes Flipper, since
* Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2");
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
maven {
url "https://sdks.instabug.com/nexus/repository/instabug-cp"
}
maven {
url "https://sdks.instabug.com/nexus/repository/instabug-cp"
}
}
}
Please, anybody, suggest how to install the realm successfully in my project.
I am new to the realm.

I am using react-native version:- 0.61.2 and realm version:- 2.23.0, so it does not support realm installation in react native. But when I downgrade realm from v2.23.0 to version:- 2.22.0 then my project build successfully and realm works.

Related

Symfony4 Twig Extension return image path

I want to create a TwigExtension Function in Symfony4 in order to display images based on a string property in the view.
I have installed the assets: "symfony/asset": "^4.4",
In lower versions of Symfony I could to this with AssetsHelper::getUrl() -> Returns the public url/path of an asset.
I am not sure how can I achieve this in Symfony4 with "Twig".
The solution is a bit different.
So This is what i did:
In webpackencore config i had to add this in order to have the files copied to the public folder:
.copyFiles({
'from': './assets/img',
'to': 'images/[path][name].[ext]'
})
Then in my extension class the function looks like this:
/**
* #param $type
*
* #return mixed
*/
public function showPaymentTypeIcon($type)
{
$sImagePath = '/build/images/payment-icons';
switch($type) {
case 'card':
default:
$assetImagePath = $sImagePath.'/credit.svg';
break;
case 'sofort':
$assetImagePath = $sImagePath.'/sofort.svg';
break;
}
$oPackage = new Package(new EmptyVersionStrategy());
return $oPackage->getUrl($assetImagePath);
}
So instead of AssetsHelper now we have to use Package as described here: https://symfony.com/doc/current/components/asset.html#asset-packages

Problems importing/using RNFirebaseAuthPackage

I am having trouble connecting react-native-firebase into my react-native project. It is installed and firebase has shown me that it is connected, however now I am trying to use the RNFirebaseAuthPackage.
I have received the error message that tells me I need to install/import the Firebase Android SDK dependency in my android/app/build.gradle, RNFirebaseAuthPackage module in my MainApplication.java and the RNFirebaseAuthPackage() inside of the getPackages()
Here is my android/app/build.gradle file
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
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.v4"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
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"
}
}
// 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-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
//Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-auth"
}
// 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'
And here is my MainApplication.java file.
package com.v4;
import android.app.Application;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.RNFirebaseAuthPackage;
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 RNFirebasePackage(),
new RNFirebaseAuthPackage()
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
And I'm not sure if it is really needed, but just incase anyways here is my project build.gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
The error I am getting when I try to sync the project in android studio is
Failed to resolve: com.google.firebase:firebase-auth:
I'm not too sure where to go from here, sorry for the copy and pasted files, I am just quite stuck.
Any help is much appreciated.
An attempt of solution is to replace this :
implementation "com.google.firebase:firebase-auth"
by this
implementation "com.google.firebase:firebase-auth:16.1.0"
in your android/app/build.gradle file.
I am facing same issue but after changing i am solving this problem follow these step and solve your issue
Run the following command
Step 1: npm install react-native-google-signin --save
Linking of Library
Step 2:react-native link
You can see the following changes in your android project. If you are unable to find the changes then please do those changes as they are must for this example.
Go to the GoogleSigninExample> android > app > build.gradle.
Scroll down and you can see the following dependency and if not please add this.
**compile project(':react-native-google-signin')**
Open GoogleSigninExample> android > settings.gradle and you can see the following lines and if not please add this.
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
Open GoogleSigninExample> android > app > src > main > java > com > googlesigninexample> MainApplication.java and you can see the following lines in imports if not then please add
import co.apptailor.googlesignin.RNGoogleSigninPackage;
Scroll down and you can see the following line in getPackages after new MainReactPackage() if not then please add a comma(,) and add
new RNGoogleSigninPackage()
if you are follow these step then you can solve your issue.
and i will show my MainApplication.java
package com.uiapp;
import android.app.Application;
import co.apptailor.googlesignin.RNGoogleSigninPackage;
import com.facebook.react.ReactApplication;
import com.inprogress.reactnativeyoutube.ReactNativeYouTube;
import co.apptailor.googlesignin.RNGoogleSigninPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.imagepicker.ImagePickerPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.inprogress.reactnativeyoutube.ReactNativeYouTube;
import com.facebook.FacebookSdk;
import com.facebook.CallbackManager;
import com.facebook.appevents.AppEventsLogger;
import android.content.Intent;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
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 ReactNativeYouTube(),
new RNGoogleSigninPackage(),
new FBSDKPackage(mCallbackManager),
new ImagePickerPackage(),
new RNGestureHandlerPackage()
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
// #Override
// public void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
// }
}
and see the android/build.gradlew
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.0")
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
and code of setting.gradlew
rootProject.name = 'UiApp'
include ':react-native-youtube'
project(':react-native-youtube').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-youtube/android')
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':app'
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-youtube'
project(':react-native-youtube').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-youtube/android')
Also see the code of android/app/build.gradlew
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
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 rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.uiapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
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"
}
}
// 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-google-signin')
implementation project(':react-native-fbsdk')
implementation project(':react-native-image-picker')
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'
}

How to define gluon application version

I want to put the application version to my gluon application. but I don't know how to do. Do I need to create service for that?
There is a very simple approach, that doesn't required a service, but it can lead to errors:
You can maintain a version code/version number for Android in the AndroidManifest:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package"
android:versionCode="1.1.0"
android:versionName="1.1.0">
The same on iOS, in the Default-Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>your.bundle.identifier</string>
<key>CFBundleVersion</key>
<string>1.1.0</string>
And finally you can keep a static field in your code:
public static final String VERSION_NAME = "1.1.0";
that you can access from the NavigationDrawer, for instance.
However this requires manual updating every time you make a new release.
To avoid errors, you can set some CI job that does it for you. See for instance this commit, that it is part of the release job of a mobile app.
Charm Down Service
However, a more definitive way of avoiding mismatches between the released versions and the variable in your code is by adding a service that directly reads those versions.
Something like this:
VersionService.java
package com.gluonhq.charm.down.plugins;
public interface VersionService {
String getVersionName();
}
VersionServiceFactory.java
package com.gluonhq.charm.down.plugins;
import com.gluonhq.charm.down.DefaultServiceFactory;
public class VersionServiceFactory extends DefaultServiceFactory<VersionService> {
public VersionServiceFactory() {
super(VersionService.class);
}
}
Android package, under src/android/java:
AndroidVersionService.java
package com.gluonhq.charm.down.plugins.android;
import android.content.pm.PackageManager;
import com.gluonhq.charm.down.plugins.VersionService;
import javafxports.android.FXActivity;
public class AndroidVersionService implements VersionService {
#Override
public String getVersionName() {
try {
return FXActivity.getInstance().getPackageManager()
.getPackageInfo(FXActivity.getInstance().getPackageName(), 0)
.versionName;
} catch (PackageManager.NameNotFoundException ex) { }
return "";
}
}
IOS package, under src/ios/java:
IOSVersionService.java
package com.gluonhq.charm.down.plugins.ios;
import com.gluonhq.charm.down.plugins.VersionService;
public class IOSVersionService implements VersionService {
static {
System.loadLibrary("Version");
}
#Override
public String getVersionName() {
return getNativeVersion();
}
private static native String getNativeVersion();
}
Under src/ios/native:
Version.m
#import <UIKit/UIKit.h>
#include "jni.h"
JNIEXPORT jint JNICALL
JNI_OnLoad_Version(JavaVM *vm, void *reserved)
{
#ifdef JNI_VERSION_1_8
//min. returned JNI_VERSION required by JDK8 for builtin libraries
JNIEnv *env;
if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
return JNI_VERSION_1_4;
}
return JNI_VERSION_1_8;
#else
return JNI_VERSION_1_4;
#endif
}
JNIEXPORT jstring JNICALL Java_com_gluonhq_charm_down_plugins_ios_IOSVersionService_getNativeVersion
(JNIEnv *env, jclass jClass)
{
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
return (*env)->NewStringUTF(env, [version cStringUsingEncoding:NSASCIIStringEncoding]);
}
Build files, at root level:
ios-build.gradle
if (System.getProperty('os.name').toLowerCase().contains("mac")) {
new ByteArrayOutputStream().withStream { os ->
exec {
args '-version', '-sdk', 'iphoneos', 'SDKVersion'
executable 'xcodebuild'
standardOutput = os
}
ext.IOS_VERSION = os.toString().trim()
}
} else {
ext.IOS_VERSION = ""
}
ext.IS_DEBUG_NATIVE = Boolean.parseBoolean(System.getProperty("IS_DEBUG_NATIVE", "false"))
def sdkPath(String platform) {
return "/Applications/Xcode.app/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${IOS_VERSION}.sdk";
}
ext.xcodebuildIOS = {buildDir, projectDir, name ->
if (!file(sdkPath('iPhoneOS')).exists()) {
println "Skipping xcodebuild"
return
}
// define statics do being able to configure the input/output files on the task
// for faster builds if nothing changed
def buildSystems = ["iPhoneOS+arm64",
"iPhoneOS+armv7",
"iPhoneSimulator+i386",
"iPhoneSimulator+x86_64"]
def linkerOutputs = []
def lipoOutput = "$buildDir/native/lib${name}.a"
def nativeSources = ["$projectDir/src/ios/native/${name}.m"]
// the actual task action
buildSystems.each { buildSystem ->
def (platform, arch) = buildSystem.tokenize("+");
def compileOutput = "$buildDir/native/$arch"
def compileOutputs = ["$buildDir/native/$arch/${name}.o"]
def linkerOutput = "$buildDir/native/$arch/lib${name}.a"
new File(compileOutput).mkdirs();
def clangArgs = [
"-x", "objective-c",
"-miphoneos-version-min=6.0",
"-fmessage-length=0",
"-std=c99",
"-fno-common",
"-Wall",
"-fno-strict-aliasing",
"-fwrapv",
"-fpascal-strings",
"-fobjc-abi-version=2",
"-fobjc-legacy-dispatch",
"-I" + System.getenv("JAVA_HOME") + "/include",
"-I" + System.getenv("JAVA_HOME") + "/include/darwin",
"-c",
IS_DEBUG_NATIVE ? ["-O0", "-DDEBUG", "-g"] : ["-O3", "-DNDEBUG"],
"-arch", arch,
"-isysroot",
sdkPath(platform),
nativeSources].flatten()
// "-o", compileOutput,
def linkerArgs = [
"-static",
"-framework", "Foundation",
"-framework", "CoreGraphics",
"-framework", "CoreBluetooth",
"-framework", "CoreLocation",
"-framework", "CoreMotion",
"-framework", "CoreText",
"-framework", "UIKit",
"-framework", "QuartzCore",
"-framework", "OpenGLES",
"-framework", "UserNotifications",
"-arch_only", arch,
"-syslibroot", sdkPath(platform),
"-L${sdkPath(platform)}/usr/lib",
"-o", linkerOutput,
compileOutputs
].flatten()
// execute compiler
exec {
executable "clang"
args clangArgs
workingDir compileOutput
}
// execute linker
exec {
executable "libtool"
args linkerArgs
workingDir compileOutput
}
linkerOutputs.add(linkerOutput)
}
def lipoArgs = [
"-create",
linkerOutputs,
"-o",
lipoOutput
].flatten();
// execute lipo to combine all linker output in one archive
exec {
executable "lipo"
args lipoArgs
}
}
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.16'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply from: 'ios-build.gradle'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'your.main.class'
dependencies {
compile 'com.gluonhq:charm:5.0.2'
}
jfxmobile {
javafxportsVersion = '8.60.11'
downConfig {
version = '3.8.6'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
task xcodebuild {
doLast {
xcodebuildIOS("$project.buildDir","$project.projectDir", "Version")
}
}
task installNativeLib (type:Copy, dependsOn: xcodebuild) {
from("$project.buildDir/native")
into("src/ios/jniLibs")
include("*.a")
}
Before deploying to iOS, run:
./gradlew installNativeLib
Service use
Finally, you can use the service anywhere in your code:
String version = Services.get(VersionService.class)
.map(VersionService::getVersionName)
.orElse(""));

Implementing checksums in Java migrations

My Java migrations currently do not implement the MigrationChecksumProvider interface. I am wondering if they should.
I do not understand what role checksums play in Flyway. Would someone explain this to me, please? Moreover, if I implement MigrationChecksumProvider, how should a checksum be computed for a given migration?
Thank you.
Checksum are used for (accidental) change detection of migrations, which would invalidate the guarantee that the schema can be recreated exactly.
For Java migrations, the sky is the limit as to what you can do. It is therefore your call as to how you want to implement checksums to detect changes.
I think most of the time you want to calculate the checksum based upon the content of the class file in question. We are doing that like this....
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.CRC32;
import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
import org.flywaydb.core.internal.util.FileCopyUtils;
import org.flywaydb.core.internal.util.logging.Log;
import org.flywaydb.core.internal.util.logging.LogFactory;
/**
* Utility class for checksum calculations.
*
*/
public final class Checksums {
private static final Log LOG = LogFactory.getLog(Checksums.class);
private Checksums() {
super(); // singleton
}
/**
* Calculates a checksum based on the given JdbcMigration. It builds the checksum from the byte content of the given
* migration class file using the same {#link CRC32} method as used by
* {#link org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver}
*
* #param migration
* #return the checksum
*/
public static final Integer checksum(JdbcMigration migration) {
Integer checksum = null;
Class<?> migrationClass = migration.getClass();
String migrationClassFilePath = migrationClass.getName().replace(".", System.getProperty("file.separator")) + ".class";
InputStream inputStream = null;
try {
inputStream = ClassLoader.getSystemResourceAsStream(migrationClassFilePath);
byte[] classContent = FileCopyUtils.copyToByteArray(inputStream);
final CRC32 crc32 = new CRC32();
crc32.update(classContent);
checksum = (int) crc32.getValue();
} catch (IOException ioe) {
LOG.error("Problem calculating checksum for class " + migrationClass.getName(), ioe);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ioe) {
LOG.error("Problem closing input stream to " + migrationClassFilePath, ioe);
}
}
}
return checksum;
}
}
Then you can create a base class that looks something like
public abstract class JdbcMigrationWithChecksum implements JdbcMigration, MigrationChecksumProvider {
#Override
public Integer getChecksum() {
return Checksums.checksum(this);
}
}

Springboot application on Tomcat is giving exception on startup at deployment

I have a SpringBoot Application that I am trying to deploy on Tomcat.
I am getting the following error on statup.
ar]
2015-06-21 19:04:26.392 ERROR 7568 --- [apr-8080-exec-4] o.s.boot.SpringApplicat
ion : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedde
d container; nested exception is org.springframework.beans.factory.BeanCreationE
xception: Error creating bean with name 'errorPageFilter': Initialization of bea
n failed; nested exception is java.lang.ClassCastException: org.springframework.
boot.context.web.ErrorPageFilter cannot be cast to org.springframework.boot.cont
ext.embedded.tomcat.TomcatEmbeddedServletContainerFactory
at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
This is my spring boot initializer code.
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class WebInitializer extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
What am I missing here.
as requested here is the gradle .
buildscript {
ext {
springBootVersion1= '1.2.3.RELEASE'
springBootVersion = '1.0.2.RELEASE'
}
repositories {
//maven { url "http://repo.spring.io/libs-snapshot" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'rabbitmq-ws-jar-to-war'
version = '0.1.0'
}
repositories {
mavenCentral()
// maven { url "http://repo.spring.io/libs-snapshot" }
// maven { url "http://maven.springframework.org/milestone" }
// flatDir {
// dirs 'lib'
// }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion1}")
compile("org.springframework.boot:spring-boot:${springBootVersion1}")
compile("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion1}")
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion1}")
compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion1}")
compile("org.springframework.boot:spring-boot-starter-test:${springBootVersion1}")
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion1}")
{
exclude module: 'org.springframework.boot:spring-boot-starter-logging'
}
//compile ('org.springframework.boot:spring-boot-starter-log4j')
compile("org.springframework.boot:spring-boot-starter-log4j:${springBootVersion1}")
compile("org.springframework.data:spring-data-rest-webmvc:2.3.0.RELEASE")
providedCompile("org.springframework.boot:spring-boot-starter-security:${springBootVersion1}")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.7.RELEASE")
compile("org.springframework.security.oauth:spring-security-oauth-parent:2.0.7.RELEASE")
compile("org.hibernate:hibernate:3.3.2.GA")
//compile("org.hibernate:hibernate-annotations:3.5.6-Final")
//compile("org.springframework:spring-hibernate3:2.0.8")
compile("javax.annotation:javax.annotation-api:1.2")
compile("org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final")
compile("org.hsqldb:hsqldb")
compile("com.google.guava:guava:17.0")
compile("org.apache.commons:commons-lang3:3.3.2")
compile("org.apache.httpcomponents:httpclient:4.3.4")
compile("com.squareup.retrofit:retrofit:1.6.0")
compile("commons-io:commons-io:2.4")
compile("com.github.davidmarquis:fluent-interface-proxy:1.3.0")
compile("org.imgscalr:imgscalr-lib:4.2")
compile("org.springframework.boot:spring-boot-starter-amqp:${springBootVersion1}")
compile("com.rabbitmq:amqp-client:3.5.1")
compile('com.squareup.retrofit:converter-jackson:1.2.2')
//compile("org.nigajuan.rabbit.management.client:rabbit-management-client:1.0-SNAPSHOT")
testCompile("junit:junit")
}
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class" // whatever Ant pattern matches your test class files
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
Thanks
Dhiren

Resources