Categories
discuss

Cordova Android 6.4.0 creates res folder top level not inside platforms android

After upading cordova and my project from 6.3.1 to 6.4.0, when I build the Android version, it generates the res folder with splash screens and icons files, at top level of the project, instead of at platforms/android/res where it should. Thus my app has the default cordova icons and splash screens instead of mine.

Is this a bug in the new Cordova version? Does anyone know of a setting that could prevent this? It was working ok when I used 6.3.1 .

Thanks.

Answer

This issue is solved in cordova-android 6.1.0 but if you try cordova platform update android at this moment doesn’t update to 6.1.0.

Run

cordova platform update android@6.1.0 --save
cordova platform rm android
cordova platform add android

to solve this issue.

Some people seem to still have the issue after the command above… Try:

cordova platform update android@6.2.0-nightly.2016.12.9.6c60dc5d --save
cordova platform rm android
cordova platform add android

You can also try: android@latest ….

Also try: ionic resources –icon

I’m using that version and it works, let me know if it solved the problem…

Categories
discuss

Save BottomNavigationView selected item during screen rotation

Using ASL’s 25.0 BottomNavigationView i’m faced with some troubles, like a save selected item (or his index) and selected item programmatically.

Answer

Unfortunately, there are plenty of features missing in BottomNavigationView at this stage.

Your question was really interesting and I wrote this extended BottomNavigationView that preserves the state and, in your case, saves last selected item.

Here is gist to the code

This extension includes:

  • Gives public two method to set and get selected items programatically.
  • Saves and restores state only for the last selection.

Lets wait until ASL devs fix this.

Categories
discuss

JSON.parse, what am I doing wrong?

So, I’m trying to parse some JSON in Javascript. This feels like it should work, but I’m getting an error. Here’s the function call:

JSON.parse("{player: 'green', direction: 'north'}");

And here’s the error

VM156:1 Uncaught SyntaxError: Unexpected token p in JSON at position 1
    at Object.parse (native)
    at <anonymous>:1:6

I’m trying this on an empty web page, no JS libraries are present.

The string, just executed as Javascript creates an object with the two expected attributes.

I’ve tried wrapping the keys in strings. That didn’t parse.

The unexpected token appears to be whatever the first letter is.

What am I doing wrong, how can I parse this object?

Answer

That’s not valid JSON.

Try this:

JSON.parse('{"player": "green", "direction": "north"}');

Note the double quotes " instead of single quotes ' and the quotes around the object keys.

Categories
discuss

Google Datastore Emulator using Java (Not using GAE)

I am using Google Cloud’s Datastore Client Library for Java to access the Cloud Datastore.

Note: I am not using App Engine to deploy my application; just running a local application for development purposes.

Following the example, I can read/write to the Cloud Datastore.

Datastore datastore = DatastoreOptions.defaultInstance().service();
KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
Key key = keyFactory.newKey();
Entity entity = datastore.get(key);

I want to be able to write to a local Datastore emulator instance instead. Following the guide here, I run gcloud beta emulators datastore start. This shows up in my terminal:

C:UsersUser>gcloud beta emulators datastore start
WARNING: Reusing existing data in [C:UsersUserAppDataRoaminggcloudemulatorsdatastore].
Executing: cmd /c C:UsersUserAppDataLocalGoogleCloud SDKgoogle-cloud-sdkplatformcloud-datastore-emulatorcloud_datastore_emulator.cmd start --host=localhost --port=8964 --store_on_disk=True --consistency=0.9 --allow_remote_shutdown C:UsersUserAppDataRoaminggcloudemulatorsdatastore
[datastore] Oct 31, 2016 11:37:27 AM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$7 apply
[datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary.
[datastore] Oct 31, 2016 11:37:27 AM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub <init>
[datastore] INFO: Local Datastore initialized:
[datastore]     Type: High Replication
[datastore]     Storage: C:UsersUserAppDataRoaminggcloudemulatorsdatastoreWEB-INFappengine-generatedlocal_db.bin
[datastore] Oct 31, 2016 11:37:28 AM io.grpc.internal.ManagedChannelImpl <init>
[datastore] INFO: [ManagedChannelImpl@5e955596] Created with target localhost:8964
[datastore] Oct 31, 2016 11:37:28 AM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub load
[datastore] INFO: The backing store, C:UsersUserAppDataRoaminggcloudemulatorsdatastoreWEB-INFappengine-generatedlocal_db.bin, does not exist. It will be created.
[datastore] Oct 31, 2016 11:37:28 AM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
[datastore] INFO: Unable to apply Java 7 long hostname workaround.
[datastore] API endpoint: http://localhost:8964
[datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run:
[datastore]
[datastore]   export DATASTORE_EMULATOR_HOST=localhost:8964
[datastore]
[datastore] Dev App Server is now running.
[datastore]

I open another terminal and set the environment variables:

C:UsersUser>gcloud beta emulators datastore env-init > set_vars.cmd && set_vars.cmd
C:UsersUser>set DATASTORE_DATASET=my-project-id
C:UsersUser>set DATASTORE_EMULATOR_HOST=localhost:8964
C:UsersUser>set DATASTORE_EMULATOR_HOST_PATH=localhost:8964/datastore
C:UsersUser>set DATASTORE_HOST=http://localhost:8964
C:UsersUser>set DATASTORE_PROJECT_ID=my-project-id

I run my application and make a REST call to post or retrieve an Entity, but this only reads/writes against the Cloud Datastore. Heading to localhost:8964/datastore gives me Not Found. Although starting the emulator tells me that it created local_db.bin file, the folder supposedly containing it is empty. I also want to stay away from using LocalDatastoreHelper in order to access the local emulator. Is there any way to achieve using gcloud only ?

Answer

The line below always connects to the remote datastore. Uses the default options (e.g. project, auth credentials) from gcloud settings.

Datastore datastore = DatastoreOptions.defaultInstance().service();

To connect to the local datastore, try the below:

@Test
public void test1() throws IOException, InterruptedException {
    Datastore ds = DatastoreOptions.builder().host("http://localhost:9999").projectId("my-project").build().service();
    com.google.cloud.datastore.Key key = ds.newKeyFactory().kind("MyEntity").newKey("mykey");
    com.google.cloud.datastore.Entity entity = com.google.cloud.datastore.Entity.builder(key).set("p1", "Hello World!").build();
    entity = ds.put(entity);
    entity = ds.get(key);
    System.out.println(entity);
}

I started my Datastore Emulator on localhost:9999. Set that as the host when building the DatastoreOptions.

I’ve confirmed that the Emulator console shows requests are received and entities are persisted. I’ve also checked the data file (local_db.bin) and it shows the data (of course it is not a plain text file).

The one thing I don’t know is – if there is a way to manage the local datastore using a browser interface. I could not find much documentation on how to administer the local datastore just like how we do the remote one from Cloud Console. Perhaps someone else can help with this.

Categories
discuss

What is the meaning of “target element is not a descendant of root”?

I got the following warning in the Chrome’s console:
"IntersectionObserver.observe(target): target element is not a descendant of root."

What is the meaning of this? How could I find the reason for it, in order to fix it?

Answer

This warning appeared for me too. Chrome Debugging tool did not like an attribute in an element. I found the offending attribute by cutting out chunks of html and reloading the page until I narrowed it down to a single attribute.

for me it was this muted attribute…

Hope this helps.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..