Gradle SwingBuilder: "Toolkit not found: apple.awt.CToolkit" error - android

I have a Gradle task that is supposed to prompt if the user wants to continue or not (part of a larger task for my Android app).
I'm using SwingBuilder to to try construct a dialog but I'm getting the following error when I try to build:
Error:(94) Execution failed for task ':XXXXXX:ask'.
> Toolkit not found: apple.awt.CToolkit
Obviously, I don't have something installed on my Mac but I'm not sure what I need to install. Is this a Java dependency? Or Gradle? (Googling this does not help very much either - the only relevant link is something to do with Google AppEngine which does not help me much).
Here's the task:
task ask << {
def pass = ''
new SwingBuilder().edt {
dialog(modal: true,
title: 'Continue',
alwaysOnTop: true,
resizable: false,
locationRelativeTo: null,
pack: true,
show: true
) {
vbox {
label(text: "Are you sure you want to continue?")
button(defaultButton: true, text: 'Continue', actionPerformed: {
//do something
dispose();
})
button(defaultButton: true, text: 'Cancel', actionPerformed: {
//do something
dispose(); // Close dialog
})
}
}
}

According to this issue on GitHub, the problem appears to be with the fact that IntelliJ IDEA runs on Java 6 by default. You'll need to force it to run with Java 7 instead, as described in this JetBrains support article.
One thing to bear in mind is that IntelliJ has problems with Java 7 and above on Mac, which is why it defaults to Java 6. You can find more details in that support article I linked to.

Related

Expo run:android gradle build fails - :app:mergeDebugResources FAILED due to invalid <color> for given resource value

Situation:
I am currently building a react native app with expo, where the android build with gradle (both locally and in eas) fails due to an invalid color being provided for a resource. This causes the :app:mergeDebugResources at com.android.build.gradle.internal.res.ResourceCompilerRunnable which throws the exception at:
/Users/<name>/.gradle/caches/transforms-3/53122dfddfd0b682fe74c9823d5d0125/transformed/appcompat-1.4.1/res/values/values.xml:37:4: Invalid <color> for given resource value.
What I assume:
Since the app uses svg images I had to modify the metro.config.js file and extend it by the svg transformer. This works very well on iOS (including the build runs smoothly) but I assume may cause issues in the android build. The current metro config setup
const { getDefaultConfig } = require('metro-config');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts },
} = await getDefaultConfig();
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
})();
Besides this I could also think of the adaptive icon being a problem. I discovered that the background color property changes sometimes automatically to random values which do not longer match the hex format (thus may be a reason for the code to break). The background color property originates from the app.json file depicted below:
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#0E192E"
},
"package": "com.<name>.<name>"
},
Especially given that the iOS build compiled without any issues but the android gradle build causes the to me unknown exception I highly appreciate any advice. Since I am not very familiar with gradle and android builds let me know if any further information can be helpful to better elaborate on the problem and help others reading this.
In case the stack trace of the gradle build is of any help:

Could not reach Cloud Firestore backend. Connection failed 1 times

i'm using a very simple code and fetching data from firestore
import firebase from 'firebase/app';
import 'firebase/firestore'
const firebaseApp = firebase.initializeApp({
apiKey: "...",
authDomain: "...",
....
});
const db = firebaseApp.firestore();
export default db;
but i keep getting this error
[2021-06-05T00:58:41.274Z] #firebase/firestore: Firestore (8.6.5): Could not reach Cloud Firestore backend. Connection failed 1 times.
Most recent error: FirebaseError: [code=permission-denied]:
Permission denied on resource project.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
i do have a very fast internet connection
my clock is also synced with the standard time
Now, i have no clue why is this happening?
please someone help me out!!!
I was facing the same issue. The connection was working on some environments, but on my client's corporate network it wasn't.
After a loong research on the internet, I found an issue on Github talking about it.
Here's what worked for me:
const firestoreDB = initializeFirestore(firebaseApp, {
experimentalForceLongPolling: true, // this line
useFetchStreams: false, // and this line
})
Here i'm using firebase v9. For firebase v8 it's something like:
firebase().firestore().settings({
experimentalForceLongPolling: true, // this line
useFetchStreams: false, // and this line
})
i was able to resolve this issue by using my credential directly where i initializeApp my firebase config, i was previously calling them from my env file i think my app was not getting the env before
Make sure your environment is pointing to the real firestone database and not the Firestore Emulator. When I came across this same issue, that was the reason.
I'm using an Angular framework so I had to comment out those environment references in my app.module.ts file.
#NgModule({
declarations: [AppComponent, InformUserComponent],
entryComponents: [InformUserComponent],
imports: [
BrowserModule,
IonicModule.forRoot(),
AngularFireModule.initializeApp(environment.firebaseConfig),
AppRoutingModule,
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: environment.production,
// Register the ServiceWorker as soon as the app is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
}),
],
providers: [AuthService, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
// {
// provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ?
// ['localhost', 8080] : undefined
// },
// {
// provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ?
// ['localhost', 5001] : undefined
// },
],
bootstrap: [AppComponent],
})
export class AppModule { }
I had the same issue and tried to use the #atunde arisekola approach. If you can solve this problem by using direct credentials in your firebaseConfig variable, consider to check whether your .env.local or any other .env you are using is located in the root directory. In my case had firebaseConfig.ts and .env.local in the same directory, and thus the error occured. It is recommended to have.env in the root of your App.
I have faced this issue as well with angular fire.
What I have changed is to add firestore settings to the provider of app module:
According to the GitHub issues discussion, I think you can try experimentalAutoDetectLongPolling first.
And option useFetchStreams is unnecessary except for users who are using very old browser versions.
import { SETTINGS as FIRESTORE_SETTINGS } from '#angular/fire/firestore';
providers:[
{
provide: FIRESTORE_SETTINGS,
useValue: { experimentalAutoDetectLongPolling: true, merge: true },
}
]
and you can use mitmproxy to reproduce the firebase errors.

How to get current country of Device in React Native (iOS and Android)?

I am trying to get current country of device in but didn't find anything. Is there something to do so in React Native?
I tried using react-native-device-info but it is also not supporting but in previous version it can be get by getDeviceCountry(). Now for the latest version it is showing error:
TypeError: _reactNativeDeviceInfo.default.getDeviceCountry is not a
function. (In '_reactNativeDeviceInfo.default.getDeviceCountry()',
'_reactNativeDeviceInfo.default.getDeviceCountry' is undefined)
According to the documentation of react-native-device-info for latest version, they have moved some of their apis to react-native-localize to reduce duplication in the react-native-community modules. react-native-localize worked perfectly for me.
Setup:
$ npm install --save react-native-localize
# --- or ---
$ yarn add react-native-localize
Usage:
import * as RNLocalize from "react-native-localize";
console.log(RNLocalize.getLocales());
console.log(RNLocalize.getCurrencies());
console.log(RNLocalize.getCountry());
console.log(RNLocalize.getCalendar());
console.log(RNLocalize.getTemperatureUnit());
console.log(RNLocalize.getTimeZone());
console.log(RNLocalize.uses24HourClock());
and many more. For detailed description please visit their official documentation by the given link: react-native-localize
Its solved my problem;
BREAKING CHANGE: remove is24Hour, getTimezone, isAutoTimeZone and isAutoDateAndTime, getDeviceLocale, getDeviceCountry, getPreferredLocales
This was the result of a survey. It removes API duplication in the react-native-community modules
Related PR: https://github.com/react-native-community/react-native-localize/pull/65
Use yarn add
https://github.com/mikehardy/react-native-localize.git#e062f0d2dc3171dc18fdb7b7139d347ad03933dc to maintain
isAutoTimeZone + isAutoDateAndTime until merged
The accepted answer didn't work for me, maybe due to https://github.com/zoontek/react-native-localize/issues/81.
However, Expo has something from its ecosystem, which worked out perfectly:
expo install expo-localization
import { getLocales } from 'expo-localization';
console.log(getLocales()[0].regionCode);
Edit: docs here https://docs.expo.io/versions/latest/sdk/localization/#localizationregion
Looks like it's a bug in the React Native. Please check their Troubleshooting section
Here is what they advice:
Seems to be a bug caused by react-native link. You can manually delete
libRNDeviceInfo-tvOS.a in Xcode -> [Your iOS build target] -> Build
Phrases -> Link Binary with Libraries.
Please use this package to get device country . to has different type of configs.
react-native-device-country
Some Examples
import DeviceCountry, {
TYPE_ANY,
TYPE_TELEPHONY,
TYPE_CONFIGURATION,
} from 'react-native-device-country';
DeviceCountry.getCountryCode()
.then((result) => {
console.log(result);
// {"code": "BY", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});
DeviceCountry.getCountryCode(TYPE_TELEPHONY)
.then((result) => {
console.log(result);
// {"code": "BY", "type": "telephony"}
})
.catch((e) => {
console.log(e);
});
DeviceCountry.getCountryCode(TYPE_CONFIGURATION)
.then((result) => {
console.log(result);
// {"code": "BY", "type": "config"}
})
.catch((e) => {
console.log(e);
});

React native - reload do nothing

I just started with React Native. I have my smartphone connected and after react-native run-android I can see "Hello World" on the screen. But when I change "Hello World" to something else, save the file, and then tap on the reload command on my device (after shaking phone), I can't see any changes. I need to react-native run-android again to see new things. I am working on Windows 10. Also build takes a lot of time. I have read similar things, but didn't find any reasonable solution. Can anyone help?
Also: Sometimes when I tap Reload then I need to press enter in packager server terminal, to reload view, but changes don't appear.
I had the same issue and found several solutions. The following is working for me:
To enable life reloading with the >0.29 react-native-versions
go to file: yourProjectFolder//node_modules/react-native/local-cli/server/server.js
Commend the line (62): process.exit(11) -> //process.exit(11)
About Point 2: I am not sure since when the solution of 2.1. is needed but i think ~ react-native v.33. Please correct this if someone knows exactly. For you just look if you find the index.js at the 2. or 2.1. path.
2.1 (Older Path of React-Native FileWatcher index.js) Go to file: yourProjectFolder//node_modules/react-native/node_modules\node-haste\lib\FileWatcher\index.js"
2.2 (Newer Path of React-Native FileWatcher index.js) Go to file:
yourProjectFolder\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\index.js
STEP 1 for 2.1 + 2.2:
Increase at the top of the index.js file: MAX_WAIT_TIME=120000 > MAX_WAIT_TIME=360000
Change function (_createWatcher) to:
STEP 2 for 2.1 (Older Path of index.js)
key: '_createWatcher',
value: function _createWatcher(rootConfig) {
var watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false
});
return new Promise(function (resolve, reject) {
const rejectTimeout = setTimeout(function() {
reject(new Error([
'Watcher took too long to load',
'Try running `watchman version` from your terminal',
'https://facebook.github.io/watchman/docs/troubleshooting.html',
].join('\n')));
}, MAX_WAIT_TIME);
watcher.once('ready', function () {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
}
STEP 2 for 2.2 (Newer Path of index.js)
_createWatcher(rootConfig) {
var watcher = new WatcherClass(rootConfig.dir, {
glob: rootConfig.globs,
dot: false
});
return new Promise(function (resolve, reject) {
const rejectTimeout = setTimeout(function() {
reject(new Error([
'Watcher took too long to load',
'Try running `watchman version` from your terminal',
'https://facebook.github.io/watchman/docs/troubleshooting.html',
].join('\n')));
}, MAX_WAIT_TIME);
watcher.once('ready', function () {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
}
This solution worked for me. Hope I could help you and correct me if I am wrong.

Nightwatch/Chromedriver with Android. Arguments for chrome are completely ignored

I'm trying to run some nightwatch tests in my android emulator. My configuration for android in my nightwatch.json looks like follows:
"android" : {
"selenium_port" : 9515,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"androidPackage": "com.android.chrome",
"args": ["--disable-web-security", "--no-first-run"]
}
}
}
The test runs without issues. But I'm always seeing the "First Run Experience" page in each run. Also it is always checking the SSL certificates event when I have set the --disable-web-security flag. Those flags work with Desktop version of Chrome.
I guess this is not an issue with Nightwatch itself. So maybe other implementations of selenium+android would work.
Addtionally, I'm not allowed to use Appium.
Do you know what I'm doing wrong? Have you faced the same issue?
I'm not sure about this spesific case, but passing args to Chrome via the conf file should not include the '--' in the beginning.
So, args: ["some-option"] instead of args: ["--some-option"] makes the difference in my setups.
You can use the below configuration for mobile emulation in the Chrome web browser:
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"mobileEmulation": { "deviceName" : "Galaxy S5"},
"args": [
"disable-web-security"
]
}
},

Categories

Resources