How to define gluon application version - javafx

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(""));

Related

WKExtensionsDelegateClassName is Invalid in info.plist

So I am banging my head, I realized my stand along Watch App had a STUPID long name of "App Name - WatchKit App" so I went into my Target and changed the Display Name to "App Name" removing WatchKit App. Well now my app won't validate when uploading to the Appstore. I get the message - Invalid Info.plist key. The key WKExtensionDelegateClassName in bundle App Name.app/Watch/App Name WatchKit App.app is invalid.
My Info.plist has the value of
<key>WKExtensionDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
I have confirmed that I have #WKExtensionDelegateAdaptor(ExtensionDelegate.self) var delegate in my #main for the SwiftUI App. And when I print a few values in my app launch I get the following confirmations:
Super Init - ExtensionDelegate
Contentview
applicationDidFinishLaunching for watchOS
Super Init - ExtensionDelegate
Optional(Wasted_Time_Watch_Extension.MeetingSetup)
Optional(Wasted_Time_Watch_Extension.MeetingStatistics)
Optional(Wasted_Time_Watch_Extension.Meeting)
applicationDidBecomeActive for watchOS
update complication
I create three classes at launch and print this in the log with print(ExtensionDelegate.shared.Setup as Any) , etc. The other lines are just confirming where I am at app startup.
This is a WatchOS8 application and I am running Xcode version Version 13.1 (13A1030d).
Update - Here's the entry in my plist
<key>WKExtensionDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
<key>WKWatchOnly</key>
And my App code
import SwiftUI
#if os(watchOS)
import ClockKit
#endif
struct DelegateKey: EnvironmentKey {
typealias Value = ExtensionDelegate
static let defaultValue: ExtensionDelegate = ExtensionDelegate()
}
extension EnvironmentValues {
var extensionDelegate: DelegateKey.Value {
get {
return self[DelegateKey.self]
}
set {
self[DelegateKey.self] = newValue
}
}
}
#main
struct WastedTimeWatchApp: App {
#WKExtensionDelegateAdaptor(ExtensionDelegate.self) var delegate
let prefs: UserDefaults = UserDefaults(suiteName: suiteName)!
#SceneBuilder var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
.environment(\.extensionDelegate, delegate)
}
}
}
}
class ExtensionDelegate: NSObject, WKExtensionDelegate, ObservableObject {
#Environment(\.extensionDelegate) static var shared
// variables removed to simplify posting
override init() {
print("Super Init - ExtensionDelegate")
super.init()
}
func applicationDidFinishLaunching() {
print("applicationDidFinishLaunching for watchOS")
ExtensionDelegate.shared.meetingSetup = MeetingSetup()
print(ExtensionDelegate.shared.meetingSetup as Any)
ExtensionDelegate.shared.meetingStatistics = MeetingStatistics()
print(ExtensionDelegate.shared.meetingStatistics as Any)
ExtensionDelegate.shared.meeting = Meeting()
print(ExtensionDelegate.shared.meeting as Any)
}
func applicationDidBecomeActive() {
print("applicationDidBecomeActive for watchOS")
print("update complication")
let server = CLKComplicationServer.sharedInstance()
for complication in server.activeComplications ?? [] {
server.reloadTimeline(for: complication)
}
}
func applicationDidBecomeInactive() {
print("update complication")
let server = CLKComplicationServer.sharedInstance()
for complication in server.activeComplications ?? [] {
server.reloadTimeline(for: complication)
}
print("applicationDidBecomeInactive for watchOS")
}
}
I figured this out... I had duplicated the plist entry in both the WatchKit App and WatchKit Extension plist file. Removed it from the list WatchKit Extension plist and all is working fine.

Default FirebaseApp is not initialized in this process ... Make sure to call FirebaseApp.initializeApp(Context) first

I am trying to add data to firestore. and also i want to do this using dagger. but i keep getting this error. can you help me please......
** Default FirebaseApp is not initialized in this process com.example.vvvv. Make sure to call FirebaseApp.initializeApp(Context) first. **
FirestoreREpository
class FirestoreRepository #Inject constructor(private val usersRef:
CollectionReference) {
fun saveSearchResults(userEntities: List<UserEntity>) {
usersRef.add(userEntities).addOnCompleteListener { task ->
when (task.isSuccessful) {
true -> Log.d(ContentValues.TAG, "added:success")
false -> Log.d(ContentValues.TAG, "added:unsuccess")
}
}
}
}
ViewModel
#HiltViewModel
class UserListViewModel #Inject constructor(private val repository: RoomRepository, private
val firestoreRepository: FirestoreRepository) :
ViewModel() {
private val _users = MutableLiveData<List<User>>()
val users: LiveData<List<User>>
get() = _users
var userData: MutableLiveData<List<User>> = MutableLiveData()
fun userSearch(term: String) {
viewModelScope.launch {
loadFromCache(term)
val getPropertiesDeferred =
GithubApi.retrofitService.searchUser(term)
try {
val userEntities: MutableList<UserEntity> = mutableListOf()
val result = getPropertiesDeferred.body()
_users.value = result?.users
result?.users?.forEach {
userEntities.add(
UserEntity(
term = term,
login = it.login,
avatar_url = it.avatar_url
)
)
}
clearSearchResults(term)
updateSearchResults(userEntities, term)
firestoreRepository.saveSearchResults(userEntities) //save
data with firebase
} catch (e: Exception) {
Log.e("userListErr", e.message.toString())
}
}
}
private fun updateSearchResults(userEntities: List<UserEntity>, term:
String) {
viewModelScope.launch(Dispatchers.IO) {
repository.insertSearchResults(userEntities)
loadFromCache(term)
}
}
private fun loadFromCache(term: String) {
viewModelScope.launch(Dispatchers.IO) {
val list = repository.getSearchResults(term)
userData.postValue(list)
}
}
private fun clearSearchResults(term: String) {
viewModelScope.launch(Dispatchers.IO) {
repository.deleteSearchResults(term)
}
}
}
AppModule
#Module
#InstallIn(SingletonComponent::class)
object APPModule {
#Singleton
#Provides
fun getAppDB(context: Application): AppDatabase {
return AppDatabase.getAppDB(context)
}
#Singleton
#Provides
fun getDao(appDB: AppDatabase): AppDao {
return appDB.getDAO()
}
#Provides
fun provideFirebaseFirestore() = FirebaseFirestore.getInstance()
#Provides
fun provideUsersRef(db: FirebaseFirestore) = db.collection("users")
}
I used multi-module in this project. id com.google.gms.google-services to app directory and solved.
In build.gradle(project) in dependencies add the following:
classpath 'com.google.gms:google-services:4.3.5'
In build.gradle(module) add the following:
plugins {
id 'com.google.gms.google-services'
}
in your last line of code add the following:
apply plugin: 'com.google.gms.google-services'
I meet this problem, because google-service sdk version not work with gradle version.
Maybe you can try with this direction.
The original project build.gradle config is ok.
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.2.1"
classpath 'com.google.gms:google-services:4.1.0'
Finally, it's solve by find compatible SDK version.
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.3.3"
classpath 'com.google.gms:google-services:4.2.0'

How to trust all packages when deserialising in Spring Cloud Stream?

This consumer didn't need trusted packages:
#Bean
fun berichtStateStoreBuilder() = Consumer<GlobalKTable<String, BerichtEvent>> {}
This suddenly does:
#Bean
fun berichtStateStoreBuilder() = Consumer<KStream<ByteArray, ByteArray>> {
it
.transform({ EventTypeAwareTransformer(EVENT_TYPE_MAPPING, objectMapper) })
.mapValues { v -> v.payload as BerichtEvent }
.groupByKey(Grouped.with(Serdes.StringSerde(), JsonSerde()))
.aggregate(
{ BerichtAggregator() },
{ _, event, aggregator -> aggregator.add(event) },
Named.`as`("aggregate"),
Materialized.`as`<String, BerichtAggregator, KeyValueStore<Bytes, ByteArray>>(BerichtStore.NAME)
.withKeySerde(Serdes.String())
.withValueSerde(JsonSerde(BerichtAggregator::class.java))
)
I've tried the following approaches, but they didn't work as I only get the following error:
Caused by: java.lang.IllegalArgumentException: The class 'at.wrwks.smp.controlling.event.BerichtEvent' is not in the trusted packages: [java.util, java.lang]. If you believe this class is safe to deserialize, please provide its name. If the serialization is only done by a trusted source, you can also enable trust all (*).
at org.springframework.kafka.support.converter.DefaultJackson2JavaTypeMapper.getClassIdType(DefaultJackson2JavaTypeMapper.java:126)
at org.springframework.kafka.support.converter.DefaultJackson2JavaTypeMapper.toJavaType(DefaultJackson2JavaTypeMapper.java:100)
at org.springframework.kafka.support.serializer.JsonDeserializer.deserialize(JsonDeserializer.java:504)
at org.apache.kafka.streams.processor.internals.SourceNode.deserializeValue(SourceNode.java:55)
at org.apache.kafka.streams.processor.internals.RecordDeserializer.deserialize(RecordDeserializer.java:66)
... 8 more
#Bean
fun defaultKafkaHeaderMapper(objectMapper: ObjectMapper): DefaultKafkaHeaderMapper {
val mapper = DefaultKafkaHeaderMapper(objectMapper, "event_type")
val rawMappedHeaders = HashMap<String, Boolean>()
rawMappedHeaders[BaseEvent.EVENT_TYPE_HEADER] = true
mapper.setRawMappedHeaders(rawMappedHeaders)
mapper.addTrustedPackages("*")
return mapper
}
spring.cloud.stream.kafka.streams.binder.header-mapper-bean-name: defaultKafkaHeaderMapper
spring.cloud.stream.kafka.streams.binder.configuration.spring.json.use.type.headers: false
spring.cloud.stream.kafka.streams.binder.configuration.spring.json.trusted.packages: '*'
Spring Cloud Stream version: 3.1.2 with Kafka Streams binder.
Workaround by using a custom JSON serde:
.groupByKey(Grouped.with(Serdes.StringSerde(), Serdes.serdeFrom(
SimpleJsonSerializer(objectMapper), SimpleJsonDeserializer(objectMapper, BerichtEvent::class.java)
)))
I just tested it and it works fine for me...
#SpringBootApplication
public class So67059860Application {
public static void main(String[] args) {
SpringApplication.run(So67059860Application.class, args);
}
#Bean
public Consumer<KStream<String, Foo>> input() {
return str -> str.foreach((k, v) -> System.out.println(v));
}
}
public class Foo {
private String bar;
public String getBar() {
return this.bar;
}
public void setBar(String bar) {
this.bar = bar;
}
#Override
public String toString() {
return "Foo [bar=" + this.bar + "]";
}
}
spring.cloud.stream.kafka.streams.binder.configuration.default.value.serde=org.springframework.kafka.support.serializer.JsonSerde
spring.cloud.stream.kafka.streams.binder.configuration.spring.json.trusted.packages=*
spring.cloud.stream.kafka.streams.binder.configuration.spring.json.value.default.type=com.example.demo.Foo
spring.application.name=so67059860
spring.cloud.function.definition=input
#logging.level.root=debug
Foo [bar=baz]
Boot 2.4.4, Cloud 2020.0.2 (SCSt 3,1.2).
Set a breakpoint in JsonSerde.configure() to see the properties being used.
Although I've done this dozens of times this time I forgot to pass the target class to the constructor JsonSerde(). This is correct:
.groupByKey(Grouped.with(Serdes.StringSerde(), JsonSerde(BerichtEvent::class.java)))
Apparently when no class will be passed, then no package can be added to the trusted packages. With a class passed the Serde will be configured with the package the target pass belongs to.

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'
}

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