The sample of Google Maps Android API v2 com.example.mapdemo can not find file "R.java" - google-maps-android-api-2

Today I have read the document of Google Maps Android API v2, it said the project of android-sdk\extras\google\google_play_services\samples\maps can run,
but after I imported into eclipse and set the libraries of android-support-v4.jar and google-play-services.jar correctly, import com.example.mapdemo.R; in FeatureView.java (at line 24) can not find the file R.java.
almost all the java file in com.example.mapdemo need class "R", for example, the file BasicMapActivity.java need R in line 41 "setContentView(R.layout.basic_demo);" and line 71 mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();"
can someone tell me how to find the class "R"?
R
.java can not create automatically because the file multimap_demo.xml have some errors in
<br><br> <fragment
<br> android:id="#+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"
<br> map:cameraTargetLat="48.85"
<br> map:cameraTargetLng="2.35"
<br> map:cameraZoom="8"/>
<br><br>
eclipse said "cameraTargetLat", "cameraTargetLng" and "cameraZoom" can not recognized.
The error information:
Multiple annotations found at this line:
- error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.example.mapdemo'
- error: No resource identifier found for attribute 'cameraZoom' in package 'com.example.mapdemo'
I do not know why.
If I change the code like this:
<br><br> <fragment
<br> android:id="#+id/map3"
<br> android:layout_width="match_parent"
<br> android:layout_height="match_parent"
<br> android:layout_weight="0.5"
<br> class="com.google.android.gms.maps.SupportMapFragment"/>
<br><br>
the errors disappeared, but i do not know if it can run.

Copy the maps_attr.xml file from the library project into your project's values folder.

You should also import google-play-services_lib project (/extras/google/google_play_services/libproject/google-play-services_lib) - after that cameraTargetLat and other ones are recognized and R.java is generated.

you should import /extras/google/google_play_services/libproject/google-play-services_lib as a library in your project.
Import an existing android project at /extras/google/google_play_services/libproject/google-play-services_lib, but remember COPYING IT TO WORKSPACE(important, maybe the path of its original place occurs error)
See your project's properties->Android settings and add library "google-play-services"
Remember to add android-support-v4.jar & google-play-services.jar to your External JARs

1, include both external jar to project
2, copy \extras\google\google_play_services\libproject\google-play-services_lib\res\values\maps_attrs.xml to project value folder
3, copy google-play-services_lib to workspace looks no necessary in my test.
Update:
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable in android

I solved it just adding the following meta-data to the AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

may be this answer can help someone.
this is due to a silly mistake, both the projects ie. Sample project of Map and Google play service project must reside on the same directory otherwise it will not referenced properly
you need do copy projects into workplace for both the projects or if you don't want to copy, so don't do it for both this is the glitch. if you do it properly then you will find this

you have to include xmlns:map="http://schemas.android.com/apk/res-auto" to your layout xml for using map element.
The R file is autogenerate by Eclipse, and you can find it in gen directory. Don't edit this file ever! In some case, you will find there more than one R file, for example when you add a library to your project, like google-play-services_lib. You always can refere to this file at code like this...
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(com.your.package.R.id.map)).getMap();
If you want to configure your map, is posible to make it by XML Attributes or Programmatically.

Related

What is the physical path of Odoo webserver?

I'm building a custom odoo module that will be using several Javascript libraries.
I need to add references to those libraries (local references) but I don't know exactly where to place those libraries and how to refer to their location.
What I tried:
- I created the new module and placed the libraries inside the module directory but it didn't work.
- I also placed the libraries in the home directory of odoo.
As I understand, the problem would be solved if I could get the default directory of the webserver that odoo runs on.
If module is using js files, then you must put these files inside your module. And still if you cant reach these files from your module its your technical error and you have to fix it yourself, also note that odoo has its js libraries already
I found this page: how to add css and js files in Openerp 7 / Odoo module maybe can help you.
Below is the content.
Store files correctly:
CSS and JS files should be reside under 'static' directory in the module(the rest of subdirectory tree under 'static' is an optional convention):
static/src/css/your_file.css
static/src/js/your_file.js
Add files in manifest (v7.0) or in XML(v8.0)
Openerp v7.0 way is to add following entries in manifest (in openerp.py):
...
'css': ['static/src/css/your_file.css'],
'js': [static/src/js/your_file.js'],
...
Odoo v8.0 way is to add corresponding record in the XML:
Add XML to the manifest (openerp.py):
...
'data': [ 'your_file.xml'],
...
Then add following record in 'your_file.xml':
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/>
<script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script>
</xpath>
</template>
....
....
</data>

ionic platform add android- Package name must look like: com.company.Name

Im getting started in developing ionic app, I followed the guide in http://ionicframework.com/docs/guide/installation.html
just in case: the command "ionic platform add ios" works and i have android sdk installed.
when typing the command "ionic platform add android" i get this error:
Adding android project...
/Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/node_modules/q/q.js:126
throw e;
^
Package name must look like: com.company.Name
Error: /Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/create: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
I tried searching an answer in other related posts, but not successful..
I'll appreciate any help in solving my problem..
What mladen5 said is correct. You need to go to the config.xml of your Cordova/Phonegap project and edit the id to meet the package name expectations.
The name can be found in the ID property and is "com.mydomainhere.appnamehere" in the example config below:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mydomainhere.appnamehere" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Awesome app</name>
<description>
The worlds most awesome app
</description>
<author email="your#email.com" href="http://www.anurlhere.com">
Author name
</author>
<content src="index.html" />
<access origin="*" />
</widget>
"Package name must look like: com.company.Name" that error is very helpful. You have package name that is invalid, probably starts with number.
Android package rules:
The first character after a period must not be a number
The first character must be a letter or underscore
Usually the app id is your company's reserved Internet domain name.
The app id must consist of letters, numbers, and underscores.
The best way to do it is when you're creating a new app. The Ionic command line interface(CLI) supports two options to do that the right way:
You can also app and package name define using command line interface(CLI) creation you project time like this bellow.
ionic start MyNewApp blank --appname MyNewApp --id com.ionicbyrequest.mynewapp
MyNewApp is my project app name.
Simple, no ? Now when you deploy to stores your id will be unique.
I had the same problem with Ionic a few weeks ago. The problem can be fixed by editing config.xml.
Find the line that starts with
The syntax inside id="" must be com.company.(company name)
ID should be without dashes, just words separated with dots: word.word.word
In your config.xml give the package name according to your project package name
Give widget id in your config.xml as com.test.testapp

Appbundler JDK8 MacOS Set WorkingDirectory Inside Package

Hi everyone !
I'm facing a problem since I'm migrating my app from Java6 to Java8 for MacOS (and other OS but with windows/linux there is NO problem !).
When I was using Java6 I used MacOS APP "App Bundler" to do the package.
This tools reference to a plist file that contains all package information and provide the ability to add an option "WorkingDirectory" and a variable $APP_PACKAGE to set the working directory of the package inside the package like that:
<key>WorkingDirectory</key>
<string>$$APP_PACKAGE/Contents/Resources/Java</string>
Unfortunately, this option "WorkingDirectory" does not exist with the bundler appbundler that provides support for Java 6 superior versions.
So I googled a lot and found this issue; Apple Issue
So I added <option value="-Duser.dir=$APP_ROOT/Contents/Resources"/> to my plist file via ant task like that:
<key>JVMOptions</key>
<array>
<string>-Xdock:icon=Contents/Resources/${bundle.icon}</string>
<string>-Duser.dir=$APP_ROOT/Contents/Resources</string>
</array>
And I tied also this:
<option value="-Duser.dir=$APP_ROOT/Contents/Java" />
<argument value="-Duser.dir=$APP_ROOT/Contents/Java"/>
Without success :-(
And I added a big "verrue" on early start of my Java application like that (as said here):
String os = System.getProperty("os.name").toLowerCase();
System.out.println("os:" +os);
if (os.indexOf( "mac" ) >= 0){
try {
System.setProperty("user.dir", new File(".").getCanonicalPath());
System.out.println("user dir:" +System.getProperty("user.dir"));
System.out.println(new File(".").toURI());
System.out.println("Working directory: "+(new File(".").getCanonicalPath()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
But nothing works; when I was creating file from the previous Java application they were created into the application working dir like /Applications/MyApp.app/Content/Java, but know when I create a file/folder it is created under /Users/MyUserName
I also follow this PATCH (I post a question) and compile a new jar but the <string>-Duser.dir=$APP_PATH/Contents/Java</string> does not do the job, the env variable is not user system created and used!
It's driving me silly... Any idea ? Regards !!
[EDIT1] As a workaround and because it is also simple but too bad I just changed all my relative paths (some at least !) like that:
String path = new File(".").getCanonicalPath();
File myFile = new File(path+File.separator+"MyFile");
It acts similar to set the working directory variable but I have to change a lot of my code rather than use a single option (and on Linux and Windows I do not have this type of problem) :-( Anyway thanks to Trejkaz to have answer on my issue... and sorry for my misspellings and my poor English.
Another time, Regards !!
[EDIT2] So I edited all my relative paths but I had a second problem with the appbundle: Every ProcessBuilder commands fails when launched by the bundle but succeed when clicking on the jar so I used "desktop" intead like this:
DesktopApi desktopApi = new DesktopApi();
desktopApi.open("path-to-my-jar"+File.Separator+"MyJar.jar");
I use the class 'DesktopApi' found here coded by MightyPork (Regards !!) as sometimes desktop command provided by JRE fails...
So I'm done with this fu***** packaging now !!! Regards !!

GWT-Youtube-API no source code available for YouTubeEmbeddedPlayer

I tried to embed a Video in my GWT Project but I get the following error in my console when I open the panel containing the video:
No source code is available for type com.google.youtube.client.YouTubeEmbeddedPlayer; did you forget to inherit a required module?
My Build Path for the Project
And this is the example code
YouTubeEmbeddedPlayer youTubeEmbeddedPlayer = new YouTubeEmbeddedPlayer("hqXUKxJiDls");
youTubeEmbeddedPlayer.setWidth("427px");
youTubeEmbeddedPlayer.setHeight("320px");
absolutePanel.add(youTubeEmbeddedPlayer, 200, 30);
project.gwt.xml:
<inherits name="com.google.gdata.YouTubeAPI" />
<inherits name="com.google.youtube.Player" />
I followed the GettingStarted wiki entry but I don't know where to put the settings.xml (it's not explained).
Thank's in advance.
Try adding gwt-youtube-api-1.0.3-sources.jar to your classpath as a standard library instead of adding it as a source attachment for gwt-youtube-api-1.0.3.jar.

Lint: How to ignore "<key> is not translated in <language>" errors?

I can't compile/debug our Android app, because the localization files are not perfect yet.
My IDE's validation tool Lint create errors saying:
newCardsOrderVals is not translated in ar, bg, ca, cs
Compiling/installing/running with Ant works fine, but I would like to use my IDE to ease debugging.
Is there a way to turn off this particular check, or ideally make it a warning rather than an error?
I understand that before release we will really need to get localisation files right, but for the time being it is not a priority as the screens themselves are being modified very frequently.
Android Studio:
"File" > "Settings" and type "MissingTranslation" into the search box
Eclipse:
Windows/Linux: In "Window" > "Preferences" > "Android" > "Lint Error Checking"
Mac: "Eclipse" > "Preferences" > "Android" > "Lint Error Checking"
Find the MissingTranslation line, and set it to Warning as seen below:
You can set the attribute translatable="false" on the definition like this:
<string name="account_setup_imap" translatable="false">IMAP</string>
For more information: http://tools.android.com/recent/non-translatablestrings
To ignore this in a gradle build add this to the android section of your build file:
lintOptions {
disable 'MissingTranslation'
}
This will cause Lint to ignore the missing translation error for ALL strings in the file, yet other string resource files can be verified if needed.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
If you want to turn off the warnings about the specific strings, you can use the following:
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--suppress MissingTranslation -->
<string name="some_string">ignore my translation</string>
...
</resources>
If you want to warn on specific strings instead of an error, you will need to build a custom Lint rule to adjust the severity status for a specific thing.
http://tools.android.com/tips/lint-custom-rules
Insert in the lint.xml file this:
<?xml version="1.0" encoding="UTF-8"?>
<lint>
...
<issue
id="MissingTranslation"
severity="ignore" />
</lint>
For more details: Suppressing Lint Warnings.
add the lines in your /res/values.xml file in resource root tab like this:
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:locale="en" tools:ignore="MissingTranslation">
tools:locale set the local language to English, no need of language translation later on that for all resource strings and tools:ignore let Lint to isnore the missing translations of the resource string values.
Add following to your gradle file in android section
lintOptions {
disable 'MissingTranslation'
}
In addition,
Not project dependent properities, Eclipse Preferences.
In Mac, Eclipse > Preferences
Another approach is to indicate the languages you intend to support and filter out the rest using the 'resConfigs' option with Gradle.
Check out this other answer for details
This is better, I think, because you don't have to completely ignore legitimate translation mistakes for languages you actually want to support
You can also put resources which you do not want to translate to file called donottranslate.xml.
Example and explanation: http://tools.android.com/recent/non-translatablestrings
Many of them has a given a different working answers, and i too got the same lint errors
i make it ignore by doing the following with eclipse.
click on Windows
click on preferences
select android > Lint Error Checking.
click on ignore All > Apply > Ok.
Thats it.
The following worked for me.
Click on Windows
Click on preferences
Select android > Lint Error Checking.
Find and select the relevant Lint checking and
Set the severity to 'Ignore' (on bottom right)