My apps were running well on a "Samsung Galaxy S5" in USA, using T-Mobile as my service provider.
Now. I am testing the same app on a "vivo v3ma" in China using China Mobile as my service provider. It is running Android 5.1 (Lollipop).
On the Chinese vivo, I have installed Play Store, Google Maps and Google Street View. On running G/Maps, it reported that GPS was not or cannot be turned on, and G/Maps downloaded and will use Google APIs to display maps.
G/Maps run well after that, it can display bilingual maps of Shanghai.
But when I run my app, it crashes when it tried to display the same Google maps. The console displays following NullPointerException error:
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d30b20)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.swpwr.builders.swpwrassetlocation, PID: 2206
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.swpwr.builders.swpwrassetlocation/com.swpwr.builders.swpwrassetlocation.ShowMapsActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
Also, when I plug the vivo3ma into the laptop running A/Studio, the AVD Manager cannot see it. When I plug my Galaxy S5 in, the AVD Manager displays it prominently.
Questions:
(1) What Google APIs do I need to import/compile into my app to display the G/Maps in China ?
(2) Why can't A/Studio's AVD screen see the vivo3ma phone ?
My build-gradle xml. Are there some other Google APIs that I have to include in the dependencies??
XML to show map
The activity code, I've hi-lited the line where the app crashed:
A/Studio jump to this error message when it hit the above line of code.
D/dalvikvm: GC_FOR_ALLOC freed <1K, 3% free 7946K/8188K, paused 5ms, total 5ms
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 177 (Landroid/graphics/drawable/RippleDrawable in Landroid/support/v7/widget/AppCompatImageHelper;
Now. I am testing the same app on a "vivo v3ma" in China using China Mobile as my service provider. It is running Android 5.1 (Lollipop).
On the Chinese vivo, I have installed Play Store, Google Maps and Google Street View. On running G/Maps, it reported that GPS was not or cannot be turned on, and G/Maps downloaded and will use Google APIs to display maps.
G/Maps run well after that, it can display bilingual maps of Shanghai.
But when I run my app, it crashes when it tried to display the same Google maps. The console displays following NullPointerException error:
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d30b20)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.swpwr.builders.swpwrassetlocation, PID: 2206
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.swpwr.builders.swpwrassetlocation/com.swpwr.builders.swpwrassetlocation.ShowMapsActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
Also, when I plug the vivo3ma into the laptop running A/Studio, the AVD Manager cannot see it. When I plug my Galaxy S5 in, the AVD Manager displays it prominently.
Questions:
(1) What Google APIs do I need to import/compile into my app to display the G/Maps in China ?
(2) Why can't A/Studio's AVD screen see the vivo3ma phone ?
My build-gradle xml. Are there some other Google APIs that I have to include in the dependencies??
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.swpwr.builders.swpwrassetlocation"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
// enable multi-dex support
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-identity:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
}
XML to show map
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.swpwr.builders.swpwrassetlocation.ShowMapsActivity"
tools:showIn="@layout/activity_show_maps">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/map_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
</RelativeLayout>
The activity code, I've hi-lited the line where the app crashed:
Code:
...
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class ShowMapsActivity extends Activity implements OnMapReadyCallback {
private GoogleMap gMap;
private MapFragment mapFragment;
private LatLng depot;
private LatLng current;
private LatLng site;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
// adjust the zoom level of the map, from 1 to 16
private int zoomLevel = 9;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// grab the current latitude and longitude of the truck
Bundle bundle = getIntent().getParcelableExtra("bundletag");
depot = bundle.getParcelable("depotLatLng");
site = bundle.getParcelable("siteLatLng");
current = bundle.getParcelable("currentLatLng");
//
setContentView(R.layout.activity_show_maps);
mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
mapFragment.getMapAsync(this);
// This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
public void onMapReady(GoogleMap thisMap) {
gMap = thisMap;
// etc lotsofcode...
...
D/dalvikvm: GC_FOR_ALLOC freed <1K, 3% free 7946K/8188K, paused 5ms, total 5ms
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 177 (Landroid/graphics/drawable/RippleDrawable in Landroid/support/v7/widget/AppCompatImageHelper;
Last edited: