Google map displaying only blank tiles android - android

I have implemented google map in my app.But its display only blank grids.I have done changes in AndroidManifest.xml file and also included API key in layout file of map activity.

This may sound silly, but I kept encountering this problem until I realized that the <uses-permission> tags need to be direct children to the <manifest> element, rather than the <application> element. I had erroneously been putting them right after the <uses-library> tag. So the final structure of your AndroidManifest.xml file should be something like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<uses-sdk ... />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application ... >
<activity ... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
Hope this helps anyone who was making the same mistake!

I was having the same problems until I realised that in the API console I had enabled
Google Maps API v2
and not the
Google Maps Android API v2
Once I enabled it everything was fine.

The problem is the code API. Use the following function to see if the Key Google Maps is correct:
private String getShaKey() {
//fucnion para saber si esta bien registrado el codigo de googlemaps
//ME SALE EXCEPTION DE NOMBRE NO ENCONTRADO?¿?¿
String strRet="";
try {
PackageInfo info = getPackageManager().getPackageInfo("your.package.name",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
//Log.v(TAG, "KeyHash:" + Base64.encodeToString(md.digest(),
strRet="KeyHash:" + Base64.encodeToString(md.digest(),Base64.DEFAULT);
}
} catch (NameNotFoundException e) {
//e.printStackTrace();
strRet="EXCEPTION NOMBRE NO ENCONTRADO";
} catch (NoSuchAlgorithmException e) {
//e.printStackTrace();
strRet="EXCEPTION ALGORITMO NO";
}
return strRet;
}

This happens to me also. On the first time I successfully launched the Google maps, in works fine, on the second day, the entire map(default view) is rendered only in half while the other half are filled with tiles only, after changing some properties in the map, it all went to tiles only.
Now, what I did is I renew my API key and everything went fine.

This happened to me when I launched the map as intent (Intent intent = new Intent(android.content.Intent.ACTION_VIEW, mapUrl) ...). The map was created empty and did not load anything. The map showed my icon as "logged in user" in the top right corner, but no error messages at all. Everything worked flawlessly on the emulator. Finally, I checked the normal Google Map App and it was empty too.
Solution: Remove my Google account from Settings App of the development device. It took me several hours to figure that out. No clue what that was, but maybe it saves someone time to know.

I had the same problem. I added this line on the Manifest.xml and everything is working fine now :
<uses-library android:name="com.google.android.maps" />

Related

The Client Token must be specified in the string resource file as com.facebook.accountkit.ClientToken

I have an android project and i want to use facebook account kit. I did all settings but when i run the project, i am getting this message;
E/AndroidRuntime: 500: Initialization error: 503: The Client Token must be specified in the string resource file as com.facebook.accountkit.ClientToken
But i specified it in strings.xml
<string name="ACCOUNT_KIT_CLIENT_TOKEN">***</string>
AndroidManifest.xml
<meta-data android:name="com.facebook.accountkit.ClientToken"
android:value="#string/ACCOUNT_KIT_CLIENT_TOKEN" />
Waiting for your helps, thank you.
For me solution was adding following to the manifest file:
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<meta-data android:name="com.facebook.accountkit.ApplicationName"
android:value="#string/app_name"/>
<meta-data
android:name="com.facebook.accountkit.ClientToken"
android:value="#string/ACCOUNT_KIT_CLIENT_TOKEN" />
And the creating the respective String resources as:
facebook_app_id with app id, found at top-left corner next to navigation pane of facebook developer console for your app.
app_name which is already defined generally in your string resource file with the name of your app.
ACCOUNT_KIT_CLIENT_TOKEN with value found at Settings>advanced in navigation drawer of facebook developer console. Then go to Security, there you will find "Client Token". Use this client token value for value of this String resource.
This worked for me. Hope this helps.
You should have something like this in string resources (you have to get the app_id)
<string name="facebook_app_id">2077942129****</string>
and in you Manifest:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
Check the attached to find to solution click on your products then go account-kit-->settings

Why I can't load an internet image on a android app using a real device?

I am developing an app for student purposes and I found an error while testing it on a real device. Here is a piece of code of my app. I use this AsynTask to retrieve information through a webpage and that works just fine.
protected void onPostExecute(PlaceRecord result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
// Refresh the values
ImageView imageFlag = (ImageView) findViewById(R.id.imageViewFlag);
try {
InputStream is = (InputStream) new URL(place.getFlagUrl())
.getContent();
Drawable d = Drawable.createFromStream(is, "src name");
Log.i(TAG, "D: " + d.toString());
if (d.toString() == "") {
imageFlag.setImageResource(R.drawable.logo_fondo);
} else {
imageFlag.setImageDrawable(d);
}
} catch (Exception e) {
Log.e(TAG, "que conho pasa: " + e);
e.printStackTrace();
} TextView textVCountry = (TextView) findViewById(R.id.textViewCountryName);
textVCountry.setText(place.getCountryName());
TextView textVPlace = (TextView) findViewById(R.id.textViewResolverPlace);
textVPlace.setText(place.getPlace());
Here is the thing, when I run this on my emulator is works perfect. Result is an object that have String countryName, String place and a FlagURL that is a URL of a image on the web. When I run this on the emulator I get the image and the two texts all perfect, but when I run it on a real device (at first I used a bitmap but it just crashed and I didn't know why..and the logcat window for the real device didnt giv
e me much help) then with this method it does not crash but when I run it it doesn't show anything.. on the emulator it shows, if you change the url for another image it shows the new one, but on the real one nope.
I can show you more code if you want, I just not wanted to fill this with code. The problem is that the logcat window doesnt show anything...
An important thing is that my real device has android 4.2 but the emulator 2.3
Any guest?
Thank you
This is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="advance.modelling.yourvistit"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="advance.modelling.yourvisit.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
You must work with internet in background thread. Move code which downloads image to doInBackground() function of your AsyncTask class. In onPostExecute you should set already downloaded image in your ImageView(Because you can work with views only in main thread)
Getting image in main thread can work only for old Android devices.

Multiple API keys in the same Android project

Is it possible to specify multiple keys for Google Maps Android API in the same code base?
It looks like I have to change the key in manifest file each time I change keystore. It's not very convenient, imho, if you need to test the app signed with keys form debug and release keystores.
I added both keys in the manifest at once. Like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
..
android:versionCode="1"
android:versionName="1.0" >
<!-- RELEASE key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my-release-keu" />
<!-- DEBUG key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my-debug-key" />
</application>
</manifest>
Apparently, this works. Looks like Google code is smart enough to use relevant key automatically.
I don't think this is what you want to do. You should add both debug and release SHA1 key to API key on Google Developer API Console. Take a look at this answer
AFAIK, there is no programmatical form on doing this. For comodity, you can define API keys in strings.xml, and retrieve it from the manifest
String debugMapKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String releaseMapKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String mapKey = BuildConfig.DEBUG ? debugMapKey : releaseMapKey;
MapView mv = new MapView(this, mapKey);

I get "nextRation is null!" error trying to use Adwhirl + AdMob in Android

I've been trying to solve this problem for weeks. There are some other similar questions in StackOverflow, and there are some (apparently solved) similar issues in AdWhirl documentation website (one and two), but this error is still bothering me.
AdWhirl documentation is rather incomplete and confusing. The steps I've followed:
I created an AdMob account and I got the AdMob ID.
I created an AdWhirl account, I put there the AdMob ID and I got the AdWhirl ID.
I added in my Java Build Path the AdMob SDK Jar 4.3.1 and the AdWhirl SDK Jar 3.1.1
In my Manifest file I added the following lines:
.
<manifest>
[...]
<application>
[...]
<activity android:name="com.google.ads.AdActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data android:value="[AdWhirl ID]" android:name="ADWHIRL_KEY"/>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
In all the layouts I want ads I added the following lines:
.
<com.adwhirl.AdWhirlLayout
android:id="#+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="72dip" />
In all the activities related to those layouts I added the following lines:
.
public class XXX extends ListActivity implements AdWhirlInterface {
[...]
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YYY);
initAds();
[...]
}
[...]
private void initAds() {
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);
adWhirlLayout.setAdWhirlInterface(this);
}
public void adWhirlGeneric() {
Log.e(AdWhirlUtil.ADWHIRL, "In adWhirlGeneric()");
}
}
Project Build Target: Google API Android 4.0
Emulator: Google APIs 2.1 (API 7)
What am I doing wrong?
I see no ads and all the time I get the "nextRation is null!" error.
This looks like pretty much like the minimalistic AdWhirl implementation. FYI, you don't need the adWhirlGeneric() method.
There are a couple of reasons nextRation may be null.
The AdWhirl servers may have been down during the time you had this issue, or that you misconfigured some settings in the AdWhirl UI. These errors are unlikely.
AdWhirl tried to request an AdMob ad, and it failed for whatever reason (my money is on lack of inventory), and AdWhirl had no next ration, meaning there are no more ad networks to try to request an ad from (and it will try again on next refresh).
NOTE: A Ration in AdWhirl represents an ad network settings, like network name and it's corresponding network id.
Check the logcat output again, and see what leads up to the nextRation is null error. Is it a JSONException? If so, that means you have issue #1. Do the logs say you found an AdMob ration, then AdMob responded with onFailedToReceiveAd, and then you get nextRation is null? Then you have issue #2.
I had the same issue and found a solution following this post:
http://code.google.com/p/adwhirl/issues/detail?id=27
Hope it can help you too.

Unable to resolve activity for: Intent

I am having a problem in running Android unit test. I got this error when I tried to run a simple test.
Here's the log:
Blockquote
java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.wsandroid.Activities/.SplashActivity }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
at com.wsandroid.test.activity.TestEULA.setUp(TestEULA.java:15)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
This error occurs for Android less than 2.2. It works fine for Android 2.2 emulator. Yet Android 2.2 emulator has a bug of sending a key twice even though we only press it one. Application to be tested runs on Android 2.2 platform.
Appreciate if anyone of you can help me.
Dzung.
This can also be cause by a missing
Make sure you have a corresponding entry in your manifest.
<activity android:name=".SplashActivity" ...
I had a similar problem with a simple test project for an app that was just a splash screen. I found that I had implemented the constructor wrong. My initial implementation of the constructor was this...
public SplashScreenTest(){
super("com.mycomp.myapp.SplashScreen", SplashScreen.class);
}
After some beating my head against the wall, I somehow decided to remove the SplashScreen from the pkg argument of super(). My successful implementation is now like this...
public SplashScreenTest() {
super("com.mycomp.myapp", SplashScreen.class);
}
I hope that this helps you or others solve the problem.
Try to check your Manifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tablet.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="android.test.runner" />
</application>
<uses-sdk android:minSdkVersion="8" />
<!-- This line below! -->
<instrumentation android:targetPackage="com.tablet.tablet"
android:name="android.test.InstrumentationTestRunner" />
</manifest>
You need to check the following line:
<instrumentation android:targetPackage="com.tablet.tablet"
android:name="android.test.InstrumentationTestRunner" />
So the targetPackage must be the same as in your code.
I had specific similar problem while using the AndroidAnnotations lib.
Later, I found out it was due to forgetting to use the generated class (MyActivity_ instead of MyActivity).
In my case the problem was that TestFragmentActivity, meaning the Activity used in our test
extends ActivityInstrumentationTestCase2<TestFragmentActivity>
must be available in the package defined in Manifest.xml as targetPackage:
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="de.my.androidhd" />
My solution was to move TestFragmentActivity into tested application package.
For the keys being sent twice issue, are you sure you're not now getting both the Down and Up actions? I had this issue when using Robotium, and generated this to make things easier:
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.widget.EditText;
import com.jayway.android.robotium.solo.Solo;
public static void type(Solo robot, EditText edit, String text) {
int index = 0;
//Find the index of this control, as Robotium doesn't seem to like R.id
for (int i = 0; i < robot.getCurrentEditTexts().size(); i++) {
if (robot.getCurrentEditTexts().get(i).getId() == edit.getId()) {
index = i;
}
}
robot.clickOnEditText(index);
KeyCharacterMap map = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
KeyEvent[] events = map.getEvents(text.toCharArray());
for (int event = 0; event < events.length; event++) {
if (events[event].getAction() == KeyEvent.ACTION_DOWN) {
robot.sendKey(events[event].getKeyCode());
}
}
}
I've had two activities with same name in different packages. Issue was about importing from the wrong package. I spend much time on it maybe it will save someone some time.

Categories

Resources