Android Studio - PreferenceScreen not 'previewing' - android-preferences

I have a fresh new install of Android Studio 3.1.4 I wish to add a PreferenceScreen to my app (I'm just following a tutorial to add Settings panel). I read the docs step by step and I'm coding accordingly but I cannot understand why Android Studio is not rendering the PreferenceScreen.
This's the code of my PrefenceScreen:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:key="switch_preference_1"
android:title="Switch preference" />
<EditTextPreference
android:defaultValue="Default value"
android:key="edit_text_preference_1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="Edit text preference" />
</PreferenceScreen>
The layout preview is blank:
the preferences.xml file is located in \res\xml directory.
No errors/warning on build.

I ran into the same problem today but with a newer version of Android Studio.
I am using Android Studio 4.0.1 and the Android X libraries. I found an answer to a related question here: https://stackoverflow.com/a/53615855/5152586 which indicates that using the preferences screen layout requires the addition of preference dependency to the build.gradle file.
implementation 'androidx.preference:preference:1.1.1'
Adding that dependency to my build.gradle file worked for me and I can now see the rendered preview for my preference screen in the Layout Designer mode.
If you are not using the newest stuff yet, another answer (https://stackoverflow.com/a/54738703/5152586) to that same question indicated that the dependencies you'll need would be both the AppCompat and Preference dependencies from the support library.
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'

Related

ANDROID: java.util.MissingResourceException: Can't find resource for bundle 'org.eclipse.paho.client.mqttv3.internal.nls.logcat_en_US', key ''

There seems to be countless reports of this bug in Stack Overflow. None of the suggestions worked. In my case it is almost identical to this stack overflow report
SPRING
except this case is in Android being built in Android Studio. It only happens in release mode with proguard. Proguard corrupts it somehow. And yes I have done the following in proguard:
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
-keep class org.eclipse.paho.** { *; }
I have also parsed the jars downloaded by gradle. I cannot update to 1.2.1 because that only works with the latest versions of Android ... according to comments made by the developers. If I could get the source code for 1.1.0 maybe I could stop it from calling a resource that does not exist.
Anyone solve this problem or is it a bug in proguard/paho?
Looking at the apks generated by release builds (uses proguard) and debug builds (no proguard) shows that proguard is taking the org.eclipse.... package name of the properties and changing the 'org' to some letter like 'c'. The mqtt paho client is looking for the property file using the full package name and therefore cannot find it, no matter what you include or exclude in proguard. I looked at an apk made a few months ago (I have not done anything with the paho client or that part of the code using the paho client ... it has worked fine and I have had no need to change it). I see in that old release apk that the 'org' is there as it should be.
So the problem is in proguard. All I could do to move forward is take the source files for 1.1.0, create a new java project module, and tediously comment out every 'log' and getLogger in the source code. Its a temporary and unpleasant fix but it works. When proguard (R8) fixes this, then I can go back to what I had.
So I guess the only real fix is to submit a bug to R8. That I have not done.

How to find out which version of Silverstripe a site is using, looking at the source code?

I have been given a Silverstripe site to maintain. How do I know which version of Silverstripe it's using, by looking in the source code?
If your SS installation was made through composer you can have a look to composer.json in the root directory.
If it's a 3.x.x version you can also leave the mouse on the SS logo in backend (upper left corner) and the anchor title wil show you the version. Maybe it works also for 2.x.x versions, but I'm not sure.
The Depreciation class provides the version.
$version = Deprecation::dump_settings()['version'];
There is a function in the LeftAndMain class called CMSVersion. This is the function which is used to fill in the version information in the title attribute on the ss logo in the cms as mentioned in the accepted answer. This function attempts to get the version information from the composer.lock file. It will fallback to the /framework/silverstripe_version and /cms/silverstripe_version files if the composer.lock file doesn't exist. So to find the version in the source code, look in composer.lock, then /framework/silverstripe_version and /cms/silverstripe_version
In the folder "framework" is a file "silverstripe_version" with the Silverstripe version.
Inside the Folder Framework there is a README.md file. Inside that you'll finde the Version Number.
Also inside framework Folder there is _config.php, there you have a variable like Deprecation::notification_version('3.1.0'); In this example, Version 3.1.0

built ExtJs 4.2, app doesn't run without old classes

I minified/built my app that uses ExtJS 4.2.0 (free version) using Sencha SDK Tools 2.0.0 beta3, and the app was built successfully. However, when I try deleting the old "app" folder containing my old classes, the app no longer works.
I also tried generating a new app using Sencha CMD 4.0.1.45 and then adding my classes, but the results are the same.
I am confused why this happens, because as I understood it, your old classes are not needed to deploy production app. In fact, the only javascript files you need to include in your "index.html" file are "ext.js" and "app-all.js".
I used Firebug and saw in the DOM that the app, along with my classes, are loaded.
I also noticed that "app-all.js" defines classes like this:
Ext.define("MyApp.view.MyClass"...
Is this really how it is supposed to behave? or am I missing something?
Thanks in advance!
Okay, I got it. A .js file in my application calls Ext.require on itself, causing the app wiring go crazy.

gwt-dev.jar conflicts with icu jar on war/lib classpath when using GAE

Ok I have to rewrite my question after further investigation.
I run into below problem in my GWT/GAE project :
java.lang.RuntimeException: Class com.google.appengine.tools.development.agent.runtime.Runtime$21 can not access a member of class com.ibm.icu.text.CollatorServiceShim with modifiers ""
at com.ibm.icu.text.Collator.getShim(Collator.java:456)
at com.ibm.icu.text.Collator.getInstance(Collator.java:478)
at com.google.visualization.datasource.datatable.value.TextValue$1.<init>(TextValue.java:126)
at com.google.visualization.datasource.datatable.value.TextValue.getTextLocalizedComparator(TextValue.java:125)
at com.google.visualization.datasource.datatable.value.Value$1.<init>(Value.java:141)
at com.google.visualization.datasource.datatable.value.Value.getLocalizedComparator(Value.java:140)
at com.google.visualization.datasource.query.engine.TableRowComparator.<init>(TableRowComparator.java:66)
at com.google.visualization.datasource.query.engine.QueryEngine.performSort(QueryEngine.java:234)
at com.google.visualization.datasource.query.engine.QueryEngine.executeQuery(QueryEngine.java:128)
at com.google.visualization.datasource.DataSourceHelper.applyQuery(DataSourceHelper.java:410)
at com.klawt.server.resources.chart.InvoicesChartServerResource.retrieve(InvoicesChartServerResource.java:129)
Some more investigation revealed that gwt-dev.jar contains a copy of the icu library :
public abstract class com.ibm.icu.text.Collator implements
java.util.Comparator, com.ibm.icu.util.Freezable
is part of gwt-dev.jar
My project has a dependency on icu4j 4.0.1 (for the Google Visualization Datasource library). But GAE SDK insists on using the version included in gwt-dev.jar;
I guess there must a way to setup my development environment so this kinda works, it did before.
I have tried moving GWT SDK to the bottom in the 'Order and export' tab of my build path and the icu jar to the top, but no luck.
Switching from OpenJDK to Oracle JDK fixes it !! It is not the first time I ran into issues with OpenJDK !

Missing Ubuntu.Components QML Module

I installed QTCreator and Ubuntu SDK as shown here.
When trying to run the code sample provided here, QTCreator tells me it can't find the Ubuntu.Components QML Module.
Notes:
The build-logs says:
file:///home/giladnaaman/Programming/Projects/CurrencyConverter/CurrencyConverter.qml:2 module "Ubuntu.Components" is not installed
But the directory /opt/qt5/imports/Ubuntu/Components
exists (and is full of files).
After adding importPaths: [ "/opt/qt5/imports" ] to the qmlproject file:
QML module does not contain information about components contained in plugins.
QMetaType::registerType: Binary compatibility break -- Type flags for 'QPaintBufferCacheEntry'[1024] don't match. Previously registered TypeFlags(0x103), now registering TypeFlags(0x3).
Do not add the importPaths property to the qmlproject.
Did you setup the QML Scene as your QML viewer?
In Qt Creator, go to Tools > Options…
Choose the External Tools tab, then in the pane select the Preview (qmlviewer) entry
On the Executable: field on the right, replace the contents with /opt/qt5/bin/qmlscene.
Optionally change the command name by double-clicking on the Preview (qmlviewer) entry from above. You can call it Preview (qmlscene).
Click on OK to save the changes.
you’ll be able to view your app through the Tools > External > Qt Quick > Preview (qmlscene)
The Ubuntu SDK is still using the older version of Qt Creator from QT4 it will not be able to locate the Ubuntu Components, and say the components are not found. But the QML Scene used for running the QML GUI will load it and run it without any problems.

Resources