Hello everybody,
I've been watching thenewboston's Android App Development series on youtube and its been pretty helpful, but I've had several situations where I'll get some sort of error and I have no idea what to do. I've tried searching forums, downloading more components with jdk, all to no avail.
My most recent issue is upon initiating a new activity, I get an error saying RelativeLayout needs LayoutHeight and LayoutWidth to be defined; but they are defined in the xml file.
I'm posting from my phone right now, tomorrow I'll follow up with a screen shot.
It really gets me down when I'm trying to be excited about learning something new and on my own, but I experience so many road bumps that I have no idea how to fix or solve. :crying:
Details of the issue
Error Displayed:
Rendering Problems NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. <RelativeLayout> does not set the required layout_width attribute: ****Set to wrap_content, Set to match_parent <RelativeLayout> does not set the required layout_height attribute: ****Set to wrap_content, Set to match_parent Or: Automatically add all missing attributes
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns="http//schemasandroidcom/apk/res/android"
xmlns:app="http//schemasandroidcom/apk/res-auto"
xmlns:tools="http//schemasandroidcom/tools"
xmlns:android="AndroidDomInspection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="comeric522.facebook.example2.MainActivity"
tools:showIn="@layout/activity_main" />
</RelativeLayout>
Other notes: automatically add all missing attributes doesn't work; wrap_content or match_parent doesn't work either.
'.' and ':' removed in between schemasandroidcom because I'm getting flagged for spam
I'm also getting these errors on the xml, and I don't understand why; I haven't done anything yet it's system generated:
Element RelativeLayout doesn't have required attribute layout_height Element RelativeLayout doesn't have required attribute layout_width 'layout_height' attribute should be defined less... (Ctrl+F1)
Validates resource references inside Android XML files.
'layout_width' attribute should be defined less... (Ctrl+F1)
Validates resource references inside Android XML files.
Related
I'm stuck. I am building a custom Settings.apk for a new tablet and I've run across an error I can't find.
Any dialog that displays a SeekBar or variation simply FC's with a null pointer exception. I have a reference source tree that is a virgin copy from the android git. If I compile the stock Settings.apk, it does the same thing at the same places as my custom version.
The error occurs in the BrightnessPreference.java and the RingerVolumePreference.java files any time the dialog containing a SeekBar or Volumizer tries to display.
Here's an example of the code:
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
mSeekBar = getSeekBar(view);
mSeekBar.setMax(MAXIMUM_BACKLIGHT - mMinBrightness); <-- errors here
It errors at setMax with a null pointer error, like the setMax method doesn't exist. My build environment seems fine. Everything I've built runs on the target devices, but this one has me stumped. Has anyone else tried building a Settings.apk lately, and does it display the volume (in sound) and brightness (in Display) dialogs?
BTW, the target is Froyo
Thanks,
--- Jem
Are you sure the mMinBrightness variable is defined? BrightnessPreference.java as shown here instead uses MINIMUM_BACKLIGHT and is defined as:
Code:
private static final int MINIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_DIM + 10;
It is then used to set the seekbar max:
Code:
mSeekBar.setMax(MAXIMUM_BACKLIGHT - MINIMUM_BACKLIGHT);
You can also look at the onBindDialogView in RingerVolumePreference.java here. If you want to check whether the java files change from the version I linked(2.2.1 Froyo), just use the arrows on either side of the currently listed version.
I appreciate the response. Yes it is defined and initialized earlier as referenced below.
=== Code ===
private int mMinBrightness;
private boolean mAutomaticAvailable;
// Backlight range is from 0 - 255. Need to make sure that user
// doesn't set the backlight to 0 and get stuck
private static final int MINIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_DIM + 10;
private static final int MAXIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_ON;
public BrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mAutomaticAvailable = context.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
setDialogLayoutResource(R.layout.preference_dialog_brightness);
setDialogIcon(R.drawable.ic_settings_display);
mMinBrightness = MINIMUM_BACKLIGHT;
if (Settings.System.getInt(context.getContentResolver(),
Settings.System.LIGHT_SENSOR_CUSTOM, 0) != 0) {
mMinBrightness = Settings.System.getInt(context.getContentResolver(),
Settings.System.LIGHT_SCREEN_DIM, mMinBrightness);
}
}
=== code ===
Thanks,
--- Jem
It might be useful to rule out an issue with mMinBrightness not getting set or getting set incorrectly by either replacing it with MINIMUM_BACKLIGHT in the setMax line or using a toast message to display the value of mMinBrightness before setMax. If that doesn't reveal anything, could you paste the relevant logcat output for the error/fc and also upload your BrightnessPreference.java file somewhere so it could be downloaded.
I saved the dir's with my modified package and blew away the entire repo structure. I then reloaded the official Android tree from kernel.org. I have compiled the Settings.apk app ALL STOCK, and I get the same errors in the brightness and volume areas. A copy of the brightnesspreference.java and a log screenshot of the error tracking can be found at:
mlsoft dot sytes dot net/brightness.zip (I can't post the direct link)
The only change in the error is the line number (same call though).
At this point, I am wondering if anyone can build the Settings.apk from the repo and get it to display a seekbar or variant in brightness or volume settings using 2.2.1 (froyo). I am comfortable at this point thinking that it is in the tree structure and not my build environment. At least I have a place to hunt if you can reproduce the error on your end.
I really appreciate your help.
--- Jem
android:id="@*android
Yeah, same thing happened to me and I found answer.
I hope this might help.
You will find that two xml files using "@*android".
"It gives access to internal resources for platform apps.
It is NOT safe to build apps with such declarations unless you are building a bundled app within a full system image."
- from stackoverflow
"What is the purpose of the star in the ID string?"
Sorry that I can not post URL. I'm new user.
Sorry about not yet having built and tested the Settings.apk on my end but I haven't found the time to do so yet. Your issue could very well be what You Kim posted about and I'm sure I wouldn't have noticed that for awhile if at all. Here's the link to the stack overflow topic You Kim referenced. The two xml files in the Settings package this occurs in are res/layout/preference_dialog_brightness.xml and res/layout/preference_dialog_ringervolume.xml. That part looks like this:
Code:
<!-- In brightness layout -->
<[COLOR="Red"]SeekBar android:id="@*android:id/seekbar"[/COLOR]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dip" />
<!-- In ringervolume layout -->
<!-- Used for the ring volume. This is what the superclass VolumePreference uses. -->
<[COLOR="red"]SeekBar android:id="@*android:id/seekbar"[/COLOR]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:paddingLeft="20dip"
android:paddingRight="20dip" />
Thank you both. I have been through those files more than once and didn't notice the declarations. Outstanding work guys. I'm off to edit/recompile/test.
Thanks again,
--- Jem
Unfortunately, these changes didn't stop the null pounter errors. Something, somewhere HAS to be uninitialized, but damned if I can find it in the absseekbar, progressbar, or any other class in the seekbar hierarchy. I even tried setting a value of 255 in setMax to rule out variable problems, but that produces the same error at the same line.
I know there is a fix, Settings works on millions of Android devices, so it has to be something stupid I'm overlooking.
--- Jem
Well, it's almost 3am, but I fixed the problem in the brightness preference. SeekBarPreference handles the getSeekBar function, but it doesn't work as expected.
It assigns a static system res ID that obviously doesn't work as intended. So, I overrode the routine just above the call to onBindDialogView. Here is the routine in the seekbarpreference file:
(at sign)Override
protected static SeekBar getSeekBar(View dialogView) {
return (SeekBar) dialogView.findViewById(com.android.internal.R.id.seekbar);
}
Overridden in the brightnes preference file to this:
(at sign)Override
protected static SeekBar getSeekBar(View dialogView) {
return (SeekBar) dialogView.findViewById(R.id.seekbar);
}
I'll go back and write the original to accept a res ID as an argument later. For now at least the brightness control works. Tomorrow I'll go after the volume controls.
--- Jem
I am now trying my hand at provXML to query/change security settings. I realize that most would probably come back with some type of access denied exception, but I am unable to even get that far.
I have an interop unlocked samsung omnia7 with mango. I am trying to use DMProcessConfigXML to send an xml string to set a security policy (in this case SECPOLICY_CFAUTORUN (2) ). I use QueryPolicy to check its value (currently a "0" and send the xm to set it to a 1.
Here is a snippet from the relavent code
Code:
DWORD dwPolicyValue = 0;
HRESULT hr = QueryPolicy(2, &dwPolicyValue);
LPWSTR wszOutput = NULL;
LPCWSTR wszQueryXML =
L"<? xml version=\"1.0\" encoding=\"utf-16\" ?>"
L"<wap-provisioningdoc>"
L"<characteristic type=\"SecurityPolicy\">"
L"<parm name=\"2\" value=\"1\">"
L"</characteristic>"
L"</wap-provisioningdoc>";
MessageBox(NULL,wszQueryXML,L"Now sending the following xml",MB_OK);
HRESULT hr2 = DMProcessConfigXML(wszQueryXML,CFGFLAG_PROCESS,&wszOutput);
delete[] wszOutput;
The first call to QueryPolciy returns a 0. The call to DMProcessConfigXML returns -2147213303 or FFFFFFFF80042009 which I believe is CONFIG_E_BAD_XML. There may be a problem with the xml string, but I can't see it. Any suggestions as to a solution or somewhere else to look?
It seems to only be when I am accessing the security policies. I can send a query for the certificate stores
Code:
LPCWSTR wszOutput =
<wap-provisioningdoc>
<characteristic type="CertificateStore">
<characteristic-query type="Privileged Execution Trust uthorities" />
<characteristic-query type="Unprivileged Execution Trust Authorities" />
<characteristic-query type="SPC" />
<characteristic-query type="CA" />
<characteristic-query type="Root" />
<characteristic-query type="MY" />
</characteristic>
</wap-provisioningdoc>
It returns a 800704EC errorcode, which is a permission problem I think. The security policy queries however give me the bad xml error.
OK I have worked a little more with this and am now successfully able to provision certs in the MY, CA, and ROOT stores with the following code
Code:
void AddCert(const std::wstring& strCertStore, const std::wstring& strCertHash, const std::wstring& strCertEncoded)
{
LPWSTR wszOutput = NULL;
wchar_t wszXML[16384];
swprintf(wszXML,L"<wap-provisioningdoc>"
L"<characteristic type=\"CertificateStore\">"
L"<characteristic type=\"%s\">"
L"<characteristic type=\"%s\">"
L"<parm name=\"EncodedCertificate\" value=\"%s\"/>"
L"</characteristic>"
L"</characteristic>"
L"</characteristic>"
L"</wap-provisioningdoc>", strCertStore.c_str(), strCertHash.c_str(), strCertEncoded.c_str());
HRESULT hr = DMProcessConfigXML(wszXML,CFGFLAG_PROCESS,&wszOutput);
delete[] wszOutput;
}
I am unable however to add a cert to the Code Integrity store, or even query that store with the provisioning xml. The call to DMProcessConfigXML returns 86000011, and I can't find any reference as to what that error code could mean. Any thoughts?
Thanks,
Since you're using native code and messing with pretty serious stuff, you may want to try starting a thread on the Development and Hacking sub-forum (be sure to do a searcch first, of course). I do know that Heathcliff74, an XDA-Devs member, has been able to get full access to the certificate store and exposes this through his WP7 Root Tools app. This app is hosted on that sub-forum.
I know people have tried calling DMProcessConfigXML() before, and been blocked by various security policies. Have you made any changes to your phone that would increase the permissions your app runs at? Being able to make any changes using wap-provisioning straight from a sideloaded app surprises me; I didn't think they had that much permission. Have you tried using registry or filesystem provxml?
My account on these forums is relatively new, and I am unable to post on the dev forums yet. For this reason, I have been posting here and hoping someone would see it and maybe offer some insight. Either that or get enough posts to allow posting in the dev forums. All this code that I have been developing is on a custom HTC image (which is a switch from the original post), so I have TCB access for a native exe that runs on boot.
I follow Heathcliff74's posts as well as yours and a few others on the dev forums and have downloaded quite a few of the apps. I've also been talking with a few of them through private messages. Once I can post on the dev forums, I will probably post some things there, as well as chime in on some of the discussions going on.
Thanks for taking the time to reply though.
I am still working on this but have decided to approach it from a different angle. Instead of using provisioning xml to add the encoded cert to the store, I am going to try using the crypto api functions to do it. I am using the instructions
here to get the strCertEncoded value. Basically just exporting it in base64 encoding and copying the contents (minus the BEGIN CERTIFICATE and END CERTIFICATE). I am trying to add the cert and then list the contents of the store. Here is the code:
Code:
char pszNameString[256];
void* pvData;
DWORD cbData = 0;
PCCERT_CONTEXT pCertContext = NULL;
DWORD dwPropId = 0;
HCERTSTORE hSystemStore = NULL;
std::string strCertEncoded ("INSERT ENCODED VALUE HERE");
DWORD dwEncodedSize = strCertEncoded.size();
if (hSystemStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_LOCAL_MACHINE, L"Code Integrity"))
{
// try to add a cert
if (CertAddEncodedCertificateToStore(hSystemStore,MY_ENCODING_TYPE,(const BYTE*)strCertEncoded.c_str(), dwEncodedSize, CERT_STORE_ADD_REPLACE_EXISTING, NULL))
fprintf(pLog, "Certificate successfully added to Code Integrity store.\n");
else
{
fprintf(pLog, "There was an error adding the certificate to the store. %x\n", GetLastError());
}
fprintf(pLog,"===== Enumerating Code Integrity store =====");
// find certs in this store
while (pCertContext=CertEnumCertificatesInStore(hSystemStore,pCertContext))
{
// get the name
if (CertGetNameString(pCertContext, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, (LPWSTR)pszNameString, 256))
{
fprintf(pLog,"\n%S\n",pszNameString);
// get the hash propery
CertGetCertificateContextProperty(pCertContext, CERT_HASH_PROP_ID, NULL, &cbData);
if (cbData == 0)
{
MyHandleError("CertGetCertificateContextProperty 1 failed.");
}
pvData = HeapAlloc(GetProcessHeap(), 0, cbData);
if (!CertGetCertificateContextProperty(pCertContext, CERT_HASH_PROP_ID, pvData, &cbData))
{
MyHandleError("CertGetCertificateContextProperty 2 failed.");
}
for (DWORD i = 0; i < cbData; i++)
{
fprintf(pLog,"%02X", ((byte*)pvData)[i]);
}
fprintf(pLog,"\n");
HeapFree(GetProcessHeap(), 0, pvData);
PCERT_INFO pinfo = pCertContext->pCertInfo;
SYSTEMTIME startDate;
FileTimeToSystemTime(&(pinfo->NotBefore),&startDate);
SYSTEMTIME endDate;
FileTimeToSystemTime(&(pinfo->NotAfter),&endDate);
fprintf(pLog,"Valid from %d/%d/%d to %d/%d/%d\n", startDate.wMonth, startDate.wDay, startDate.wYear, endDate.wMonth, endDate.wDay, endDate.wYear);
}
}
}
else
{
fprintf(pLog,"Error opening Code Integrity store. %d", hSystemStore);
}
The call to CertAddEncodedCertificateToStore returns with the errorcode 8009310B. The message for the error is "ASN1 bad tag value met." I have found some information on this error but have been unable to determine why I am getting it.
I have a listbox, with custom items. Code:
Code:
<ListBox Height="600" HorizontalAlignment="Left" Margin="7,6,0,0" Name="friendList" VerticalAlignment="Top" Width="449" ItemsSource="{Binding Friends}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="5,0">
<Image Height="120" HorizontalAlignment="Left" Name="image" Stretch="Fill" VerticalAlignment="Top" Width="120" Source="{Binding ImageUri}" GotFocus="image_GotFocus"/>
<CheckBox Height="78" HorizontalAlignment="Left" Margin="65,63,0,0" x:Name="selectedChckbox" VerticalAlignment="Top" Width="55" IsChecked="{Binding Selected, Mode=TwoWay}"/>
<TextBlock Height="58" HorizontalAlignment="Left" Margin="0,122,0,0" x:Name="nameTextBlck" VerticalAlignment="Top" Text ="{Binding Title}" Width="120" TextWrapping="Wrap" GotFocus="name_GotFocus"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I've created a veiwmodel for the values for binding, and when I click on one item I want to change the checkbox state like so:
Code:
friendSelectionViewModel.Friends[_selectFriendContent.friendList.SelectedIndex].Selected = !friendSelectionViewModel.Friends[_selectFriendContent.friendList.SelectedIndex].Selected;
But the only way the listbox gets the values updated, if I set the datacontext to null and than assign the viewmodel aggain like so:
Code:
_selectFriendContent.DataContext = null;
_selectFriendContent.DataContext = friendSelectionViewModel;
But this takes about 5-10 seconds to refresh the list. I know there is a better solution, I just cant figure out how.
Thanks in advance!
I don't know what datatype your collection 'friends' is from what you've posted, but I assume it's some kind of collection of objects of type 'Friend' class, and if so you can achieve what you want as long as the 'Friend' class itself is also a viewmodel (i.e. implements INotifyPropertyChanged) and has a property on it called 'Selected'. It's that class that any bindings in your datatemplate will look to as a viewmodel.
Taking the above to be true; what you need is to bind your ListBox's SelectedItem property, e.g.:
<ListBox
x:Name="lbFriendsList"
SelectedItem="{Binding SelectedFriend, Mode=TwoWay}"
...
in your 'friendSelectionViewModel', when an item in the list is selected it will trigger code in the 'SelectedFriend' property's "set" method, where you will have access to the Friend object that has been selected, and you will be able to do whatever you want to it, e.g. to always have it 'checked' when it is tapped, you might have this kind of code in your friendSelectionViewModel (assuming you've got the xaml in place that I've written above):
public Friend SelectedFriend
{
get
{
...
}
set
{
if(value != null)
value.Selected = true;
}
}
As long as you've set up the class Friend as a viewmodel too, and code a 'Selected' property in the Friend class (and as with most properties in viewmodels you set it up to call the typical OnPropertyChanged("Selected "); in its 'set' method) then that will trigger the update of the checkbox that you've set up in the datatemplate (because you've already got that bound to the property 'Selected' in your Xaml).
Hope that's clear and helps
Ian
yes that was the problem, and I missed to implement INotifyPropertyChanged for the TempFriends Class
thanks
Since the Xaml property of the RichTextbox is not a dependency property I have created a customized RichTextbox where I can interact with its xaml property:
Code:
<local:RichTextUserControl RtfXaml="{Binding Path=Text, Converter={StaticResource RichTextBoxContentConverter}}" />
and I am Binding the following text to the xaml property and it is working fine:
Code:
<Section xml:space=\"preserve\" HasTrailingParagraphBreakOnPaste=\"False\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">
<Paragraph FontSize=\"20\" FontFamily=\"Segoe WP\" Foreground=\"#FFFFFFFF\" FontWeight=\"Normal\" FontStyle=\"Normal\" FontStretch=\"Normal\" TextAlignment=\"Left\">
<Run Text=\"Some text without formatting\" />
<Italic>Some italic text</Italic>
<Underline>I am UnderLined</Underline>
</Paragraph>
</Section>
I am binding with it trough a converter, where I search for smiley characters (for example , , so on...) and replacing them with images, and if I insert the following code somewhere in-between the paragraph text it crashes:
Code:
<InlineUIContainer>
<Image Source="ApplicationIcon.png"/>
</InlineUIContainer>
It is only exception when it is with binding.
thanks in advance
The command line client for Stagefright
https://android.googlesource.com/platform/frameworks/av/+/master/cmds/stagefright/stagefright.cpp
Is using MediaSource to play the Video.
How can I set MediaSource to be from byte array (char *), where I can specify it. I want to load the whole file from memory from array (very small video, not need for file streaming)
https://android.googlesource.com/pl.../master/cmds/stagefright/stagefright.cpp#1234
I think MediaSource is an Interface, it has read() methods etc, but nothing to consturct MediaSource from bytearray, char array (char *)
How can I construct proper MediaSource? So that I can just make
playSource(mediaSource);