Hi I am trying to bind wikitude .aar fine in xamarin...I am having some issues
Com.Wikitude.Tracker.IObjectTrackerListener.cs(47,47): Error CS0102: The type 'TargetsLoadedEventArgs' already contains a definition for 'p0' (CS0102) (AarBinding)
Com.Wikitude.Tracker.IObjectTrackerListener.cs(14,14): Error CS0102: The type 'ErrorLoadingTargetsEventArgs' already contains a definition for 'P1' (CS0102) (AarBinding)
I tried to use the Metadata.xml as
<attr path="/api/package[#name='Com.Wikitude.Tracker']/class[#name='ErrorLoadingTargetsEventArgs']/field[#name='p0']" name="managedName">p0_2</attr>
But it is now working any suggestions Please ?
Hi I was as able to fix this issue..It may be helpful for others
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<attr path="/api/package[#name='com.wikitude.tracker']/interface[#name='ObjectTrackerListener']/method[#name='onTargetsLoaded']/parameter[1]" name="managedName">tracker</attr>
<attr path="/api/package[#name='com.wikitude.tracker']/interface[#name='ObjectTrackerListener']/method[#name='onErrorLoadingTargets']/parameter[1]" name="managedName">tracker</attr>
<attr path="/api/package[#name='com.wikitude.tracker']/interface[#name='ObjectTrackerListener']/method[#name='onErrorLoadingTargets']/parameter[2]" name="managedName">errorCode</attr>
<attr path="/api/package[#name='com.wikitude.tracker']/interface[#name='ObjectTrackerListener']/method[#name='onErrorLoadingTargets']/parameter[3]" name="managedName">errorMessage</attr>
<attr path="/api/package[#name='com.pbar.samples']/class[#name='StartActivity']"
name="visibility">public</attr>
</metadata>
Related
I am declaring a styleable view with attrs, and I created the file myview_attrs.xml this simple way:
<resources>
<declare-styleable name="TestStyleable">
<attr name="testAttr" format="integer"/>
</declare-styleable>
</resources>
Then, I want to load this attr in my code:
void loadAttributes(AttributeSet attrs) {
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.);
}
After R.styleable. , with ctrl-SPACE, these are the options I am given:
That is obviously wrong. Indeed, I can't select R.styleable.TestStyleable, because it's not proposed in the menu, but only R.styleable.TestStyleable_testAttr, that does not make sense.
Of course, if I choose the second one it gives me error, because a int[] is expected and I put an int. On the other side, if I manually write R.styleable.TestStyleable fails with "Cannot resolve symbol".
What am I missing here??
Update: this ended to be an Android Studio bug.
As #Yurii Tsap stated, this is an Android Studio bug, and it finally got fixed by making
File -> Invalidate Caches / Restart
I have created a custom compound view inside a library application and everything was OK. When I add custom attributes to view, I always get default values. I followed this steps with only one difference: my view is in a library project.
/res/values/attrs.xml
<resources>
<declare-styleable name="DatePickerView">
<attr name="showToday" format="boolean" />
<attr name="calendar" format="enum">
<enum name="jalali" value="0" />
<enum name="gregorian" value="1" />
</attr>
</declare-styleable>
</resources>
Layout file that contains view:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:farayan="http://schemas.android.com/apk/lib/net.farayan.android.view"
...
<net.farayan.android.view.datepicker.DatePickerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
farayan:showToday="false"
farayan:calendar="gregorian"/>
...
Component's code:
int calendar;
boolean showToday;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePickerView, 0, 0);
try {
calendar = a.getInteger(R.styleable.DatePickerView_calendar, 0);
showToday = a.getBoolean(R.styleable.DatePickerView_showToday, true);
} finally {
a.recycle();
}
calendar and showToday are always 0 and true respectively. Any idea?
It looks like something is not right here:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:farayan="http://schemas.android.com/apk/lib/net.farayan.android.view"
What about change to:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:farayan="http://schemas.android.com/apk/res/net.farayan.android.view"
net.farayan.android.view is your app root namespace.
update1
xmlns:farayan="http://schemas.android.com/apk/res/your_main_app_package"
Here is am example. It use a view defined in the library project.
If we add new compound view code and its attributesinside project, we should add this at the beginning of layout:
xmlns:custom="http://schemas.android.com/apk/res/your_main_app_package
and if new compound view is inside a library project linked to our peoject, we should add this:
xmlns:custom="http://schemas.android.com/apk/res-auto
Link: https://stackoverflow.com/a/10217752/1152549
Here is the code I am using:
public ASSwitch(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray sharedTypedArray = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.ASSwitch,
0, 0);
try {
onText = sharedTypedArray.getText(R.styleable.ASSwtich_onText, null);
} finally {
sharedTypedArray.recycle();
}
}
Here is the attrs.xml file (added to values folder):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ASSwitch">
<attr name="onText" format="string" />
<attr name="offText" format="string" />
<attr name="onState" format="boolean" />
<attr name="toogleDrawable" format="string" />
<attr name="frameDrawable" format="string" />
</declare-styleable>
</resources>
The answers in these questions couldn't fix the problem. Please don't consider my question as duplicate.
Android Hello, Gallery tutorial -- "R.styleable cannot be resolved"
Android: How to Declare Styleable in R.java?
R.styleable can not be resolved, why?
R.styleable cannot be resolved
Update: It seems that I was importing the wrong R class. It shall be the application's R class not android.R.
Check your imports:
Wrong: Android.R
Correct: com.example.yourproject.R
I had the same error when made this customized view. Maybe when follow the guiding step, the helper tool automatically inserts this wrong import.
It seems that I was importing the wrong R class. It shall be the application's R class not android.R
I've been working on a Custom Control for Android and although I tried to do what's suggested here there seems to be something I'm doing wrong.
Here's my code to see if anyone can spot the problem:
MyComponent.java
public MyComponent(Context context, AttributeSet attrs)
{
super(context);
TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.MyComponent);
CharSequence myId = arr.getString(R.styleable.MyComponent_identifier);
if (myId != null)
{
this.setIdentifier(myId.toString());
}
Integer cds = arr.getInteger(R.styleable.MyComponent_cd_number, 0);
if(cds != null)
{
this.setCds(cds);
}
arr.recycle();
}
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyComponent">
<attr name="cd_number" format="integer" />
<attr name="identifier" format="string" />
</declare-styleable>
</resources>
main.xml
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bgl="http://schemas.android.com/apk/res/my.test.package.components"
android:id="#+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<my.test.package.MyComponent
android:id="#+id/hand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
bgl:cd_number="4"
bgl:identifier="plr"/>
...
</TableLayout>
When I put this I get the following errors:
error: No resource identifier found for attribute 'cd_number' in package 'my.test.package'
error: No resource identifier found for attribute 'identifier' in package 'my.test.package'
If I change my namespace to something like:
xmlns:bgl="http://schemas.mywhatever.com/apk/res/my.test.package"
...the errors go way and the thing runs but myId is null and cds is 0 (the default value!) back on the MyComponent.java constructor.
I'd say it's some very basic mistake but I not being able to spot it and since there's not much documentation on this I decided to ask here.
Thanks in advance!
Ok. I got it solved!
On the original post I had:
xmlns:bgl="http://schemas.android.com/apk/res/my.test.package
...but in my source I had:
xmlns:bgl="http://schemas.android.com/apk/res/my.test.package.components
...because I thought one should put the URI to the components package.
THIS IS WRONG!
On the xmlns it should be the application name as is declared on the Manifest!
When I removed the "components" part of the xmlns it "matched" the application name in the Manifest and the errors went away and when I ran the thing in debug I could actually see the values I was passing to the parameters in the XML!
Hope this helps someone else! :-)
UPDATE
Later on I had the need to move the control into a library and faced the problem again. It seems that when you put the component in a library and use it on a client app you must declare the xmlns as below:
xmlns:myns="http://schemas.android.com/apk/res-auto"
If you do so (and have the library declared as an Android dependency) Eclipse (or is it Android?) will search the dependencies for the appropriate attribute bindings.
I had a problem similar to this, turned out it was calling a different constructor
Try with the constructor that takes in the defStyle parameter
public MyComponent(Context context, AttributeSet attrs, int defStyle)
I've been searching for the answer for a while, but I can't find the same set of circumstances, so I turn to you for help...
I'm trying to use the google SDK (not the admob sdk) to put ads in my android app. When running the app in the emulator, the log messages that I see are:
03-25 22:35:17.457: INFO/Ads(853): adRequestUrlHtml: [ contains two <script> tags ]
03-25 22:35:21.028: INFO/Ads(853): Received ad url: [ big long url ]
Sometimes I get:
03-25 22:35:21.828: INFO/Ads(853): onFailedToReceiveAd(No ad to show.)
which perhaps I can understand, but I also get:
03-25 22:50:56.817: INFO/Ads(1084): onFailedToReceiveAd(A network error occurred.)
If I hit the "big long url" above in my desktop browser, I get an ad about 1/2 the time and blank the other 1/2. (Hello, Dish Network) I never get an error.
I can browse the web with the emulator's browser, so the network component is working.
The app has internet privileges.
I'm frustrated with the lack of usable sample code - I see a lot of people using the old admob SDK and a few code fragments of people using the google SDK, but not a soup-to-nuts example/tutorial.
I've commented out the rest of my code, to no avail. Here's the main chunk of code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdView adView = new AdView(this, AdSize.BANNER, ADMOB_PUBLISHER_ID);
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
AdRequest req = new AdRequest();
// req.setTesting(true);
adView.loadAd(req);
}
My manifest includes this:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
and
<uses-permission android:name="android.permission.INTERNET" />
My main.xml contains this layout for the page:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/yellow"
android:id="#+id/mainLayout"
>
admob support hasn't replied.
Can anyone help me or at least refer me to the perfect google sdk guide for admob noobs?
Thanks!
have you add attr.xml file???
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.google.ads.AdView">
<attr name="adSize">
<enum name="BANNER" value="1"/>
<enum name="IAB_MRECT" value="2"/>
<enum name="IAB_BANNER" value="3"/>
<enum name="IAB_LEADERBOARD" value="4"/>
</attr>
<attr name="adUnitId" format="string"/>
</declare-styleable>
</resources>
try adding this permission line to your AndroidManifest.xml file
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Friends, I meet the same problem today. I followed the whold google instruction. Finally, I got it. You can customize the request for call load. Like this:
AdRequest re = new AdRequest();
//re.setTesting(true);
re.setGender(AdRequest.Gender.FEMALE);
adview.loadAd(re);
You can try my example, I put my apk and source code here:
Add Google Admob in Android Application